Skip to content

fix(ai): trace caller.toolId dependencies in pruneMessages#12610

Open
giulio-leone wants to merge 2 commits intovercel:mainfrom
giulio-leone:fix/issue-12504-prune-messages-caller-refs
Open

fix(ai): trace caller.toolId dependencies in pruneMessages#12610
giulio-leone wants to merge 2 commits intovercel:mainfrom
giulio-leone:fix/issue-12504-prune-messages-caller-refs

Conversation

@giulio-leone
Copy link

Fixes #12504

Problem

pruneMessages + convertToModelMessages orphan Anthropic caller references, causing 'source tool not found' API error with code_execution programmatic tool calling.

Root Cause

pruneMessages builds keptToolCallIds but doesn't follow providerOptions.anthropic.caller.toolId references. When a tool-call references a server_tool_use via caller.toolId, the server_tool_use can be pruned while the referencing tool-call is kept.

Fix

Added transitive caller.toolId dependency tracing in pruneMessages:

  • Builds callerDeps map from toolCallId → caller.toolId
  • Iteratively resolves until fixed-point (handles transitive chains)
  • Terminates correctly even with circular references

giulio-leone and others added 2 commits February 14, 2026 01:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant