fix(core): wire abort signal through chat compression LLM calls#20407
fix(core): wire abort signal through chat compression LLM calls#20407Shiv-aurora wants to merge 4 commits intogoogle-gemini:mainfrom
Conversation
The compression service's two LLM calls (summarization + verification) were using throwaway AbortController signals that could never be aborted. This meant Ctrl+C / user cancellation didn't stop in-flight compression requests, wasting API tokens and blocking cancellation. Wire the parent abort signal from processTurn and executeTurn through tryCompressChat into the compression service. Make the abortSignal parameter required in compress() to prevent future regressions. The /compress command (which has no parent signal) gets a no-op fallback in GeminiClient.tryCompressChat. Resolves TODO(joshualitt) in chatCompressionService.ts.
Summary of ChangesHello @Shiv-aurora, 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 significantly enhances the responsiveness and resource efficiency of the chat compression feature. Previously, LLM calls made during chat compression were not cancellable, leading to wasted API tokens and a poor user experience when attempting to interrupt ongoing operations. The changes ensure that user-initiated cancellation signals are properly propagated to these LLM calls, allowing for immediate termination of compression requests and preventing unnecessary resource consumption. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request correctly wires the parent abort signal through the chat compression service's LLM calls, preventing orphaned in-flight compression requests and improving responsiveness. The implementation is solid, making abortSignal a required parameter in chatCompressionService.compress() to prevent regressions and gracefully handling manual /compress calls, with updated test files. A security audit of packages/core/src/agents/local-executor.ts, packages/core/src/core/client.ts, and packages/core/src/services/chatCompressionService.ts found no vulnerabilities.
The compression service's two LLM calls (summarization + verification) were using throwaway AbortController signals that could never be aborted. This meant Ctrl+C / user cancellation didn't stop in-flight compression requests, wasting API tokens and blocking cancellation. Wire the parent abort signal from processTurn and executeTurn through tryCompressChat into the compression service. Make the abortSignal parameter required in compress() to prevent future regressions. The /compress command (which has no parent signal) gets a no-op fallback in GeminiClient.tryCompressChat. Resolves TODO(joshualitt) in chatCompressionService.ts.
fix(core): wire abort signal through chat compression LLM calls
Summary
Wire the parent abort signal through chat compression LLM calls so Ctrl+C actually cancels in-flight compression requests.
Details
The compression service's two LLM calls (summarization + verification) created throwaway
AbortControllersignals that could never be aborted. This meant user cancellation didn't stop compression requests, wasting API tokens and blocking cancellation.Changes:
combinedSignalfromexecuteTurnthroughtryCompressChatinto the compression service inlocal-executor.tssignalfromprocessTurnthroughtryCompressChatinclient.tsabortSignalrequired incompress()to prevent future regressions/compresscommand (no parent signal) gets a no-op fallback inGeminiClient.tryCompressChatTODO(joshualitt)that called for this fixRelated Issues
Fixes #20405
How to Validate
/compressmanually -- should still work (no-op fallback signal)npm test -- packages/core/src/services/chatCompressionService.test.tspassesPre-Merge Checklist