Repository navigation
fix(compaction): show the summarizer the audited latest ask - #130620
Conversation
The safeguard reads the latest user ask from the pre-partition window but only feeds the summarizer the partitioned messages. When recentTurnsPreserve keeps the ask verbatim and the preserved suffix is head-truncated, the producer can never reflect it, so every attempt fails latest_user_ask_not_reflected and compaction cancels, leaving the session stuck at the context limit. Hand the bounded ask to the summarizer as untrusted data on every attempt so the guard only demands what the producer was shown.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 12:07 AM ET / 04:07 UTC. ClawSweeper reviewWhat this changesThe PR carries terminal completion state into compaction summary retention and validation so completed latest requests are not retained as pending work, and makes a lazy Control UI panel test await its render. Merge readinessKeep open for normal merge review. The requested completion-state fix is present at the compaction quality boundary and the prior P1 scenario is covered; no new blocking correctness defect was found. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherCompaction turns older agent conversation into a structured checkpoint that later turns consume. The safeguard partitions context, generates or retains a summary, audits its required facts, and writes the resulting session context. flowchart LR
A[Conversation history] --> B[Context partitioning]
B --> C[Compaction summary]
C --> D[Quality audit]
D --> E[Retained checkpoint]
E --> F[Later agent turn]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +41, Tests +167. Total +208 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep completion state on the existing compaction-quality boundary and merge after the exact-head checks complete. Do we have a high-confidence way to reproduce the issue? No live current-main replay was performed in this read-only review, but the focused handler-level regression provides a high-confidence source reproduction of the completed request being treated as pending. Is this the best way to solve the issue? Yes. The completion fact is captured with the latest turn and consumed by the existing retention and audit owner rather than inferred from summary prose downstream. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 35630bf1dfba. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]>
Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]>
0a545b7 to
0093a7f
Compare
|
@clawsweeper re-review The P1 completion-state finding is addressed on
Local proof: compaction safeguard 141/141, sidebar attention 33/33, full changed-file gate clean, and structured autoreview clean. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]>
|
@clawsweeper re-review Live Gateway proof and the split-turn repair are now on exact head
Local proof: Agent Core 45/45, compaction safeguard 142/142, complete |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…#130620) * fix(compaction): show the summarizer the audited latest ask The safeguard reads the latest user ask from the pre-partition window but only feeds the summarizer the partitioned messages. When recentTurnsPreserve keeps the ask verbatim and the preserved suffix is head-truncated, the producer can never reflect it, so every attempt fails latest_user_ask_not_reflected and compaction cancels, leaving the session stuck at the context limit. Hand the bounded ask to the summarizer as untrusted data on every attempt so the guard only demands what the producer was shown. * fix(compaction): preserve latest turn context Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> * test(ui): await lazy attention panel render Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> * fix(compaction): audit completed split turns Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: roboclaw-bot <[email protected]>
What Problem This Solves
A long tool-heavy turn could hit the context limit and then fail both automatic and manual compaction with
latest_user_ask_not_reflected. The quality guard audited the latest user request from the pre-partition window, while recent-turn preservation removed that request—and sometimes its completing assistant response—from the messages given to the summarizer. If the bounded verbatim suffix then dropped the request, the guard demanded a fact the producer never saw and cancelled compaction.The original patch handed only the bounded request to the summarizer. Autoreview found that an all-preserved window could still skip the summarizer and that request-only context could resurrect completed work. ClawSweeper then found the remaining inverse: even with the full turn visible, an accepted summary could still list a completed request under
## Pending user asks.Final live Gateway proof exposed one more boundary: when the retention cut split a long completed turn, the summarizer saw only its prefix while the terminal assistant response stayed in the retained suffix. The audit therefore treated the boundary request as unresolved and accepted a split-turn summary that revived it under pending work.
Why This Change Was Made
The quality producer receives the full prepared context whenever it is already generating a summary. An all-preserved window remains model-free when its audited request survives verbatim; if bounded preservation would hide the request, the same prepared context is summarized instead of returning a doomed fallback.
For genuine split turns, Agent Core now records whether that exact cut turn completes in its retained suffix. The safeguard carries that cut-scoped fact into retention and audits every generated
## Pending user askssection, including the separately generated split-turn summary. A bad first summary is rejected with a concrete reason and corrected within the existing bounded retry. Non-split turns keep their existing local completion inference.This keeps the quality guard fail-closed, preserves the bounded verbatim suffix, and avoids treating user text as prompt authority. No config, schema, protocol, or default changes are introduced.
The first exact-head CI run also exposed an unrelated flaky UI test. Product code was unaffected: the test hit Vitest's 1-second wait timeout while the attention panel awaited a lazy import. The test now joins that import and then awaits Lit's update before asserting the same top-layer menu ancestry. No timeout was increased and no assertion was weakened.
User Impact
Sessions whose latest user turn is preserved behind a long tool chain—or split across the retention cut—can compact instead of cancelling or reviving completed work. Accepted checkpoints cannot mark a successfully completed latest turn as pending.
Evidence
Live Gateway proof
8e62635fd626e69da80179777a0b1de4e9cf0356## Pending user asks.None.; the completed request and/tmp/pr130620/live/markerremained under non-pending context.cbx_3381f0b0b953was destroyed after artifact collection.Regression proof
## Pending user asks; the repaired owner rejects it and accepts only the corrected checkpoint.Local verification
node scripts/run-vitest.mjs packages/agent-core/src/harness/compaction/compaction.test.ts src/agents/agent-hooks/compaction-safeguard.test.ts— 45/45 core and 142/142 safeguard passednode scripts/run-vitest.mjs ui/src/components/sidebar-attention.test.ts— 33/33 passed on the prior exact head; the UI file is unchanged by the split-turn repairnode scripts/check-changed.mjs— formatting, core/core-test typecheck, lint, dead-code, architecture, import-cycle, guard, and UI i18n lanes passedCI diagnosis
Initial run
33034247213failed onlychecks-node-compact-large-11inui/src/components/sidebar-attention.test.ts; the assertion timed out at 1009 ms while awaiting the lazy panel module. All compaction checks and the focused ClawSweeper proof passed on that head. Run33038123439completed green on the prior repaired head. Exact-head CI for8e62635fd626e69da80179777a0b1de4e9cf0356is tracked separately before merge.Scope
The production growth carries one cut-scoped completion fact through the existing Agent Core preparation contract and adds the missing generated-section audit. There is no parallel compaction path or compatibility surface.
What was not tested
No replay of the reporter's private ~255k-token gateway transcript was performed. The live proof uses the real Gateway/session/CLI/persistence path with deterministic provider responses so the bad-first-summary/corrective-retry boundary is reproducible; it is not external-provider proof.
Worked on by