feat(compaction): enforce 384k active budget ceiling and sticky generation latch for request-shape stability - #1095
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31f29200ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
…ens 노출 및 35k 기본값 적용
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31f29200ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9837c5acd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…eat/context-budget-policy # Conflicts: # packages/agent/src/harness/compaction/compaction.ts # packages/coding-agent/src/core/extensions/builtin/compaction/index.ts # packages/coding-agent/src/core/extensions/builtin/compaction/policy.ts # packages/coding-agent/src/core/settings-manager.ts
Summary
Separates physical context window from operational working-set budget (
ContextBudgetPolicy) in core compaction and builtin compaction extensions, enforcing a 384k active ceiling for 1M models and a sticky generation latch to prevent request prefix shape oscillations.Key Changes
ContextBudgetPolicy(384k Active Ceiling & 288k Warmup):maxActiveContextTokens = 384_000for 1M-class models (contextWindow >= 500_000), regardless of adaptive ratio resulting in 650k.384_000 * 0.75 ≈ 288_000tokens.keepRecentTokens = 35_000(explicit user settings take precedence).Request-Shape Sticky Generation Latch:
session_compactor session tree reload/reset.Context Pressure Metric Interface:
ContextPressureinterface withactiveTokens,requestBodyBytes, andgenerationfor non-token metric tracking.Verification
packages/coding-agent/test/compaction/policy.test.ts: 5/5 PASS (200k compatibility, 1M 384k/288k matrix, user overrides).packages/coding-agent/test/compaction/context-reduction.test.ts: 9/9 PASS (collapse, shrink, clear, sticky generation latch & prefix stability).packages/coding-agent/test/compaction.test.ts: 43/43 PASS.npm run check: 0 errors (biome, shrinkwrap, install-lock, tsc --noEmit, browser-smoke).npm run buildPASS.Summary by cubic
Enforces a 384k active-context ceiling for 1M-class models and adds a branch-scoped sticky context-reduction latch to stabilize request prefix shape and preserve cache hits. Previously we used a 0.65 ratio (~650k on 1M) and reduction could oscillate; now blocking caps at 384k, speculative warmup starts at 288k, and reduction stays latched until compaction is accepted or the model or session branch changes.
ContextBudgetPolicydecouples physical window and active budget. 1M defaults tomaxActiveContextTokens=384k,keepRecentTokens=35k, warmup at 75%,reserveTokens=16,384; standard models keepkeepRecentTokens=20k. Users can override via settingscompaction.maxContextTokensandcompaction.keepRecentTokens; explicit overrides (including zero) are preserved.shouldCompact()honor the active ceiling;computeEffectiveBlockingThresholdTokens()caps adaptive thresholds; the final provider admission path now enforces the same ceiling before dispatch; speculative warmup derives from the policy.session_compact,session_tree, andmodel_select. Provider-native compaction stays excluded.compaction.keepRecentTokens: 20000. To lower the active ceiling, setcompaction.maxContextTokens.Written for commit 2cf8c81. Summary will update on new commits.