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
- Agentic coding accessibility will reshape understanding of software complexity — pixlpa · 2026-08-24
- Devin Agent bypasses Slack block by finding emails in git logs — sandylikesfrogs · 2026-08-24
- Developer habits shift: Agents become collaborators from simple tools — latticecut · 2026-08-24
- Dev bottleneck shifts from writing to reading code: exe.dev co-founder — thursdai_pod · 2026-08-24
- The biggest AI mistake: trying to reinvent the wheel instead of using tools — Tired40s · 2026-08-24
- DeepPaperNote turns research papers into Obsidian notes — tom_doerr · 2026-08-24