Skip to content

fix(core): thread abort signal through chat compression#20515

Closed
deadsmash07 wants to merge 1 commit intogoogle-gemini:mainfrom
deadsmash07:fix/compression-abort-signal
Closed

fix(core): thread abort signal through chat compression#20515
deadsmash07 wants to merge 1 commit intogoogle-gemini:mainfrom
deadsmash07:fix/compression-abort-signal

Conversation

@deadsmash07
Copy link
Copy Markdown
Contributor

Summary

  • Thread the parent abort signal from processTurn and executeTurn through tryCompressChat into the compression service
  • Ctrl+C during chat compression now cancels the in-flight generateContent API calls immediately

Details

When the CLI triggers chat compression (summarization + verification LLM calls), pressing Ctrl+C didn't cancel the underlying API requests. Both generateContent calls in chatCompressionService.compress() were receiving a throwaway new AbortController().signal because tryCompressChat in both client.ts and local-executor.ts never forwarded the parent abort signal.

The fix adds an optional abortSignal parameter to both tryCompressChat methods and passes through the signals that are already available at the call sites (signal in processTurn, combinedSignal in executeTurn).

Related Issues

Fixes #20405

How to Validate

  1. Start a long conversation that triggers chat compression
  2. Press Ctrl+C while compression is running
  3. Verify the API calls are cancelled immediately (no lingering requests)

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed) — N/A
  • Added/updated tests (if needed) — Existing tests cover the compression flow; typecheck confirms signature compatibility
  • Noted breaking changes (if any) — None (parameter is optional)
  • Validated on required platforms/methods:
    • Linux npm run

Ctrl+C during compression now cancels the in-flight API calls.
Previously, tryCompressChat did not forward the parent abort signal
to the compression service, so generateContent calls used a throwaway
AbortController and ignored user cancellation.

Fixes google-gemini#20405
@deadsmash07 deadsmash07 requested a review from a team as a code owner February 27, 2026 00:06
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the responsiveness of the application by implementing proper cancellation for long-running chat compression operations. By propagating existing abort signals through the chat compression logic, users can now interrupt ongoing LLM API calls immediately, preventing lingering requests and improving control during interactive sessions.

Highlights

  • Abort Signal Propagation: The abortSignal is now threaded through tryCompressChat in both local-executor.ts and client.ts to the underlying chat compression service.
  • Immediate Cancellation: Pressing Ctrl+C during chat compression will now immediately cancel in-flight generateContent API calls, improving user experience.
Changelog
  • packages/core/src/agents/local-executor.ts
    • Modified tryCompressChat to accept an optional abortSignal parameter.
    • Passed the combinedSignal from executeTurn to tryCompressChat.
    • Forwarded the received abortSignal to the chat compression service.
  • packages/core/src/core/client.ts
    • Modified tryCompressChat to accept an optional abortSignal parameter.
    • Passed the signal from processTurn to tryCompressChat.
    • Forwarded the received abortSignal to the chat compression service.
Activity
  • The pull request addresses and fixes issue Bug: Ctrl+C doesn't cancel in-flight chat compression requests #20405.
  • Existing tests are deemed sufficient to cover the compression flow, and type-checking confirmed signature compatibility.
  • The changes introduce no breaking changes as the abortSignal parameter is optional.
  • The changes have been validated on Linux using npm run.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly threads the parent abort signal through the chat compression service. By adding an optional abortSignal parameter to tryCompressChat in local-executor.ts and client.ts, the change ensures that in-flight generateContent API calls during chat summarization can be properly cancelled. The implementation is straightforward and effectively resolves the issue of lingering API requests upon cancellation.

@gemini-cli gemini-cli bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Feb 27, 2026
@deadsmash07
Copy link
Copy Markdown
Contributor Author

Closing this — @Shiv-aurora's PR #20407 addresses the same issue and was opened first. No need for a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Ctrl+C doesn't cancel in-flight chat compression requests

1 participant