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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user