Repository navigation
fix: stop transcript storms during context overflow recovery - #147202
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 1:40 PM ET / 17:40 UTC (Revision 2). ClawSweeper reviewWhat this changesBounds overflow recovery to the model’s current context, prevents archived tool results from triggering transcript copies, and adds regression coverage plus an asynchronous test-cleanup fix. Merge readiness✅ Ready for maintainer review The prior budget finding is addressed, and no new blocking defect was found. Current main still contains the archive-wide recovery path, so this protected PR remains useful. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw’s embedded agent retries context-overflow failures by compacting conversation history and trimming tool output. Recovery reads the SQLite transcript and publishes changes through the existing atomic rewrite owner before retrying inference. flowchart TD
A[Context overflow] --> B[Compaction recovery]
C[Resolved model budget] --> D[Bounded transcript reader]
B --> D
D --> E[Current context selection]
E --> F[Tool output truncation]
F --> G[Atomic transcript publication]
G --> H[Retry inference]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +13, Tests +86, Docs +2, Other 0. Total +101 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use one bounded model-context view for attempts and recovery while preserving archived transcript bytes and existing atomic publication safeguards. Do we have a high-confidence way to reproduce the issue? Yes: current main selects historical tool results from the raw branch, allowing the suffix rewrite to copy archived turns and resets; the supplied SQLite regressions exercise that mechanism. This review did not execute them. Is this the best way to solve the issue? Yes: reusing the canonical context iterator and the attempt’s existing hydration limits repairs the selection boundary without adding a second rewrite mechanism or changing retention. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f96fed1a7cc0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
bfec2ce to
1367c22
Compare
|
@clawsweeper re-review Updated head: Addressed the effective-budget finding: every recovery reader now receives the resolved model budget. A 200k-token / 1.2 MB tool-result regression fails on the initial PR and passes after the correction. All 93 recovery tests, core and affected test typechecks, changed-file lint, and fresh independent review pass. Added the requested scale evidence and repeatable probe to the PR body: real SQLite with 1,700,007 synthetic entries recovered in 3,869.54 ms, appended 4 entries, copied 0 resets, and preserved every original row digest. This is one cold synthetic sample; the separate repeated before/after benchmark is 176.36 ms versus 29.82 ms median. No production latency equivalence is claimed. A separate test-only commit awaits Workboard cleanup introduced by #147191, which caused the first CI run's sole failure. The affected test and plugin lint pass locally. No merge or autofix requested. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* commit '201f11afefdb19a9c75e9d3542bf7425c80df7a7': (141 commits) fix: keep catalog discovery scoped and execution lazy (#147159) fix: serialize reclamation worker shutdown with foreground writes (#147178) test(sessions): cover abrupt committed transcript recovery (#143984) fix: stop transcript storms during context overflow recovery (#147202) fix: reduce CPU overhead for small history and usage reads (#147205) fix: resume tasks after tools finish and the model times out (#147203) refactor(scripts): share SQLite reliability message waits (#146900) feat(exec): configure approval reviewer thinking and fastMode (#147192) test: remove redundant Bonjour module headers (#146981) refactor: share streaming media tail boundary update (#146989) refactor(tui): classify resume candidates once (#146983) improve: skip unused toast dismissal work (#147196) fix(linux): recover saved remote connections without replacing active sessions (#146047) fix: doctor stays silent when Windows state dir is under OneDrive (#123720) feat: announce successful Daybreak retries (#147146) feat(code-mode): reuse results across code cells (#147154) refactor(test): reuse CLI plugin fixture writer (#147186) test: skip unused compiler setup in routing fixtures (#147194) test: reuse LINE webhook runtime fixture (#146710) fix(code-mode): check automation and process result types (#147143) ...
* commit '2d87daf04b78992382299d552f15ac84a86a23ed': (1815 commits) fix(ui): distinguish tool activity with semantic icons (#147207) fix(linux): recover completed Quick Chat replies without resending (#146048) feat(desktop): unify Tauri title bar and window controls (#147097) refactor(test): share plugin fixture server shims (#147225) perf(gateway): defer worker workspace execution imports (#143496) fix(gateway): post-ack webhook work fails with "Async work scope is closed" (#144801) refactor(scripts): centralize upgrade survivor version floors (#146975) fix(ci): check publication registries before FRV fanout (#147184) fix(qa): align system-agent delegation with channel contracts (#145905) improve: reduce repeated chat message identity work (#147210) fix(channels): remove stale pre-tool previews from Slack and Telegram (#147106) fix: keep catalog discovery scoped and execution lazy (#147159) fix: serialize reclamation worker shutdown with foreground writes (#147178) test(sessions): cover abrupt committed transcript recovery (#143984) fix: stop transcript storms during context overflow recovery (#147202) fix: reduce CPU overhead for small history and usage reads (#147205) fix: resume tasks after tools finish and the model times out (#147203) refactor(scripts): share SQLite reliability message waits (#146900) feat(exec): configure approval reviewer thinking and fastMode (#147192) test: remove redundant Bonjour module headers (#146981) ...
…w#147202) * fix: stop transcript storms during context overflow recovery * test: await Workboard cleanup after attachment race * fix: use resolved model budgets during overflow recovery --------- Co-authored-by: VACInc <[email protected]>
Summary
High Level TLDR
Fixes transcript storms and long Gateway stalls when context-overflow recovery trims tool results in a session with retained history.
What Problem This Solves
A small recovery edit could copy almost the entire session archive, including historical reset markers, into fresh transcript entries. In the observed incident, recovery copied about 1.67 million entries and held a synchronous database write for 924 seconds.
User Impact
Long-running conversations can recover from context overflow without duplicating archived turns or reset markers. Existing history remains readable. This prevents new amplification; it does not delete previously duplicated records or change retention, schemas, configuration, or permissions.
Why This Change Was Made
Root Cause
Recovery opened an unbounded SessionManager, unlike normal attempts. The truncation planner then consumed the raw branch instead of the canonical model-context window. Its earliest historical replacement made the existing atomic branch rewrite copy the entire remaining suffix.
Recovery now shares the normal attempt hydration limits using the resolved model budget, and truncation selects entries through the existing model-context iterator. This preserves the established reset-retention and compaction rules and retains the existing atomic publication and writer-authority checks.
Verification
Real behavior proof
The regression uses a synthetic context engine with real SQLite storage, run admission, writer claims, overflow recovery, compaction publication, truncation, and independent reopen reads. It covers successful compaction, failed-compaction fallback, a compacted context that needs no truncation, and a 200k-token resolved model budget with 1.2 MB of current tool output.
On the original production code, all four added regression cases fail: archived reset counts double, and archive-only oversized output causes unnecessary transcript copies. The larger-budget case separately fails on the initial PR revision because recovery omits the eligible tool output and surfaces overflow. With the fix, original row digests remain unchanged, reset counts stay constant, current tool output shrinks when needed, and recovery returns
retry. The default fixture output fits normal attempt hydration while still exceeding the truncation threshold.Evidence
check-changedpass covered core/test typechecks, lint, dead exports, and repository guards. After the review correction, core typechecking, the affected agent test type graph, and type-aware lint for all changed production/test files passed again.git diff --checkpassed.Full benchmark process peak RSS was 2,345 MiB before and 2,361 MiB after, including test compilation/setup; no peak-memory reduction is claimed. The measured recovery improvement is approximately 83% on this fixture, not a production latency projection.
Repeatable benchmark probe
Save this temporary test beside
run.compaction-runtime.test-support.ts, then run it withOPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs <test-path>. Compare the PR production files with their base versions while keeping this fixture unchanged. Remove the temporary test afterward.Incident-scale synthetic archive
A separate real-SQLite probe seeded 1,700,007 transcript entries through
replaceTranscriptEvents, ran actual overflow recovery, then independently reopened storage and compared every original row digest. Recovery took 3,869.54 ms, appended 4 entries, and copied 0 historical resets. All existing row digests matched. This was one cold sample; the small repeated benchmark above supplies the before/after comparison. Seeding and full-archive verification are excluded from recovery timing.Repeatable large-archive probe
Save this temporary test beside the recovery fixture and run it with one worker using the same Vitest command as above. It uses synthetic text and isolated test storage; remove the probe afterward.
CI repair
The first hosted run passed the core lint stripe but failed extension lint on an unawaited async Workboard test cleanup introduced by #147191 in the merge base. A separate one-line test-only repair awaits
harness.close(). The affected concurrency test and type-aware plugin lint pass locally. No Workboard production behavior changes.What was not tested
No production Gateway restart or live provider/channel replay was performed. The private incident archive was not copied into a test environment; the 1.7-million-entry synthetic archive matches its order of magnitude, not its exact payloads or disk/cache state. The fix uses the existing supported storage and update paths; no migration or operator action is required after installation.