fix: unify agent display names and strip invisible sort prefixes

- Replace getAgentRuntimeName with getAgentDisplayName for consistency
- Add stripAgentListSortPrefix helper to normalize agent names
- Strip sort prefixes in subagent-resolver and sync-executor
- Backfill canonical names for core agents when builtin configs omit name
- Update tests to match new behavior
This commit is contained in:
YeonGyu-Kim
2026-04-11 14:53:01 +09:00
parent c30b058b7e
commit 9f135af41c
9 changed files with 180 additions and 37 deletions
+64 -7
View File
@@ -315,6 +315,63 @@ describe("Plan agent demote behavior", () => {
])
})
test("backfills core agent runtime names when builtin configs omit name", async () => {
// #given
const createBuiltinAgentsMock = agents.createBuiltinAgents as unknown as {
mockResolvedValue: (value: Record<string, unknown>) => void
}
createBuiltinAgentsMock.mockResolvedValue({
sisyphus: { prompt: "test", mode: "primary" },
hephaestus: { prompt: "test", mode: "primary" },
oracle: { prompt: "test", mode: "subagent" },
atlas: { prompt: "test", mode: "primary" },
})
const pluginConfig = createPluginConfig({
sisyphus_agent: {
planner_enabled: true,
},
})
const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-6",
agent: {},
}
const handler = createConfigHandler({
ctx: { directory: "/tmp" },
pluginConfig,
modelCacheState: {
anthropicContext1MEnabled: false,
modelContextLimitsCache: new Map(),
},
})
// #when
await handler(config)
// #then
const emittedCoreEntries = Object.entries(
config.agent as Record<string, { name?: string }>,
).slice(0, 4)
expect(emittedCoreEntries).toEqual([
[
getAgentDisplayName("sisyphus"),
expect.objectContaining({ name: getAgentDisplayName("sisyphus") }),
],
[
getAgentDisplayName("hephaestus"),
expect.objectContaining({ name: getAgentDisplayName("hephaestus") }),
],
[
getAgentDisplayName("prometheus"),
expect.objectContaining({ name: getAgentDisplayName("prometheus") }),
],
[
getAgentDisplayName("atlas"),
expect.objectContaining({ name: getAgentDisplayName("atlas") }),
],
])
})
test("plan agent should be demoted to subagent without inheriting prometheus prompt", async () => {
// #given
const pluginConfig = createPluginConfig({
@@ -479,7 +536,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus"))
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
})
test("canonicalizes configured default_agent when key uses mixed case", async () => {
@@ -503,7 +560,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus"))
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
})
test("canonicalizes configured default_agent key to display name", async () => {
@@ -527,7 +584,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// #then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus"))
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
})
test("preserves existing display-name default_agent", async () => {
@@ -575,10 +632,10 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// #then
expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus"))
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
})
test("uses runtime default_agent name so OpenCode matches the emitted ordered agent names", async () => {
test("uses canonical default_agent display name so OpenCode lookups match emitted agent keys", async () => {
// given
const pluginConfig = createPluginConfig({})
const config: Record<string, unknown> = {
@@ -599,7 +656,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus"))
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
})
test("sets default_agent to sisyphus when configured default_agent is empty after trim", async () => {
@@ -623,7 +680,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus"))
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
})
test("preserves custom default_agent names while trimming whitespace", async () => {