feat(agent): structured, economical compaction (soft/force ratios + fold economics)#3073
Merged
Merged
Conversation
…old economics) Adds a soft-notice ratio (report growing context without cratering the cache prefix), a force ratio (compact even low-value folds at the high-water mark), and a fold-economics gate that skips a summarizer round-trip when the region is too small to pay for itself. Rebased onto main-v2: unified compact() to (ctx, trigger, instructions, force) so the new force flag coexists with the existing /compact focus + PreCompact-hook path; kept main-v2's token-budgeted tail (planCompaction) and detailed summary prompt rather than reverting to the PR's message-count tail; adapted the threshold tests to the token-budgeted tail. Closes #2406
Owner
Author
|
C:/Program Files/Git/e2e |
🤖 Reasonix e2e benchmarkAccuracy: 3/4 (75%) · Cache hit: 75% · Tokens: 160,894 (prompt 158,586 / completion 2,308) · Compactions: 3 · Cost: ¥ 0.0463
Real provider run. Cache-hit % is cached prompt tokens / total prompt tokens. |
Owner
Author
|
C:/Program Files/Git/e2e |
🤖 Reasonix e2e benchmarkAccuracy: 4/4 (100%) · Cache hit: 74% · Tokens: 153,899 (prompt 151,915 / completion 1,984) · Compactions: 3 · Cost: ¥ 0.0452
Real provider run. Cache-hit % is cached prompt tokens / total prompt tokens. |
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.
Rebase of #2406 (by @SivanCola) onto current main-v2 (after #3050/#3057 landed). The branch had drifted; I applied the net diff and re-merged the compaction core by hand, since
compact()had diverged on both sides.What it does
forceand by manual/compact).Rebase notes (signature reconciliation)
compact(ctx, trigger, instructions); this PR hadcompact(ctx, force bool). Unified tocompact(ctx, trigger, instructions, force)so the force flag coexists with the existing/compact <focus>text + PreCompact-hook path and the cache-diagnostics rewrite tracking from feat(agent): cache prefix diagnostics for prompt-cache churn #3057.planCompaction, parameterized with a min-message count for the single-large-message fallback) rather than reverting to the PR's message-count tail, and kept main-v2's more detailed summary prompt.maybeCompactnow layers the soft-notice and force logic on top of main-v2's anti-re-compactioncompactStucklatch.Local:
go build ./...,go vet, andgo test ./internal/agent ./internal/config ./internal/boot ./internal/cli ./internal/controlall green.Closes #2406