fix(compaction): stabilize request-local reduction cache - #901
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f11d2061f6
ℹ️ 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".
|
ULW audit verdict: BLOCKED. The context-reduction oscillation is real and the fix passes focused/affected tests plus mock-loop QA, but the submitted branch conflicts with current main in |
…-cache-stability-pr # Conflicts: # packages/coding-agent/changes.md
|
Conflict resolved: merged current main (d641e7e) into the branch and resolved the changes.md conflict by keeping both sections — the new main entry first, then the reduction-cache entry. Focused regressions (900-context-reduction-cache-stability, 900-context-reduction-lifecycle) pass locally. The branch is now MERGEABLE; BLOCKED appears to be awaiting review approval. |
|
Re-audit request: the changes.md conflict flagged in the BLOCKED verdict was resolved on 2026-08-17 (merged main d641e7e, kept both sections). The branch is still cleanly mergeable against current main (9ad176f, post-#955) — GitHub reports mergeable=true — and all checks (GitGuardian, cubic) are green. The only remaining state is mergeable_state=blocked awaiting review approval. Until this lands we carry the latch as a local patch on senpi 2026.8.18-2, so a re-run of the ULW audit would be appreciated. |
Summary
session_compactevent.The context hook rewrites only the outgoing request; it does not replace stored session history. With a stateless gate, reported usage moving from 501,000 to 499,000 tokens against a one-million-token window alternated reduced and unreduced payload shapes for the same stored history. This change keeps the request shape stable until compaction actually changes that history.
The stateful high/low watermark introduced for emergency pruning in #425 is the closest precedent. Here, an accepted compaction is the release condition because a narrow numeric release band cannot prove that stored history changed.
Fixes #900.
Tests
npm run checknpm run buildSummary by cubic
Stabilizes request-local context reduction by latching once the 50% gate is crossed and releasing only after an accepted, persisted compaction or when session-tree navigation changes the active branch. Previously reduction flipped around 50%, producing alternating payload shapes; now requests keep one reduced shape until history actually changes.
ContextReductionLatchwithcreateContextReductionLatchandresetContextReductionLatch;shouldApplyContextReductionoptionally accepts a latch. Stateless callers are unchanged; pass a latch to keep stable reduction across requests.session_compactand onsession_treenavigation; rejected compaction does not reset. Preserves provider-native compaction bypass while latched.packages/coding-agent/src/core/extensions/builtin/compaction/context-reduction.tsandpackages/coding-agent/src/core/extensions/builtin/compaction/index.ts.Written for commit 231d467. Summary will update on new commits.