Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,45 @@ describe("injectContinuation", () => {
})

// then
expect(capturedAgent).toBe("Sisyphus - Ultraworker")
expect(capturedAgent).toBe("\u200BSisyphus - Ultraworker")
})

test("falls back to the runtime display name when only config-key agent info is available", 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_fallback",
resolvedInfo: {
agent: "sisyphus",
model: { providerID: "anthropic", modelID: "claude-sonnet-4-20250514" },
},
sessionStateStore: sessionStateStore as never,
})

// then
expect(capturedAgent).toBe("\u200BSisyphus - Ultraworker")
})

test("inherits tools from resolved message info when reinjecting", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { log } from "../../shared/logger"
import { isSqliteBackend } from "../../shared/opencode-storage-detection"
import {
getAgentConfigKey,
getAgentRuntimeName,
normalizeAgentForPromptKey,
} from "../../shared/agent-display-names"

Expand Down Expand Up @@ -130,7 +131,13 @@ export async function injectContinuation(args: {
}

const promptAgent = normalizeAgentForPromptKey(agentName)
const launchAgent = resolveRegisteredAgentName(agentName)
const configKey = promptAgent ?? (agentName ? getAgentConfigKey(agentName) : undefined)
const fallbackLaunchAgent = configKey ? getAgentRuntimeName(configKey) : undefined
const resolvedLaunchAgent = resolveRegisteredAgentName(agentName)
const launchAgent =
resolvedLaunchAgent && resolvedLaunchAgent !== agentName
? resolvedLaunchAgent
: fallbackLaunchAgent ?? agentName ?? promptAgent

if (promptAgent && skipAgents.some(s => getAgentConfigKey(s) === getAgentConfigKey(promptAgent))) {
log(`[${HOOK_NAME}] Skipped: agent in skipAgents list`, { sessionID, agent: agentName })
Expand Down
Loading