fix: permanently resolve agent name duplication yo-yo bug
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user