Skip to content

Conversation

@kfxmvp
Copy link

@kfxmvp kfxmvp commented Dec 10, 2025

TLDR

This PR fixes a critical bug where using tools (function calls) with Gemini 3 Pro Preview resulted in an API Error 400. The error was caused by the missing thought_signature, which is required by the Gemini API for tool verification in this model.

Dive Deeper

  • Issue: As reported in [Bug] API Error 400 with Gemini 3 Pro: Missing thought_signature for function call #1187, Gemini 3 Pro Preview failed to execute tool calls, returning Unable to submit request because function call ... is missing a thought_signature.
  • Fix: Implemented logic in OpenAIContentConverter to extract the thoughtSignature from the streaming response chunks and attach it to the corresponding functionCall object. This ensures the signature is passed back to the API in subsequent requests, satisfying the verification requirement.
  • Cache Mechanism: The implementation uses index as the key to cache thoughtSignature. This approach ensures robustness because id might not be present in every chunk during streaming or in certain model responses, whereas index is a reliable identifier for correlating chunks within the stream.

Reviewer Test Plan

  1. Setup: Configure the CLI to use gemini-3-pro-preview.
  2. Reproduction: Execute a prompt that requires a tool call (e.g., read_file README.md).
  3. Verification: Confirm that the tool executes successfully and the previous API Error 400 is resolved.
  4. Regression Test: Ensure that other models (e.g., gemini-1.5-pro, gpt-4o) still function correctly with tool calls.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - - -
Seatbelt - -

Linked issues / bugs

Resolves #1187

@pomelo-nwu
Copy link
Collaborator

@kfxmvp Appreciate it! We’ll need a bit to check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] API Error 400 with Gemini 3 Pro: Missing thought_signature for function call

2 participants