mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:28:38 +00:00
fix(agents): repair orphaned tool results for OpenAI after history truncation
repairToolUseResultPairing was gated behind !isOpenAi, skipping orphaned tool_result cleanup for OpenAI providers. When limitHistoryTurns truncated conversation history, tool_result messages whose matching tool_call was before the truncation point survived and were sent as function_call_output items with stale call_id references. OpenAI rejects these with: "No tool call found for function call output with call_id ..." Enable the repair universally — all providers need it after truncation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -103,7 +103,10 @@ export function resolveTranscriptPolicy(params: {
|
|||||||
: sanitizeToolCallIds
|
: sanitizeToolCallIds
|
||||||
? "strict"
|
? "strict"
|
||||||
: undefined;
|
: undefined;
|
||||||
const repairToolUseResultPairing = isGoogle || isAnthropic;
|
// All providers need orphaned tool_result repair after history truncation.
|
||||||
|
// OpenAI rejects function_call_output items whose call_id has no matching
|
||||||
|
// function_call in the conversation, so the repair must run universally.
|
||||||
|
const repairToolUseResultPairing = true;
|
||||||
const sanitizeThoughtSignatures =
|
const sanitizeThoughtSignatures =
|
||||||
isOpenRouterGemini || isGoogle ? { allowBase64Only: true, includeCamelCase: true } : undefined;
|
isOpenRouterGemini || isGoogle ? { allowBase64Only: true, includeCamelCase: true } : undefined;
|
||||||
|
|
||||||
@@ -111,7 +114,7 @@ export function resolveTranscriptPolicy(params: {
|
|||||||
sanitizeMode: isOpenAi ? "images-only" : needsNonImageSanitize ? "full" : "images-only",
|
sanitizeMode: isOpenAi ? "images-only" : needsNonImageSanitize ? "full" : "images-only",
|
||||||
sanitizeToolCallIds: !isOpenAi && sanitizeToolCallIds,
|
sanitizeToolCallIds: !isOpenAi && sanitizeToolCallIds,
|
||||||
toolCallIdMode,
|
toolCallIdMode,
|
||||||
repairToolUseResultPairing: !isOpenAi && repairToolUseResultPairing,
|
repairToolUseResultPairing,
|
||||||
preserveSignatures: false,
|
preserveSignatures: false,
|
||||||
sanitizeThoughtSignatures: isOpenAi ? undefined : sanitizeThoughtSignatures,
|
sanitizeThoughtSignatures: isOpenAi ? undefined : sanitizeThoughtSignatures,
|
||||||
sanitizeThinkingSignatures: false,
|
sanitizeThinkingSignatures: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user