fix(todo-continuation): normalize agent name to config key before promptAsync (#3149)

The todo-continuation-enforcer was passing raw agent names (which could be
display names like 'Sisyphus (Ultraworker)') to promptAsync. These names
contain spaces/parentheses that violate HTTP header specs, causing the
x-opencode-agent-name header validation to fail with 'unknown error' toast.

Added normalizeAgentForPromptKey() that converts display names to config keys
(e.g., 'Sisyphus (Ultraworker)' -> 'sisyphus') before API calls.

TDD: Added regression test that verifies config key is sent to promptAsync.
This commit is contained in:
YeonGyu-Kim
2026-04-06 11:44:11 +09:00
parent 98e6659af5
commit de6c74bfb4
4 changed files with 81 additions and 6 deletions
+22
View File
@@ -98,3 +98,25 @@ export function normalizeAgentForPrompt(agentName: string | undefined): string |
return trimmed
}
export function normalizeAgentForPromptKey(agentName: string | undefined): string | undefined {
if (typeof agentName !== "string") {
return undefined
}
const trimmed = stripAgentListSortPrefix(agentName.trim())
if (!trimmed) {
return undefined
}
const lower = trimmed.toLowerCase()
const reversed = REVERSE_DISPLAY_NAMES[lower]
if (reversed !== undefined) {
return reversed
}
if (AGENT_DISPLAY_NAMES[lower] !== undefined) {
return lower
}
return trimmed
}