- Status:
- [merged] March 2026
- Stack:
- TypeScript, Node.js
- Author:
- @SH20RAJ, my previous GitHub account (GitHub now shows it as “ghost”)
Subject: gemini-cli: cancelling a turn now cancels chat compression
Pressing Ctrl+C cancelled the visible turn but not the chat-compression request running behind it. I traced where the AbortSignal stopped being passed along and threaded it through. The maintainers merged it.
The bug
In a multi-turn chat, cancelling a turn stopped the stream the user was watching. Before that turn ran, though, the client could start a request to compress the chat history, and that request never received the turn's AbortSignal. So it kept running after the user had cancelled: a wasted model call, and work in flight that could finish late and race with the next prompt.
The fix
I followed the signal from where the turn is created down to the compression call and passed it through the layers that dropped it, so the compression request is cancelled together with the turn. The merged commit is titled fix(core): thread AbortSignal to chat compression requests.
A simplified sketch of the shape of the change (the real diff is in the pull request):
async executeTurn(prompt: string, { signal }: { signal?: AbortSignal }) {
if (this.shouldCompressHistory()) {
// before: compress({ history }) with no signal
await this.compressionService.compress({ history: this.chatHistory, signal });
}
return this.client.streamGenerateContent(prompt, { signal });
}What I took from it
- Cancellation bugs hide in the calls that happen before the one you are watching.
- In an unfamiliar codebase, following one value end to end is faster than reading every file.
- A small, scoped diff with a clear reproduction is what gets through review.
Link: google-gemini/gemini-cli#20778
Merged-commit: f11bd3d
Reported-in: google-gemini/gemini-cli#20405