fix(anthropic): include Anthropic in tool call ID sanitization#13976
Open
omair445 wants to merge 1 commit intoopenclaw:mainfrom
Open
fix(anthropic): include Anthropic in tool call ID sanitization#13976omair445 wants to merge 1 commit intoopenclaw:mainfrom
omair445 wants to merge 1 commit intoopenclaw:mainfrom
Conversation
TWFBusiness
added a commit
to TWFBusiness/openclaw-tw
that referenced
this pull request
Feb 11, 2026
…pstream fixes - Remove Discord, Telegram, Slack, Signal, iMessage, BlueBubbles extensions - Remove @buape/carbon, grammy, and other gateway-specific dependencies - Add session-based login system (cookie auth, rate limiting) - Add type stubs for optional deps (baileys, ciao, qrcode-terminal) - Apply upstream PRs: XSS fix (openclaw#13952), orphan tool_results (openclaw#13974), Anthropic tool ID sanitization (openclaw#13976), BM25 score fix (openclaw#14005), redaction fix (openclaw#14006), subagent timeout (openclaw#13996), context window guard (openclaw#13986), model default reset (openclaw#13993), cache token accounting (openclaw#13853) - Fix all TypeScript compilation errors from channel removal Co-Authored-By: Claude Opus 4.6 <[email protected]>
7a321b8 to
37807b2
Compare
bfc1ccb to
f92900f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Anthropic API rejects tool_use IDs that contain underscores (e.g.
toolu_01XYZ), requiring IDs to match^[a-zA-Z0-9-]+$. However,sanitizeToolCallIdsonly covers Google and Mistral — Anthropic is missing. This causes persistent API errors when tool call IDs from other providers contain invalid characters.Fixes #13799
Root Cause
In
transcript-policy.ts:The gateway logs "Tool calls will be sanitized on retry" but since
sanitizeToolCallIdsis false for Anthropic, the retry uses unsanitized IDs too — causing an infinite loop.Behavior Changes
sanitizeToolCallIds: truewithtoolCallIdMode: "strict"Tests
9 new tests in
transcript-policy.test.ts:Covers sanitizeToolCallIds and toolCallIdMode for Anthropic, Google, Mistral, and OpenAI.
lobster-biscuit
Sign-Off
Greptile Overview
Greptile Summary
Added Anthropic to the list of providers that require tool call ID sanitization. The Anthropic API requires tool call IDs to match
^[a-zA-Z0-9-]+$(no underscores), butsanitizeToolCallIdsonly covered Google and Mistral, causing retry loops when tool call IDs from other providers contained invalid characters. The one-line fix ontranscript-policy.ts:98now includesisAnthropicin the condition, and comprehensive tests verify the behavior for all major providers (Anthropic via bothproviderandmodelApi, Google, Mistral, and OpenAI).Confidence Score: 5/5