mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +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>
(cherry picked from commit 97b065aa6e)
This commit is contained in:
committed by
Peter Steinberger
parent
424ba72cad
commit
252079f001
@@ -108,7 +108,10 @@ export function resolveTranscriptPolicy(params: {
|
||||
: sanitizeToolCallIds
|
||||
? "strict"
|
||||
: 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 =
|
||||
isOpenRouterGemini || isGoogle ? { allowBase64Only: true, includeCamelCase: true } : undefined;
|
||||
|
||||
@@ -116,7 +119,7 @@ export function resolveTranscriptPolicy(params: {
|
||||
sanitizeMode: isOpenAi ? "images-only" : needsNonImageSanitize ? "full" : "images-only",
|
||||
sanitizeToolCallIds: !isOpenAi && sanitizeToolCallIds,
|
||||
toolCallIdMode,
|
||||
repairToolUseResultPairing: !isOpenAi && repairToolUseResultPairing,
|
||||
repairToolUseResultPairing,
|
||||
preserveSignatures: false,
|
||||
sanitizeThoughtSignatures: isOpenAi ? undefined : sanitizeThoughtSignatures,
|
||||
sanitizeThinkingSignatures: false,
|
||||
|
||||
Reference in New Issue
Block a user