fix: prevent self-amplifying compaction failure loop (#900) - #1055
Closed
kartikmengane09-oss wants to merge 1 commit into
Closed
fix: prevent self-amplifying compaction failure loop (#900)#1055kartikmengane09-oss wants to merge 1 commit into
kartikmengane09-oss wants to merge 1 commit into
Conversation
…meIntellect-ai#900) - Skip failed assistant provider attempts (stopReason: error) from buildSessionContext replay - Skip compaction_outcome custom_message telemetry from buildSessionContext replay - Enforce safe input token budget and message-boundary chunking in generateSummary - Add post-compaction result validation in compact to prevent committing oversized context - Add regression test coverage for session context filtering and bounded summarization
kartikmengane09-oss
marked this pull request as ready for review
August 9, 2026 07:34
avion23
pushed a commit
to avion23/prime-agent
that referenced
this pull request
Aug 9, 2026
…lf-amplifying compaction failure loop (PrimeIntellect-ai#900)
Contributor
|
Thank you for the report and proposed work. This root cause is now covered by maintainer-owned stacked PR #1165, authored independently from We did not inspect or reuse this PR's diff, branch, commits, implementation code, or tests; its public description/comments were used only as a bug report. To keep one review surface, this PR is superseded by #1165 and is being closed. The complete review stack is #1158–#1165. It is being left unmerged for human review after CI and review-bot findings are cleared. |
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
Fixes the self-amplifying compaction failure loop described in #900.
Problem
Long-running sessions can exceed the model context window. The initial provider call fails, recovery compaction is then attempted with an oversized summarization request, and the compaction failure is persisted and replayed into subsequent model context. This causes repeated failures and progressively larger context until the session becomes unresponsive.
Changes
Validation
Relevant compaction and session-context regression tests are included/run as part of the change.
Closes #900
Note
Fix self-amplifying compaction failure loop by adding context budget enforcement
compaction.ts:generateSummarynow splits oversized conversations into budget-sized chunks using a chars/4 token estimate, summarizes each chunk independently, then aggregates into a final summary with a second-pass if needed.compactvalidates the produced summary against the model's context window after generation and throws if the result would exceed the safe limit, preventing an oversized compacted state from being committed.session-manager.ts:buildSessionContextnow filters out assistant messages withstopReason: "error"andcompaction_outcomecustom messages from the model context to avoid replaying failed attempts.compactnow throws instead of silently succeeding when the compacted result is too large for the context window.Macroscope summarized 6f1ef3e.