-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(core)!: redesign auto-compaction thresholds with three-tier ladder #4345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LaZzyMan
wants to merge
14
commits into
main
Choose a base branch
from
lazzy/auto-compaction-redesign-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
593d738
feat(core)!: redesign auto-compaction thresholds with three-tier ladder
LaZzyMan e7a26a6
test(core): fix leftover hasFailedCompressionAttempt option in compre…
LaZzyMan 1f9a35b
fix(core): drop compaction summary when output hits maxOutputTokens cap
LaZzyMan 0505877
fix(cli): render three-tier thresholds in /context TUI view
LaZzyMan 81ec0ee
fix(core,cli): address PR #4168 review batch 4
LaZzyMan cb3b09e
fix(core,cli): address PR #4168 review batch 5
LaZzyMan 50bac97
fix(core): disambiguate hard-rescue from manual /compress orphan-strip
LaZzyMan 45346df
docs(core): fix tier-collapse direction in auto-compaction design doc
LaZzyMan f91b7e4
refactor(core): extract shared in-flight funcCall fixture in compress…
LaZzyMan 1f856ba
fix(core,cli): address PR #4345 round-2 review feedback
LaZzyMan 7c7c2d2
merge: resolve conflicts with main (drop heap-pressure, adapt to getH…
LaZzyMan b62b554
fix(core): address PR #4345 round-3 + round-4 review feedback
LaZzyMan 05a41bb
fix(core): address PR #4345 round-5 review feedback
LaZzyMan a81438e
fix(core): address PR #4345 round-6 review feedback (R6 sweep)
LaZzyMan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
1,752 changes: 1,752 additions & 0 deletions
1,752
docs/plans/2026-05-14-auto-compaction-threshold-redesign.md
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, it, expect } from 'vitest'; | ||
| import { tipRegistry, type TipContext } from './tipRegistry.js'; | ||
|
|
||
| const baseCtx: TipContext = { | ||
| lastPromptTokenCount: 0, | ||
| contextWindowSize: 200_000, | ||
| sessionPromptCount: 10, | ||
| sessionCount: 1, | ||
| platform: 'darwin', | ||
| thresholds: { | ||
| warn: 147_000, | ||
| auto: 167_000, | ||
| hard: 177_000, | ||
| effectiveWindow: 180_000, | ||
| }, | ||
| }; | ||
|
|
||
| function tipById(id: string) { | ||
| return tipRegistry.find((t) => t.id === id)!; | ||
| } | ||
|
|
||
| describe('context-* tip thresholds align with computeThresholds', () => { | ||
| it('compress-intro fires between warn and auto', () => { | ||
| const t = tipById('compress-intro'); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 100_000 })).toBe( | ||
| false, | ||
| ); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 150_000 })).toBe( | ||
| true, | ||
| ); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 168_000 })).toBe( | ||
| false, | ||
| ); | ||
| }); | ||
|
|
||
| it('context-high fires between auto and hard', () => { | ||
| const t = tipById('context-high'); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 150_000 })).toBe( | ||
| false, | ||
| ); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 170_000 })).toBe( | ||
| true, | ||
| ); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 178_000 })).toBe( | ||
| false, | ||
| ); | ||
| }); | ||
|
|
||
| it('context-critical fires at or above hard', () => { | ||
| const t = tipById('context-critical'); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 170_000 })).toBe( | ||
| false, | ||
| ); | ||
| expect(t.isRelevant({ ...baseCtx, lastPromptTokenCount: 178_000 })).toBe( | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| it('falls back gracefully when thresholds undefined (legacy callers)', () => { | ||
| const ctx = { ...baseCtx, thresholds: undefined }; | ||
| // All three context-* tips return false when thresholds are missing | ||
| // (the comparison would be unsafe without them). | ||
| expect(tipById('compress-intro').isRelevant(ctx)).toBe(false); | ||
| expect(tipById('context-high').isRelevant(ctx)).toBe(false); | ||
| expect(tipById('context-critical').isRelevant(ctx)).toBe(false); | ||
| }); | ||
|
|
||
| it('compress-intro additionally gates on sessionPromptCount > 5', () => { | ||
| const t = tipById('compress-intro'); | ||
| // Above warn, below auto, but session is too new. | ||
| expect( | ||
| t.isRelevant({ | ||
| ...baseCtx, | ||
| lastPromptTokenCount: 150_000, | ||
| sessionPromptCount: 3, | ||
| }), | ||
| ).toBe(false); | ||
| expect( | ||
| t.isRelevant({ | ||
| ...baseCtx, | ||
| lastPromptTokenCount: 150_000, | ||
| sessionPromptCount: 6, | ||
| }), | ||
| ).toBe(true); | ||
| }); | ||
| }); |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.