fix: permanently resolve agent name duplication yo-yo bug

This commit is contained in:
Sami Jawhar
2026-03-29 04:02:13 +00:00
parent 3dc11ea620
commit 4314a3e482
9 changed files with 180 additions and 16 deletions
+3
View File
@@ -187,10 +187,13 @@ describe("AGENT_DISPLAY_NAMES", () => {
"sisyphus-junior": "Sisyphus-Junior",
metis: "Metis (Plan Consultant)",
momus: "Momus (Plan Critic)",
athena: "Athena (Council)",
"athena-junior": "Athena-Junior (Council)",
oracle: "oracle",
librarian: "librarian",
explore: "explore",
"multimodal-looker": "multimodal-looker",
"council-member": "council-member",
}
// when checking the constant
+32 -1
View File
@@ -11,10 +11,13 @@ export const AGENT_DISPLAY_NAMES: Record<string, string> = {
"sisyphus-junior": "Sisyphus-Junior",
metis: "Metis (Plan Consultant)",
momus: "Momus (Plan Critic)",
athena: "Athena (Council)",
"athena-junior": "Athena-Junior (Council)",
oracle: "oracle",
librarian: "librarian",
explore: "explore",
"multimodal-looker": "multimodal-looker",
"council-member": "council-member",
}
/**
@@ -51,4 +54,32 @@ export function getAgentConfigKey(agentName: string): string {
if (reversed !== undefined) return reversed
if (AGENT_DISPLAY_NAMES[lower] !== undefined) return lower
return lower
}
}
/**
* Normalize an agent name for prompt APIs.
* - Known display names -> canonical display names
* - Known config keys (any case) -> canonical display names
* - Unknown/custom names -> preserved as-is (trimmed)
*/
export function normalizeAgentForPrompt(agentName: string | undefined): string | undefined {
if (typeof agentName !== "string") {
return undefined
}
const trimmed = agentName.trim()
if (!trimmed) {
return undefined
}
const lower = trimmed.toLowerCase()
const reversed = REVERSE_DISPLAY_NAMES[lower]
if (reversed !== undefined) {
return AGENT_DISPLAY_NAMES[reversed] ?? trimmed
}
if (AGENT_DISPLAY_NAMES[lower] !== undefined) {
return AGENT_DISPLAY_NAMES[lower]
}
return trimmed
}