Repository navigation
fix(compaction): recover overflow from sparse assistant history - #122159
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
bcd2483 to
f6490a2
Compare
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
cfffbdb to
c8b96ed
Compare
|
Codex review: found issues before merge. Reviewed August 11, 2026, 2:08 PM ET / 18:08 UTC. ClawSweeper reviewWhat this changesThis PR makes context compaction ignore sparse assistant-history rows without provider usage and adds a regression test proving that an earlier valid usage snapshot is retained. Merge readinessKeep open. Current main still dereferences a missing assistant usage block in the shared compaction scan; this branch fixes that owner boundary and adds focused regression coverage. Remove the release-owned changelog edit before merge. Priority: P1 Review scores
Verification
How this fits togetherAgent Core projects persisted session history into model context, estimates its token budget, and prepares compaction before retrying an overflowed request. Assistant usage snapshots guide that estimate, which determines whether recovery can continue. flowchart LR
A[Persisted session history] --> B[Session context projection]
B --> C[Usage snapshot scan]
C --> D{Usage present?}
D -->|Sparse row| E[Scan older assistant rows]
D -->|Explicit unavailable marker| F[Estimate transcript]
E --> G[Prepare compaction]
F --> G
G --> H[Overflow retry]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +21, Docs +1. Total +26 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Merge the narrow sparse-history guard and regression test after removing the release-owned Do we have a high-confidence way to reproduce the issue? Yes—current main reads Is this the best way to solve the issue? Yes for the runtime behavior: the guard belongs in the shared barrier classifier used by both reverse scans, preserving explicit unavailable and legacy-CLI semantics. The submitted release-note edit is not part of that fix. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2c636dda0ca4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Co-authored-by: Peter Steinberger <[email protected]>
c8b96ed to
b5a7005
Compare
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
…claw#122159) Prevent overflow recovery from dereferencing missing assistant usage metadata while preserving explicit unavailable and legacy CLI barriers. Co-authored-by: Peter Steinberger <[email protected]>
Related: #121867
What Problem This Solves
Fixes an issue where overflow recovery could crash instead of compacting when persisted or seeded assistant history contained a row without provider usage metadata.
The failure was reproduced in the exact-SHA qualification for
1383144b027a6b10c746636687182064d24b3bf9: candidate, baseline, and runtime-pair QA all failedcompaction-retry-mutating-toolafter auto-compaction threwCannot read properties of undefined (reading 'contextUsage').Qualification: https://github.com/openclaw/openclaw/actions/runs/31512918029
Why This Change Was Made
The compaction usage classifier now treats an assistant row with no usage block as sparse history and continues scanning for the preceding valid usage snapshot. Deliberate zero/unavailable context markers and legacy CLI barriers keep their existing invalidation behavior.
This is the focused mainline extraction of the compaction repair authored by @steipete in
4726adbc6339567679895a5d3d530b4ba6602eff; the earlier combined release repair landed only on a release-integration branch in #121867.User Impact
Long-running agents can recover from context overflow when history contains sparse assistant rows instead of terminating the run with an internal compaction error.
Evidence
isUnavailableContextBarrierwithundefined.contextUsage.pnpm check:changed: passed.compaction-retry-mutating-toolno longer crashes: auto-compaction succeeded, the retry performed one write, and the terminal reply completed. The scenario then reported a harness-only assertion failure because its current causal check also includes successful preflightcompaction-summaryrequests that occur before the injected overflow; no QA harness changes are included in this focused product repair.git diff --check, privacy scan, and targetedoxfmt: passed.