Fix: Gemini CLI Multi-Turn History Corruption on Abort

amelidev · ghdev · 2026-08-14

This PR fixes a tricky issue in Gemini CLI where aborting a multi-turn prompt with tool calls left the session history in an incomplete, pending state. This caused the model to erroneously resume the cancelled task when the user sent a new, unrelated message.

The Fix: It introduces initial state tracking for history length and token counts when a new prompt starts. If the prompt execution is aborted or cancelled mid-stream, the conversational history and token baseline are fully rolled back to their pristine state before the prompt began. A unit test was also added to ensure correct rollback behavior.

Original post →

More from coding & agent

coding & agent channel →