fix(agent-names): use HTTP-header-safe display names and config keys for API calls (#3138)

Display names with parentheses like 'Atlas (Plan Executor)' cause HTTP
header validation errors in x-opencode-agent-name. This was blocking
Atlas/Prometheus from working via /start-work and auto-retry.

Changes:
- Display names: parens -> dashes ('Atlas - Plan Executor')
- Hooks (start-work, no-hephaestus-non-gpt, no-sisyphus-gpt): use
  config keys ('atlas', 'sisyphus', 'hephaestus') for agent API fields
- auto-retry: use config key instead of display name for promptAsync
- agent-override-protection: handle dash-suffix normalization
- Updated all test expectations to match new format

Closes #3138
This commit is contained in:
YeonGyu-Kim
2026-04-07 10:08:04 +09:00
parent ebfd4a41ee
commit f8c626086e
26 changed files with 146 additions and 144 deletions
+16 -16
View File
@@ -92,12 +92,12 @@ describe("Agent Config Integration", () => {
const displayNames = agents.map((agent) => getAgentDisplayName(agent))
// then - display names are correct
expect(displayNames).toContain("Sisyphus (Ultraworker)")
expect(displayNames).toContain("Hephaestus (Deep Agent)")
expect(displayNames).toContain("Prometheus (Plan Builder)")
expect(displayNames).toContain("Atlas (Plan Executor)")
expect(displayNames).toContain("Metis (Plan Consultant)")
expect(displayNames).toContain("Momus (Plan Critic)")
expect(displayNames).toContain("Sisyphus - Ultraworker")
expect(displayNames).toContain("Hephaestus - Deep Agent")
expect(displayNames).toContain("Prometheus - Plan Builder")
expect(displayNames).toContain("Atlas - Plan Executor")
expect(displayNames).toContain("Metis - Plan Consultant")
expect(displayNames).toContain("Momus - Plan Critic")
expect(displayNames).toContain("oracle")
expect(displayNames).toContain("librarian")
expect(displayNames).toContain("explore")
@@ -112,12 +112,12 @@ describe("Agent Config Integration", () => {
const displayNames = keys.map((key) => getAgentDisplayName(key))
// then - correct display names are returned
expect(displayNames[0]).toBe("Sisyphus (Ultraworker)")
expect(displayNames[1]).toBe("Atlas (Plan Executor)")
expect(displayNames[2]).toBe("Sisyphus (Ultraworker)")
expect(displayNames[3]).toBe("Atlas (Plan Executor)")
expect(displayNames[4]).toBe("Prometheus (Plan Builder)")
expect(displayNames[5]).toBe("Prometheus (Plan Builder)")
expect(displayNames[0]).toBe("Sisyphus - Ultraworker")
expect(displayNames[1]).toBe("Atlas - Plan Executor")
expect(displayNames[2]).toBe("Sisyphus - Ultraworker")
expect(displayNames[3]).toBe("Atlas - Plan Executor")
expect(displayNames[4]).toBe("Prometheus - Plan Builder")
expect(displayNames[5]).toBe("Prometheus - Plan Builder")
})
test("returns original key for unknown agents", () => {
@@ -189,8 +189,8 @@ describe("Agent Config Integration", () => {
const prometheusDisplay = getAgentDisplayName("prometheus")
// then - display names are correct
expect(sisyphusDisplay).toBe("Sisyphus (Ultraworker)")
expect(prometheusDisplay).toBe("Prometheus (Plan Builder)")
expect(sisyphusDisplay).toBe("Sisyphus - Ultraworker")
expect(prometheusDisplay).toBe("Prometheus - Plan Builder")
// then - config values are preserved
expect(result.migrated.sisyphus).toEqual({ model: "anthropic/claude-opus-4-6", temperature: 0.1 })
@@ -218,8 +218,8 @@ describe("Agent Config Integration", () => {
const atlasDisplay = getAgentDisplayName("atlas")
// then - display names are correct
expect(sisyphusDisplay).toBe("Sisyphus (Ultraworker)")
expect(atlasDisplay).toBe("Atlas (Plan Executor)")
expect(sisyphusDisplay).toBe("Sisyphus - Ultraworker")
expect(atlasDisplay).toBe("Atlas - Plan Executor")
})
})
})
+37 -37
View File
@@ -9,8 +9,8 @@ describe("getAgentDisplayName", () => {
// when getAgentDisplayName called
const result = getAgentDisplayName(configKey)
// then returns "Sisyphus (Ultraworker)"
expect(result).toBe("Sisyphus (Ultraworker)")
// then returns "Sisyphus - Ultraworker"
expect(result).toBe("Sisyphus - Ultraworker")
})
it("returns display name for uppercase config key (old format - case-insensitive)", () => {
@@ -20,8 +20,8 @@ describe("getAgentDisplayName", () => {
// when getAgentDisplayName called
const result = getAgentDisplayName(configKey)
// then returns "Sisyphus (Ultraworker)" (case-insensitive lookup)
expect(result).toBe("Sisyphus (Ultraworker)")
// then returns "Sisyphus - Ultraworker" (case-insensitive lookup)
expect(result).toBe("Sisyphus - Ultraworker")
})
it("returns original key for unknown agents (fallback)", () => {
@@ -42,8 +42,8 @@ describe("getAgentDisplayName", () => {
// when getAgentDisplayName called
const result = getAgentDisplayName(configKey)
// then returns "Atlas (Plan Executor)"
expect(result).toBe("Atlas (Plan Executor)")
// then returns "Atlas - Plan Executor"
expect(result).toBe("Atlas - Plan Executor")
})
it("returns display name for prometheus", () => {
@@ -53,8 +53,8 @@ describe("getAgentDisplayName", () => {
// when getAgentDisplayName called
const result = getAgentDisplayName(configKey)
// then returns "Prometheus (Plan Builder)"
expect(result).toBe("Prometheus (Plan Builder)")
// then returns "Prometheus - Plan Builder"
expect(result).toBe("Prometheus - Plan Builder")
})
it("returns display name for sisyphus-junior", () => {
@@ -75,8 +75,8 @@ describe("getAgentDisplayName", () => {
// when getAgentDisplayName called
const result = getAgentDisplayName(configKey)
// then returns "Metis (Plan Consultant)"
expect(result).toBe("Metis (Plan Consultant)")
// then returns "Metis - Plan Consultant"
expect(result).toBe("Metis - Plan Consultant")
})
it("returns display name for momus", () => {
@@ -86,8 +86,8 @@ describe("getAgentDisplayName", () => {
// when getAgentDisplayName called
const result = getAgentDisplayName(configKey)
// then returns "Momus (Plan Critic)"
expect(result).toBe("Momus (Plan Critic)")
// then returns "Momus - Plan Critic"
expect(result).toBe("Momus - Plan Critic")
})
it("returns display name for oracle", () => {
@@ -137,17 +137,17 @@ describe("getAgentDisplayName", () => {
describe("getAgentConfigKey", () => {
it("resolves display name to config key", () => {
// given display name "Sisyphus (Ultraworker)"
// given display name "Sisyphus - Ultraworker"
// when getAgentConfigKey called
// then returns "sisyphus"
expect(getAgentConfigKey("Sisyphus (Ultraworker)")).toBe("sisyphus")
expect(getAgentConfigKey("Sisyphus - Ultraworker")).toBe("sisyphus")
})
it("resolves display name case-insensitively", () => {
// given display name in different case
// when getAgentConfigKey called
// then returns "atlas"
expect(getAgentConfigKey("atlas (plan executor)")).toBe("atlas")
expect(getAgentConfigKey("atlas - plan executor")).toBe("atlas")
})
it("passes through lowercase config keys unchanged", () => {
@@ -167,11 +167,11 @@ describe("getAgentConfigKey", () => {
it("resolves all core agent display names", () => {
// given all core display names
// when/then each resolves to its config key
expect(getAgentConfigKey("Hephaestus (Deep Agent)")).toBe("hephaestus")
expect(getAgentConfigKey("Prometheus (Plan Builder)")).toBe("prometheus")
expect(getAgentConfigKey("Atlas (Plan Executor)")).toBe("atlas")
expect(getAgentConfigKey("Metis (Plan Consultant)")).toBe("metis")
expect(getAgentConfigKey("Momus (Plan Critic)")).toBe("momus")
expect(getAgentConfigKey("Hephaestus - Deep Agent")).toBe("hephaestus")
expect(getAgentConfigKey("Prometheus - Plan Builder")).toBe("prometheus")
expect(getAgentConfigKey("Atlas - Plan Executor")).toBe("atlas")
expect(getAgentConfigKey("Metis - Plan Consultant")).toBe("metis")
expect(getAgentConfigKey("Momus - Plan Critic")).toBe("momus")
expect(getAgentConfigKey("Sisyphus-Junior")).toBe("sisyphus-junior")
})
@@ -182,10 +182,10 @@ describe("getAgentConfigKey", () => {
describe("getAgentListDisplayName", () => {
it("applies invisible stable-sort prefixes to the core agent list", () => {
expect(getAgentListDisplayName("sisyphus")).toBe("\u200BSisyphus (Ultraworker)")
expect(getAgentListDisplayName("hephaestus")).toBe("\u200B\u200BHephaestus (Deep Agent)")
expect(getAgentListDisplayName("prometheus")).toBe("\u200B\u200B\u200BPrometheus (Plan Builder)")
expect(getAgentListDisplayName("atlas")).toBe("\u200B\u200B\u200B\u200BAtlas (Plan Executor)")
expect(getAgentListDisplayName("sisyphus")).toBe("\u200BSisyphus - Ultraworker")
expect(getAgentListDisplayName("hephaestus")).toBe("\u200B\u200BHephaestus - Deep Agent")
expect(getAgentListDisplayName("prometheus")).toBe("\u200B\u200B\u200BPrometheus - Plan Builder")
expect(getAgentListDisplayName("atlas")).toBe("\u200B\u200B\u200B\u200BAtlas - Plan Executor")
})
it("keeps non-core agents unprefixed for list display", () => {
@@ -195,16 +195,16 @@ describe("getAgentListDisplayName", () => {
describe("normalizeAgentForPrompt", () => {
it("strips core UI ordering prefixes back to canonical display names", () => {
expect(normalizeAgentForPrompt(getAgentListDisplayName("sisyphus"))).toBe("Sisyphus (Ultraworker)")
expect(normalizeAgentForPrompt(getAgentListDisplayName("hephaestus"))).toBe("Hephaestus (Deep Agent)")
expect(normalizeAgentForPrompt(getAgentListDisplayName("prometheus"))).toBe("Prometheus (Plan Builder)")
expect(normalizeAgentForPrompt(getAgentListDisplayName("atlas"))).toBe("Atlas (Plan Executor)")
expect(normalizeAgentForPrompt(getAgentListDisplayName("sisyphus"))).toBe("Sisyphus - Ultraworker")
expect(normalizeAgentForPrompt(getAgentListDisplayName("hephaestus"))).toBe("Hephaestus - Deep Agent")
expect(normalizeAgentForPrompt(getAgentListDisplayName("prometheus"))).toBe("Prometheus - Plan Builder")
expect(normalizeAgentForPrompt(getAgentListDisplayName("atlas"))).toBe("Atlas - Plan Executor")
})
})
describe("normalizeAgentForPromptKey", () => {
it("converts built-in display names to config keys", () => {
expect(normalizeAgentForPromptKey("Sisyphus (Ultraworker)")).toBe("sisyphus")
expect(normalizeAgentForPromptKey("Sisyphus - Ultraworker")).toBe("sisyphus")
})
it("preserves custom agents", () => {
@@ -216,15 +216,15 @@ describe("AGENT_DISPLAY_NAMES", () => {
it("contains all expected agent mappings", () => {
// given expected mappings
const expectedMappings = {
sisyphus: "Sisyphus (Ultraworker)",
hephaestus: "Hephaestus (Deep Agent)",
prometheus: "Prometheus (Plan Builder)",
atlas: "Atlas (Plan Executor)",
sisyphus: "Sisyphus - Ultraworker",
hephaestus: "Hephaestus - Deep Agent",
prometheus: "Prometheus - Plan Builder",
atlas: "Atlas - Plan Executor",
"sisyphus-junior": "Sisyphus-Junior",
metis: "Metis (Plan Consultant)",
momus: "Momus (Plan Critic)",
athena: "Athena (Council)",
"athena-junior": "Athena-Junior (Council)",
metis: "Metis - Plan Consultant",
momus: "Momus - Plan Critic",
athena: "Athena - Council",
"athena-junior": "Athena-Junior - Council",
oracle: "oracle",
librarian: "librarian",
explore: "explore",
+8 -8
View File
@@ -4,15 +4,15 @@
* Display names include suffixes for UI/logs (e.g., "Sisyphus (Ultraworker)").
*/
export const AGENT_DISPLAY_NAMES: Record<string, string> = {
sisyphus: "Sisyphus (Ultraworker)",
hephaestus: "Hephaestus (Deep Agent)",
prometheus: "Prometheus (Plan Builder)",
atlas: "Atlas (Plan Executor)",
sisyphus: "Sisyphus - Ultraworker",
hephaestus: "Hephaestus - Deep Agent",
prometheus: "Prometheus - Plan Builder",
atlas: "Atlas - Plan Executor",
"sisyphus-junior": "Sisyphus-Junior",
metis: "Metis (Plan Consultant)",
momus: "Momus (Plan Critic)",
athena: "Athena (Council)",
"athena-junior": "Athena-Junior (Council)",
metis: "Metis - Plan Consultant",
momus: "Momus - Plan Critic",
athena: "Athena - Council",
"athena-junior": "Athena-Junior - Council",
oracle: "oracle",
librarian: "librarian",
explore: "explore",