Fixing Gemini CLI API 400 Errors Caused by Missing thoughtSignature
sarbojitrana · ghdev · 2026-07-31
This PR fixes a regression bug in Gemini CLI v0.53.0 that caused API Error 400.
Root Cause
When context management is disabled, the stripThoughts() function unconditionally drops history parts with thought: true. However, if the Gemini API attaches the required thoughtSignature to these thought parts, stripping them throws away the turn's only signature. When these signature-less functionCalls are replayed, the API rejects the request.
The Fix
Mirroring the correct logic from the context-management-enabled path, the fix injects an existing SYNTHETICTHOUGHTSIGNATURE sentinel onto the first functionCall when stripping thoughts, ensuring requests pass successfully.
More from coding & agent
- UNC's Wanda: agentic AI for neuroimaging validated on 123,000 brains — PTenigma · 2026-12-02
- Software products need an API/MCP/plugin now: agents will drive acquisition and retention — omooretweets · 2026-12-02
- AI coding tools are self-configuring: install Claude Code and you're done — _jaydeepkarale · 2026-12-02
- Image-to-Blender showdown: Neon crushes Opus with a huge gap — YouJiacheng · 2026-12-02
- Matt Shumer says collaborating with Jacob humbles his AI-orchestration skills ahead of Spawn — mattshumer_ · 2026-12-02
- LiveCraft benchmark: top agents score just 30.3/100 in real-time Minecraft worlds — Chengxing Xie · 2026-12-02