mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(agents): preserve fallback tool-call hints (#99851)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user