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
@@ -5,6 +5,44 @@ import { injectContinuation } from "./continuation-injection"
import { OMO_INTERNAL_INITIATOR_MARKER } from "../../shared/internal-initiator-marker"
describe("injectContinuation", () => {
test("normalizes built-in display names to config keys before promptAsync", async () => {
// given
let capturedAgent: string | undefined
const ctx = {
directory: "/tmp/test",
client: {
session: {
todo: async () => ({ data: [{ id: "1", content: "todo", status: "pending", priority: "high" }] }),
promptAsync: async (input: {
body: {
agent?: string
}
}) => {
capturedAgent = input.body.agent
return {}
},
},
},
}
const sessionStateStore = {
getExistingState: () => ({ inFlight: false, lastInjectedAt: 0, consecutiveFailures: 0 }),
}
// when
await injectContinuation({
ctx: ctx as never,
sessionID: "ses_display_name_agent",
resolvedInfo: {
agent: "Sisyphus (Ultraworker)",
model: { providerID: "anthropic", modelID: "claude-sonnet-4-20250514" },
},
sessionStateStore: sessionStateStore as never,
})
// then
expect(capturedAgent).toBe("sisyphus")
})
test("inherits tools from resolved message info when reinjecting", async () => {
// given
let capturedTools: Record<string, boolean> | undefined