fix(core): honor compaction.auto on provider overflow#17936
Open
timwkosatec wants to merge 2 commits intoanomalyco:devfrom
Open
fix(core): honor compaction.auto on provider overflow#17936timwkosatec wants to merge 2 commits intoanomalyco:devfrom
timwkosatec wants to merge 2 commits intoanomalyco:devfrom
Conversation
6 tasks
ff71e61 to
72d6cea
Compare
Author
|
The failing e2e checks look unrelated to this fix. This PR comes from a fork, so it looks like the paid-model e2e workflow cannot access that secret here. The code-related checks are green. |
f22c2aa to
1448371
Compare
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.
Issue for this PR
Closes #16882
Type of change
What does this PR do?
PR #14707 added auto-compaction recovery for 413/context overflow errors, but the
ContextOverflowErrorcatch block inprocessor.tsunconditionally setsneedsCompaction = truewithout checking thecompaction.autoconfig. Users who setcompaction: { "auto": false }still get forced into a compaction loop on overflow, and switching to a model with a larger context window doesn't recover the session.This adds a
config.compaction?.auto === falsegate to the overflow catch path:"stop". The user can then resume with a different model.needsCompaction = true→ compact and recover).The strict
=== falsecheck means the default (undefined) still compacts, so this is backward-compatible. Manual compaction (/compact) remains available regardless of theautosetting.How did you verify your code works?
Added two tests in
compaction.test.ts:stops on provider overflow when compaction.auto is false— verifies result is"stop", error is persisted asContextOverflowError, no compaction parts written.compacts on provider overflow when compaction.auto is true— verifies result is"compact", no error on assistant message.Run with:
Also verified no regressions in:
bun test test/session/retry.test.ts(18 pass)bun test test/session/message-v2.test.ts -t "fromError"(6 pass)Screenshots / recordings
N/A — no UI changes.
Checklist