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
- Dev builds oddly satisfying self-fixing sand component that repairs itself — prasenx · 2026-10-16
- When Does an Agent Actually Need an API Gateway? Reddit Weighs Direct Calls vs. Unified Endpoints — TurbulentStiffness · 2026-10-16
- optimAIzr: Open-Source Local CLI Tracks Where Your Claude Code and Codex Tokens Go — stichstichstich · 2026-10-16
- Local tool calling compared: how Gemma 4, Llama 3 and Mistral differ — leslysandra · 2026-10-16
- Harness, a command center for coding agents, hits #2 on Product Hunt — dee_hw · 2026-10-16
- First-Time Claude Code User Builds a Full Social Network, zwimpost, in One Week — Lanky-Ad8072 · 2026-10-16