fix(core): harden reactive compression follow-ups#3985
Merged
Conversation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the “reactive compression” paths introduced in #3879 by tightening cancellation propagation, preventing send-lock deadlocks on setup failures, and ensuring failed reactive compression attempts are latched so later auto-compaction logic can respond appropriately.
Changes:
- Pass
AbortSignalthrough to the compression summarygenerateContentrequest. - Centralize “explicit compression failure” detection and use it to latch failures (excluding
NOOP) for reactive compression follow-ups. - Ensure the send lock is released (and the partially-added user turn is rolled back) when setup throws after compression.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/services/chatCompressionService.ts | Threads abortSignal into compression summary generation requests. |
| packages/core/src/services/chatCompressionService.test.ts | Adds coverage asserting abort propagation into summary generation. |
| packages/core/src/core/geminiChat.ts | Refactors explicit compression-failure detection; releases send lock on setup failure; latches explicit reactive compression failures. |
| packages/core/src/core/geminiChat.test.ts | Adds regression tests for send-lock release on setup failure and reactive failure latch behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
wenshao
approved these changes
May 9, 2026
wenshao
left a comment
Collaborator
There was a problem hiding this comment.
No issues found. LGTM! ✅ — gpt-5.5 via Qwen Code /review
This was referenced May 15, 2026
mabry1985
added a commit
to protoLabsAI/protoCLI
that referenced
this pull request
May 27, 2026
Adapted from QwenLM#3879 (+QwenLM#3985 hardening). When a provider rejects a request because the prompt exceeds the context window, force-compress the chat history once and retry the request — instead of surfacing a hard failure. Because our geminiChat has diverged substantially from upstream (≈1/3 the size, bespoke overflow handling, compression owned by client.tryCompressChat rather than a geminiChat.tryCompress method), this is an adaptation, not a patch port: - New `utils/contextLengthError.ts`: provider-agnostic `getContextLengthExceededInfo` that classifies an arbitrary error (incl. nested causes / embedded JSON) as a context-overflow vs. a timeout, and extracts actual/limit token counts. Ported near-verbatim (self-contained) with full test coverage. - geminiChat streaming retry loop: on a classified overflow, compress the LIVE chat via `ChatCompressionService` (force=true) — NOT client.tryCompressChat, which calls startChat() and would swap the chat instance out from under the in-flight generator. Install the compressed history with setHistory, mirror the essential side effects (FileReadCache.clear + telemetry token count), refresh the request contents, and retry once. A one-shot flag prevents any compress/retry loop if the request is still too large after compression. Tests: 25 classifier cases; 3 geminiChat reactive cases (compress→retry succeeds; non-overflow errors don't compress; at-most-once guard). 39 geminiChat + 51 compression-service tests pass; core builds; eslint clean. Co-authored-by: Automaker <automaker@localhost> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
xaelistic
pushed a commit
to xaelistic/qwen-code
that referenced
this pull request
Jun 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NOOP, and that the send-lock cleanup does not change normal streaming behavior.Validation
AbortSignal.geminiChat.test.tsandchatCompressionService.test.ts. Core typecheck passed. Prettier reported the changed files unchanged after formatting.git diff --checkpassed.Local verification
From the repository root, run:
cd packages/core npx vitest run src/core/geminiChat.test.ts src/services/chatCompressionService.test.ts npm run typecheckExpected test output:
Expected typecheck output:
What this verifies:
Quickest reviewer verification path:
Evidence (output, logs, screenshots, video, JSON, before/after, etc.):
Scope / Risk
NOOPstill keeps the existing forced-compression semantics.人工验证
预期
预期:
Testing Matrix
Testing matrix notes:
Linked Issues / Bugs