fix(agents): restore canonical core agent ordering

Remap the core agent keys, default agent, and command routing back to\nlist display names so OpenCode's name-based sorting keeps the\ncanonical Sisyphus -> Hephaestus -> Prometheus -> Atlas order.\n\nAlso teach tool config lookups to resolve the prefixed list keys and\nadd regression tests that exercise the real ordering and routing path.
This commit is contained in:
YeonGyu-Kim
2026-04-09 12:42:48 +09:00
parent 132a994cfc
commit 4f88e0f4e1
11 changed files with 107 additions and 68 deletions
+35 -35
View File
@@ -4,7 +4,7 @@ import { describe, test, expect, spyOn, beforeEach, afterEach } from "bun:test"
import { resolveCategoryConfig, createConfigHandler } from "./config-handler"
import type { CategoryConfig } from "../config/schema"
import type { OhMyOpenCodeConfig } from "../config"
import { getAgentDisplayName, getAgentDisplayName } from "../shared/agent-display-names"
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names"
import * as agents from "../agents"
import * as sisyphusJunior from "../agents/sisyphus-junior"
@@ -246,10 +246,10 @@ describe("Plan agent demote behavior", () => {
// #then
const keys = Object.keys(config.agent as Record<string, unknown>)
const coreAgents = [
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
getAgentListDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"),
getAgentListDisplayName("atlas"),
]
const ordered = keys.filter((key) => coreAgents.includes(key))
expect(ordered).toEqual(coreAgents)
@@ -294,10 +294,10 @@ describe("Plan agent demote behavior", () => {
reorderSpy.mock.calls.at(0)?.[0] as Record<string, unknown>
)
expect(assembledAgentKeys.slice(0, 4)).toEqual([
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
getAgentListDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"),
getAgentListDisplayName("atlas"),
])
})
@@ -336,7 +336,7 @@ describe("Plan agent demote behavior", () => {
expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("subagent")
expect(agents.plan.prompt).toBeUndefined()
expect(agents[getAgentDisplayName("prometheus")]?.prompt).toBeDefined()
expect(agents[getAgentListDisplayName("prometheus")]?.prompt).toBeDefined()
})
test("plan agent remains unchanged when planner is disabled", async () => {
@@ -370,7 +370,7 @@ describe("Plan agent demote behavior", () => {
// #then - plan is not touched, prometheus is not created
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
expect(agents[getAgentDisplayName("prometheus")]).toBeUndefined()
expect(agents[getAgentListDisplayName("prometheus")]).toBeUndefined()
expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("primary")
expect(agents.plan.prompt).toBe("original plan prompt")
@@ -401,7 +401,7 @@ describe("Plan agent demote behavior", () => {
// then
const agents = config.agent as Record<string, { mode?: string }>
const prometheusKey = getAgentDisplayName("prometheus")
const prometheusKey = getAgentListDisplayName("prometheus")
expect(agents[prometheusKey]).toBeDefined()
expect(agents[prometheusKey].mode).toBe("all")
})
@@ -437,7 +437,7 @@ describe("Agent permission defaults", () => {
// #then
const agentConfig = config.agent as Record<string, { permission?: Record<string, string> }>
const hephaestusKey = getAgentDisplayName("hephaestus")
const hephaestusKey = getAgentListDisplayName("hephaestus")
expect(agentConfig[hephaestusKey]).toBeDefined()
expect(agentConfig[hephaestusKey].permission?.task).toBe("allow")
})
@@ -465,7 +465,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus"))
})
test("canonicalizes configured default_agent when key uses mixed case", async () => {
@@ -489,7 +489,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus"))
})
test("canonicalizes configured default_agent key to display name", async () => {
@@ -513,13 +513,13 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// #then
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus"))
})
test("preserves existing display-name default_agent", async () => {
// #given
const pluginConfig = createPluginConfig({})
const displayName = getAgentDisplayName("hephaestus")
const displayName = getAgentListDisplayName("hephaestus")
const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-6",
default_agent: displayName,
@@ -561,7 +561,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// #then
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
expect(config.default_agent).toBe(getAgentListDisplayName("sisyphus"))
})
test("sets default_agent to sisyphus when configured default_agent is empty after trim", async () => {
@@ -585,7 +585,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
expect(config.default_agent).toBe(getAgentListDisplayName("sisyphus"))
})
test("preserves custom default_agent names while trimming whitespace", async () => {
@@ -779,7 +779,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct override's reasoningEffort wins
const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("low")
})
@@ -820,7 +820,7 @@ describe("Prometheus direct override priority over category", () => {
// then - category's reasoningEffort is applied
const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("high")
})
@@ -862,7 +862,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct temperature wins over category
const agents = config.agent as Record<string, { temperature?: number }>
const pKey = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].temperature).toBe(0.1)
})
@@ -898,7 +898,7 @@ describe("Prometheus direct override priority over category", () => {
// #then - prompt_append is appended to base prompt, not overwriting it
const agents = config.agent as Record<string, { prompt?: string }>
const pKey = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].prompt).toContain("Prometheus")
expect(agents[pKey].prompt).toContain(customInstructions)
@@ -1290,17 +1290,17 @@ describe("command agent routing coherence", () => {
//#then
const agentConfig = config.agent as Record<string, unknown>
const commandConfig = config.command as Record<string, { agent?: string }>
expect(Object.keys(agentConfig)).toContain(getAgentDisplayName("atlas"))
expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"))
expect(Object.keys(agentConfig)).toContain(getAgentListDisplayName("atlas"))
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas"))
})
})
describe("per-agent todowrite/todoread deny when task_system enabled", () => {
const AGENTS_WITH_TODO_DENY = new Set([
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
getAgentListDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"),
getAgentListDisplayName("atlas"),
getAgentDisplayName("sisyphus-junior"),
])
@@ -1381,10 +1381,10 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined()
})
test("does not deny todowrite/todoread when task_system is undefined", async () => {
@@ -1420,8 +1420,8 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
})
})