fix(prompts): normalize agent names for continuation injections
This commit is contained in:
@@ -1804,7 +1804,7 @@ session_id: ses_untrusted_999
|
||||
// then - should call prompt for sisyphus
|
||||
expect(mockInput._promptMock).toHaveBeenCalled()
|
||||
const callArgs = mockInput._promptMock.mock.calls[0][0]
|
||||
expect(callArgs.body.agent).toBe("sisyphus")
|
||||
expect(callArgs.body.agent).toBe("Sisyphus (Ultraworker)")
|
||||
})
|
||||
|
||||
test("should preserve display-name agent in continuation prompt when boulder agent uses display form", async () => {
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
normalizeSDKResponse,
|
||||
resolveInheritedPromptTools,
|
||||
} from "../../shared"
|
||||
import { normalizeAgentForPrompt } from "../../shared/agent-display-names"
|
||||
|
||||
type MessageInfo = {
|
||||
agent?: string
|
||||
@@ -69,6 +70,7 @@ export async function injectContinuationPrompt(
|
||||
}
|
||||
|
||||
const inheritedTools = resolveInheritedPromptTools(sourceSessionID, tools)
|
||||
const promptAgent = normalizeAgentForPrompt(agent)
|
||||
|
||||
const launchModel = model
|
||||
? { providerID: model.providerID, modelID: model.modelID }
|
||||
@@ -78,7 +80,7 @@ export async function injectContinuationPrompt(
|
||||
await ctx.client.session.promptAsync({
|
||||
path: { id: options.sessionID },
|
||||
body: {
|
||||
...(agent !== undefined ? { agent } : {}),
|
||||
...(promptAgent ? { agent: promptAgent } : {}),
|
||||
...(launchModel ? { model: launchModel } : {}),
|
||||
...(launchVariant ? { variant: launchVariant } : {}),
|
||||
...(inheritedTools ? { tools: inheritedTools } : {}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { createOpencodeClient } from "@opencode-ai/sdk"
|
||||
import { normalizeAgentForPrompt } from "../../shared/agent-display-names"
|
||||
import type { MessageData, ResumeConfig } from "./types"
|
||||
import { createInternalAgentTextPart, resolveInheritedPromptTools } from "../../shared"
|
||||
|
||||
@@ -25,6 +26,8 @@ export function extractResumeConfig(userMessage: MessageData | undefined, sessio
|
||||
}
|
||||
|
||||
export async function resumeSession(client: Client, config: ResumeConfig): Promise<boolean> {
|
||||
const promptAgent = normalizeAgentForPrompt(config.agent)
|
||||
|
||||
try {
|
||||
const inheritedTools = resolveInheritedPromptTools(config.sessionID, config.tools)
|
||||
const launchModel = config.model
|
||||
@@ -36,7 +39,7 @@ export async function resumeSession(client: Client, config: ResumeConfig): Promi
|
||||
path: { id: config.sessionID },
|
||||
body: {
|
||||
parts: [createInternalAgentTextPart(RECOVERY_RESUME_TEXT)],
|
||||
agent: config.agent,
|
||||
...(promptAgent ? { agent: promptAgent } : {}),
|
||||
...(launchModel ? { model: launchModel } : {}),
|
||||
...(launchVariant ? { variant: launchVariant } : {}),
|
||||
...(inheritedTools ? { tools: inheritedTools } : {}),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { BackgroundManager } from "../../features/background-agent"
|
||||
import { getMainSessionID, getSessionAgent } from "../../features/claude-code-session-state"
|
||||
import { normalizeAgentForPrompt } from "../../shared/agent-display-names"
|
||||
import { log } from "../../shared/logger"
|
||||
import { createInternalAgentTextPart, resolveInheritedPromptTools } from "../../shared"
|
||||
import { isAbortError } from "../../shared/is-abort-error"
|
||||
@@ -83,7 +84,7 @@ async function resolveMainSessionTarget(
|
||||
log(`[${HOOK_NAME}] Failed to resolve main session agent`, { sessionID, error: String(error) })
|
||||
}
|
||||
|
||||
return { agent, model, tools: resolveInheritedPromptTools(sessionID, tools) }
|
||||
return { agent: normalizeAgentForPrompt(agent), model, tools: resolveInheritedPromptTools(sessionID, tools) }
|
||||
}
|
||||
|
||||
async function getThinkingSummary(ctx: BabysitterContext, sessionID: string): Promise<string | null> {
|
||||
|
||||
Reference in New Issue
Block a user