Repository navigation
fix(agents): cap compaction budgets for small contexts - #87927
vincentkoc wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 5:19 PM ET / 21:19 UTC. Summary PR surface: Source +33, Tests +38, Docs +14, Generated 0. Total +85 across 9 files. Reproducibility: yes. at source level: current main caps only the reserve floor, then leaves high existing reserve and keep-recent budgets uncapped when a context window is known. I did not run a live gateway or local-model reproduction in this read-only review. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Rebase onto current main, reconcile small-context prompt safety with explicit reserve-token semantics across related compaction paths, then merge only if maintainers accept the compatibility change. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main caps only the reserve floor, then leaves high existing reserve and keep-recent budgets uncapped when a context window is known. I did not run a live gateway or local-model reproduction in this read-only review. Is this the best way to solve the issue? Conditionally yes: settings normalization is a plausible narrow fix location, but the PR must be rebased and maintainer-approved because it changes effective config-backed values and overlaps related reserve-token semantics work. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 15de9d881a84. Label changesLabel justifications:
Evidence reviewedPR surface: Source +33, Tests +38, Docs +14, Generated 0. Total +85 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
985f328 to
5dbcc93
Compare
5dbcc93 to
7be9ce4
Compare
7be9ce4 to
470b477
Compare
470b477 to
0459aef
Compare
a9e2e5e to
42c2af5
Compare
42c2af5 to
aa62240
Compare
aa62240 to
6d460a4
Compare
|
Confirming this fix is needed: the unguarded path reproduces live on I drove the real The negative prompt budget means the runtime predicate ( This PR's |
|
The sound part of this PR has been replayed and landed through #100621 as The landed fix caps the final effective reserve for a known small context window. Exact runtime proof showed a 16,384-token context changing from reserve 16,384 with I deliberately did not replay the The branch could not be updated directly because maintainer edits are disabled, so I recreated the verified subset with Vincent's co-author credit and changelog thanks. Thank you @vincentkoc. For future contributor branches, enabling Allow edits by maintainers lets us repair the original PR in place. |
Summary
Verification
Behavior addressed: small-context runs no longer retain impossible compaction
reserveTokensorkeepRecentTokensbudgets whencontextTokenBudgetis known, and compacted tails no longer consume the whole post-reserve prompt budget before the summary is added.Real environment tested: focused local Vitest/docs/format/lint proof in a Codex worktree; remote Crabbox/Testbox proof was attempted on the refreshed head and blocked by runner availability/auth, noted below.
Exact steps or command run after this patch:
node scripts/run-vitest.mjs run src/agents/agent-settings.test.ts --reporter=dot node --import tsx scripts/generate-config-doc-baseline.ts --write node --import tsx scripts/generate-config-doc-baseline.ts --check node scripts/check-docs-mdx.mjs docs/reference/session-management-compaction.md docs/gateway/config-agents.md node scripts/format-docs.mjs --check docs/reference/session-management-compaction.md docs/gateway/config-agents.md node_modules/.bin/oxfmt --check --threads=1 src/agents/agent-settings.ts src/agents/agent-settings.test.ts src/agents/agent-compaction-constants.ts src/agents/compaction-planning.ts src/config/schema.help.ts src/config/types.agent-defaults.ts node scripts/run-oxlint.mjs src/agents/agent-settings.ts src/agents/agent-settings.test.ts src/agents/agent-compaction-constants.ts src/agents/compaction-planning.ts src/config/schema.help.ts src/config/types.agent-defaults.ts git diff --check origin/main...HEAD blacksmith testbox list node scripts/crabbox-wrapper.mjs run --provider azure --target linux --idle-timeout 90m --ttl 180m --timing-json --shell -- "pnpm check:changed" crabbox stop --provider azure --target linux --id cbx_b8cfba03c38eEvidence after fix: refreshed head
6d460a45848is rebased onto currentorigin/main5ee3e5d8c07. Focused local wrapper passedsrc/agents/agent-settings.test.tswith 36/36 tests. Config baseline generation/check passed withOK docs/.generated/config-baseline.sha256; docs MDX passed fordocs/reference/session-management-compaction.mdanddocs/gateway/config-agents.md; docs formatting reportedDocs formatting clean; oxfmt, oxlint, andgit diff --check origin/main...HEADpassed.Remote proof: Blacksmith Testbox is blocked locally by
not authenticated - run 'blacksmith auth login' first. Azure Crabbox allocated runrun_23b37df84fc5with providerazure, lease idcbx_b8cfba03c38e, slugswift-prawn, targetlinux, but timed out after 10m waiting for a coordinator lease before runningpnpm check:changed. Cleanup stop returned coordinator404 not_found, so no late active lease remained to release.Observed result after fix: a 16K-context profile resolves reserve to
8,384and keep-recent to4,000; configured over-budget reserve and keep-recent values are capped to the available context window while leaving summary overhead; when no context window is known, existing uncapped behavior is preserved. The session-management reference now documents those context-window caps and points atapplyAgentCompactionSettingsFromConfig(), not the old uncapped helper.What was not tested: broad remote
pnpm check:changedon the refreshed head, because Testbox auth and Azure allocation blocked it; no live Ollama generation for this patch because the changed behavior is the embedded-agent settings normalization layer.