Skip to content

fix(core): preserve thoughtSignature in functionCall parts to fix 400 error - #28586

Closed
Tejas-Raj01 wants to merge 6 commits into
google-gemini:mainfrom
Tejas-Raj01:fix-tool-call-signature
Closed

fix(core): preserve thoughtSignature in functionCall parts to fix 400 error#28586
Tejas-Raj01 wants to merge 6 commits into
google-gemini:mainfrom
Tejas-Raj01:fix-tool-call-signature

Conversation

@Tejas-Raj01

Copy link
Copy Markdown

PR Title

fix(core): preserve thoughtSignature in functionCall parts to fix 400 error


PR Body

Summary

Fixes a regression introduced in version 0.53.0 that causes a 400 Bad Request error during parallel tool calls. The thoughtSignature was being inadvertently stripped from functionCall parts during history mapping and scrubbing.

Details

  • Updated the ToolCallRecord and related interfaces in packages/core/src/scheduler/types.ts and packages/core/src/services/chatRecordingTypes.ts to include the optional thoughtSignature property.
  • Modified the mapping logic in packages/core/src/utils/sessionUtils.ts to preserve thoughtSignature when converting tool calls to parts.
  • Added a unit test case in packages/core/src/utils/sessionUtils.test.ts to ensure the signature is maintained in the output.

Related Issues

Fixes #28579

How to Validate

  1. Run the test suite to ensure the new unit test passes:
    npx vitest run packages/core/src/utils/sessionUtils.test.ts
  2. Start the CLI locally:
    npm start
  3. Issue a prompt that forces the model to use parallel tool calling (e.g., "Check the weather in New York and London at the same time using your weather tool").
  4. Verify that the CLI successfully executes the tools and returns the response without throwing the 400 Bad Request: Function call is missing a thought_signature API error.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@Tejas-Raj01
Tejas-Raj01 requested a review from a team as a code owner July 29, 2026 19:38
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 regression where the thoughtSignature was being stripped from function call parts during session history processing. By updating the core data structures and mapping logic, the system now correctly preserves this signature, preventing API errors during parallel tool execution.

Highlights

  • Regression Fix: Resolved a 400 Bad Request error occurring during parallel tool calls by ensuring the thoughtSignature property is correctly preserved during history mapping.
  • Type Definitions: Updated ToolCallRequestInfo and ToolCallRecord interfaces to include the optional thoughtSignature property.
  • Testing: Added a new unit test in sessionUtils.test.ts to verify that thoughtSignature is maintained in the model's output history.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/m A medium sized PR label Jul 29, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 72
  • Additions: +72
  • Deletions: -0
  • Files changed: 6

@google-cla

google-cla Bot commented Jul 29, 2026

Copy link
Copy Markdown

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for preserving and propagating thoughtSignature across tool calls, updating relevant interfaces, stream hooks, session utilities, and tests. Feedback suggests ensuring that the optional id property in useGeminiStream.ts falls back to tool.request.callId when undefined, rather than being conditionally omitted, to prevent potential API errors.

Comment thread packages/cli/src/ui/hooks/useGeminiStream.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@gemini-cli

gemini-cli Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@Tejas-Raj01

Copy link
Copy Markdown
Author

Hi @scidomino, @galdawave, @DavidAPierce,
I've opened PR #28586 which fixes this P2 regression and includes the necessary unit tests. Could someone please review it and apply the 'help wanted' label to the original issue so the bot doesn't close this PR?

@gemini-cli

gemini-cli Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@gemini-cli gemini-cli Bot closed this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality priority/p2 Important but can be addressed in a future release. size/m A medium sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(core): 400 Bad Request: "Function call is missing a thought_signature in functionCall parts" during parallel tool calls

1 participant