Repository navigation
Conversation
…onses truncateFunctionResponsePart cut the base64 inside __binary_injection__, so read_file on audio/video over ~48 KB sent undecodable inlineData and the API returned 400 "Base64 decoding failed". Older binary turns are already evicted by collapseOlderFunctionResponses. Fixes google-gemini#30240
|
📊 PR Size: size/S
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where large binary files (audio/video) processed via Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request modifies the truncateFunctionResponsePart utility in packages/core/src/utils/tool-utils.ts to prevent the truncation of binary injections identified by BINARY_INJECTION_KEY. This ensures that base64 media data remains intact to avoid undecodable requests, while other text fields continue to be truncated as expected. A corresponding unit test has been added to tool-utils.test.ts to verify this behavior. I have no further feedback to provide as the implementation is clean and well-tested.
Summary
Since #30180,
read_fileon an audio or video file larger than about 48 KB fails with 400 "Base64 decoding failed".truncateFunctionResponsePartwalks the function response recursively. It also cuts the base64 inside__binary_injection__, beforeGeminiChatmoves that data into its own user turn. This PR skips that key when truncating.Details
truncateFunctionResponsePart, so all four callers are covered:createSuccessResultandcreateCancelledResultintool-executor.ts, and the two inlocal-executor.ts.collapseOlderFunctionResponsesalready replacesinlineDatain older user turns withOMITTED_BINARY_MESSAGE, which includes the turn the injection is moved into. Nested images infunctionResponse.partswere never truncated either, for the same reason.mainand passes with this change.Related Issues
Fixes #30240
How to Validate
Unit tests:
npm test -w @google/gemini-cli-core -- src/utils/tool-utils.test.ts src/scheduler/tool-executor.test.ts src/agents/memory-leak-regression.test.tsLive check on Linux with Login with Google,
-m gemini-3-flash-preview. The workspace holds a 3-second 440 Hz WAV (96,044 bytes), and the prompt isgemini -p "Use read_file on tone.wav, then tell me in one sentence what you hear":e5d88fb2cBase64 decoding failedBase64 decoding failedRequests ending with a model turn are not supported(read_file on audio/video returns 400 "Requests ending with a model turn are not supported" on Gemini 3: synthetic binary ack turn is stripped #30229)With Gemini 3 models, audio and video need this PR and fix(core): keep the synthetic binary ack so injected audio/video stays in its own turn #30230 together. Each fixes a different step.
Pre-Merge Checklist
https://claude.ai/code/session_01Sw78yR9Us3cqRudv2DDgdA