Repository navigation
[Fix] LiteLLM + Gemini: tool call id truncation corrupts thought_signature - #2119
PierrunoYT wants to merge 1 commit into
Conversation
…ture LiteLLM encodes a Gemini thought signature into the tool call id after __thought__. sanitizeOpenAiCallId cut such ids to 64 characters and appended a hash, so Gemini received a corrupted signature (400 Base64 decoding failed). Only character-sanitize ids containing the marker. Fixes Zoo-Code-Org#2064 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Required CI passed. Waiting for automated review of the latest commit. If automated review does not start, a maintainer must restart it. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Fixes #2064
Problem
LiteLLM carries a Gemini thought signature inside the tool call id (
call_xxx__thought__<signature>). The LiteLLM handler ran every tool call id throughsanitizeOpenAiCallId, which truncates to 64 characters and appends_+ an 8-hex hash. For these ids that cut the signature and added the hash, so Gemini rejected the next request with400 ... thought_signature ... Base64 decoding failed.Fix
New
sanitizeLiteLlmCallId(utils/tool-id.ts): ids containing__thought__are only character-sanitized (never truncated); all other ids keep the existing OpenAI 64-character treatment.LiteLLMHandleruses it for both the standard and the R1-format message conversion.Notes
Tests
tool-id.spec.ts(intact long id, invalid-character sanitizing, other long ids still truncated, short ids unchanged) and alite-llm.spec.tstest that the assistanttool_calls[].idand the tool messagetool_call_idreach the request unchanged.check-typespasses.🤖 Generated with Claude Code