fix(todo): normalize continuation agent names
This commit is contained in:
@@ -45,4 +45,38 @@ describe("injectContinuation agent names", () => {
|
||||
// then
|
||||
expect(capturedAgent).toBe("Hephaestus - Deep Agent")
|
||||
})
|
||||
|
||||
test("#given resolved agent is an invisible-prefixed config key #when continuation is injected #then promptAsync receives the display name", async () => {
|
||||
// given
|
||||
let capturedAgent: string | undefined
|
||||
const ctx = unsafeTestValue<Parameters<typeof injectContinuation>[0]["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 = unsafeTestValue<Parameters<typeof injectContinuation>[0]["sessionStateStore"]>({
|
||||
getExistingState: () => ({ inFlight: false, lastInjectedAt: 0, consecutiveFailures: 0 }),
|
||||
})
|
||||
|
||||
// when
|
||||
await injectContinuation({
|
||||
ctx,
|
||||
sessionID: "ses_invisible_lowercase_builtin_agent",
|
||||
resolvedInfo: {
|
||||
agent: "\u200Bhephaestus",
|
||||
model: { providerID: "openai", modelID: "gpt-5.5" },
|
||||
},
|
||||
sessionStateStore,
|
||||
})
|
||||
|
||||
// then
|
||||
expect(capturedAgent).toBe("Hephaestus - Deep Agent")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ import { log } from "../../shared/logger"
|
||||
import { isSqliteBackend } from "../../shared/opencode-storage-detection"
|
||||
import {
|
||||
getAgentConfigKey,
|
||||
normalizeAgentForPromptKey,
|
||||
normalizeAgentForPrompt,
|
||||
stripAgentListSortPrefix,
|
||||
} from "../../shared/agent-display-names"
|
||||
import { dispatchInternalPrompt, isInternalPromptDispatchAccepted } from "../shared/prompt-async-gate"
|
||||
@@ -132,7 +132,11 @@ export async function injectContinuation(args: {
|
||||
tools = tools ?? previousMessage?.tools
|
||||
}
|
||||
|
||||
const promptAgent = resolveRegisteredAgentName(agentName) ?? normalizeAgentForPromptKey(agentName)
|
||||
const agentConfigKey = getAgentConfigKey(agentName ?? "")
|
||||
const registeredAgentName = resolveRegisteredAgentName(agentName)
|
||||
const promptAgent = registeredAgentName !== undefined && registeredAgentName !== agentConfigKey
|
||||
? registeredAgentName
|
||||
: normalizeAgentForPrompt(agentName)
|
||||
const launchAgent = promptAgent ? stripAgentListSortPrefix(promptAgent).trim() || undefined : undefined
|
||||
|
||||
if (promptAgent && skipAgents.some(s => getAgentConfigKey(s) === getAgentConfigKey(promptAgent))) {
|
||||
|
||||
Reference in New Issue
Block a user