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.

Original post →

More from coding & agent

coding & agent channel →