google-gemini / google-gemini/gemini-cli
bug: Missing thought_signature in functionCall for Gemini 3/3.1 reasoning models
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### Bug Description
When using Gemini 3/3.1 reasoning models with function calling, the CLI throws a `400 Bad Request` (INVALID_ARGUMENT) error:
`Function call is missing a thought_signature in functionCall parts.`
### Cause
In `ensureActiveLoopHasThoughtSignatures` and `pairToolsAndEnforceSignatures`, the CLI injects the synthetic thought signature at the root of the `part` object (as `part.thoughtSignature`) in camelCase, instead of nesting it inside the `part.functionCall` object as `thought_signature` (snake_case) as strictly required by the Gemini/Vertex API.
### Proposed Fix
The synthetic signatures must be mirrored inside the `functionCall` object with both camelCase and snake_case properties to ensure backward/forward compatibility and schema validation:
```javascript
// Example in ensureActiveLoopHasThoughtSignatures:
if (!part.thoughtSignature) {
newParts[j] = {
...part,
thoughtSignature: SYNTHETIC_THOUGHT_SIGNATURE2,
functionCall: {
...part.functionCall,
thought_signature: SYNTHETIC_THOUGHT_SIGNATURE2,
thoughtSignature: SYNTHETIC_THOUGHT_SIGNATURE2
}
};
}
```
Contributor guide
Research direction
Locate ensureActiveLoopHasThoughtSignatures and pairToolsAndEnforceSignatures, then inspect how functionCall parts are copied and serialized. Ensure synthetic signatures are present inside functionCall as both thought_signature and thoughtSignature, while preserving the existing root fields; done means Gemini function-calling requests no longer fail for missing thought_signature.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, api, cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100