diff --git a/src/agents/command/attempt-execution.helpers.ts b/src/agents/command/attempt-execution.helpers.ts index 71f5c7e3bf12..21f8374d7965 100644 --- a/src/agents/command/attempt-execution.helpers.ts +++ b/src/agents/command/attempt-execution.helpers.ts @@ -12,7 +12,11 @@ import { startsWithSilentToken, stripLeadingSilentToken, } from "../../auto-reply/tokens.js"; -import { resolveToolUseId, type ToolContentBlock } from "../../chat/tool-content.js"; +import { + isToolCallBlock, + resolveToolUseId, + type ToolContentBlock, +} from "../../chat/tool-content.js"; import { type ClaudeCliFallbackSeed, readClaudeCliFallbackSeed, @@ -320,7 +324,7 @@ function extractFallbackTurnText(message: FallbackTurnLikeMessage): string { // Tool calls: render as a compact "(tool: name)" hint so the fallback // model sees the conversation flow without the full tool argument blob, // which is rarely useful out of context and chews through char budget. - if (rec.type === "tool_use" && typeof rec.name === "string") { + if (isToolCallBlock(rec) && typeof rec.name === "string") { parts.push(`(tool call: ${rec.name})`); continue; } diff --git a/src/agents/command/attempt-execution.test.ts b/src/agents/command/attempt-execution.test.ts index 7adf2f08dc43..efd68b6b625e 100644 --- a/src/agents/command/attempt-execution.test.ts +++ b/src/agents/command/attempt-execution.test.ts @@ -166,7 +166,7 @@ describe("formatClaudeCliFallbackPrelude", () => { role: "assistant", content: [ { type: "text", text: "Earlier assistant reply" }, - { type: "tool_use", name: "Bash" }, + { type: "toolcall", name: "Bash" }, ], }, { @@ -269,7 +269,10 @@ describe("buildClaudeCliFallbackContextPrelude", () => { message: { role: "assistant", model: "claude-sonnet-4-6", - content: [{ type: "text", text: "prior answer about blue-green" }], + content: [ + { type: "text", text: "prior answer about blue-green" }, + { type: "tool_use", id: "toolu_1", name: "Bash", input: { command: "pwd" } }, + ], }, }, ]; @@ -285,6 +288,7 @@ describe("buildClaudeCliFallbackContextPrelude", () => { expect(prelude).toContain("## Prior session context (from claude-cli)"); expect(prelude).toContain("user: prior question about deploys"); expect(prelude).toContain("assistant: prior answer about blue-green"); + expect(prelude).toContain("(tool call: Bash)"); } finally { await fs.rm(tmpHome, { recursive: true, force: true }); }