Repository navigation
fix(core): preserve functionResponse parts and functionCall metadata when stripping prefixes (#29589) - #29668
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 a data loss issue in the Gemini chat integration where stripping tool name prefixes from IDs inadvertently dropped critical fields like multimodal parts and metadata. By switching from manual object reconstruction to object spread, the implementation now safely preserves all original properties, ensuring correct handling of binary data and tool call metadata. 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
|
|
📊 PR Size: size/M
|
There was a problem hiding this comment.
Code Review
This pull request updates the stripToolCallIdPrefixes function in packages/core/src/core/geminiChat.ts to use the spread operator when copying functionCall and functionResponse objects, ensuring that all additional fields (such as partialArgs and nested parts) are preserved when stripping prefixes. A corresponding unit test has been added to packages/core/src/core/geminiChat.test.ts to verify this behavior. There are no review comments, and I have no feedback to provide.
|
@googlebot I signed it! |
…when stripping prefixes (google-gemini#29589)
ee2adf3 to
40c3f01
Compare
Summary
Preserves all fields of
functionResponse(such as multimodalparts) andfunctionCall(such aspartialArgsand streaming metadata) whenstripToolCallIdPrefixes()removes tool name prefixes from IDs.Details
In
packages/core/src/core/geminiChat.ts,stripToolCallIdPrefixes()stripped<toolName>__prefixes fromfunctionResponseandfunctionCallIDs by manually reconstructing objects with hardcoded{ name, response, id }and{ name, args, id }subsets.When
read_fileor other tools return multimodal payloads (images, screenshots, inline data),convertToFunctionResponseattaches them tofunctionResponse.partsif multimodal tool use is supported. BecausestripToolCallIdPrefixes()reconstructednewPart.functionResponsewithoutparts, all binary/image content was discarded prior to sending the request to Gemini / Vertex AI, causing models to hallucinate descriptions of unseen images. Similarly, extra fields onfunctionCallwere dropped.This PR uses object spread (
...frand...fc) to preserve all existing properties while updating the strippedid.Related Issues
Closes #29589
How to Validate
Run unit tests:
npx vitest run packages/core/src/core/geminiChat.test.ts -t "stripToolCallIdPrefixes"Pre-Merge Checklist