Repository navigation
fix: prevent compaction worker OOM on large session histories - #194536
Conversation
Stream selected compaction payloads through the acknowledged hydration transport instead of retaining the complete payload graph in the transcript worker. Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: a8d89037-eea4-4dff-bad6-38b73565346c
|
🦞👀 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. What this changesThis PR streams selected compaction payloads through the existing hydration transport instead of retaining their complete decoded contents in the worker. Example: A cold session contains 33,000 messages of 15,000 characters each.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete compaction allocation defect that remains on main, both previous findings are fixed, and no new actionable defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCompaction requests a complete semantic transcript window from the history worker; SQLite supplies selected records, acknowledged chunks carry their payloads to the host, and the host reconstructs the existing context result for the compactor. flowchart LR
A[Compaction request] --> B[Existing context selector]
B --> C[Selection metadata]
C --> D[Snapshot payload stream]
D --> E[Host completeness and ordering]
E --> F[Existing compactor]
Technical reviewBest possible solution: Retain the existing complete-context selection policy while transferring selected payloads through its existing acknowledged transport. Do we have a high-confidence way to reproduce the issue? Current-main source retains every selected decoded payload when compaction disables replay limits, matching the PR's reported cold-Gateway OOM reproduction; no target code was executed during this read-only review. Is this the best way to solve the issue? The change fixes the owning allocation boundary without truncating compaction input, increasing heap limits, or introducing another selector, cache, or persistence owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f01b0aae3cfc. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +119, Tests +62, Other +114. Total +295 across 10 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 8, 2026, 2:19 AM ET / 07:19 UTC (Revision 2). |
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 12f6f8de-6a33-4c77-806e-36a038852180
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Reuse the reset lifecycle regression for full streamed snapshot parity and abandoned-branch exclusion. Remove duplicated transport setup and its allocation so the PR adds no net test lines even when the base has existing ratchet debt. Co-authored-by: RomneyDa <[email protected]>
…aw#194536) * fix: prevent compaction worker OOM on large session histories Stream selected compaction payloads through the acknowledged hydration transport instead of retaining the complete payload graph in the transcript worker. Co-authored-by: RomneyDa <[email protected]> * fix: prevent compaction worker OOM on large session histories OpenClaw-Publication: a8d89037-eea4-4dff-bad6-38b73565346c * fix: address compaction streaming review regressions Co-authored-by: RomneyDa <[email protected]> * Publish openclaw/sqlite-oom-repro-fix OpenClaw-Publication: 12f6f8de-6a33-4c77-806e-36a038852180 * test: consolidate compaction streaming coverage Reuse the reset lifecycle regression for full streamed snapshot parity and abandoned-branch exclusion. Remove duplicated transport setup and its allocation so the PR adds no net test lines even when the base has existing ratchet debt. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]>
Adapt approved #194536 to the release ancestry owner without importing background-result dependencies or persisted active facts. Plan the complete semantic window using lightweight metadata, then stream its selected payloads through the acknowledged transport in the same read snapshot. Validate exact selected sequences and counts before restoring semantic event order. Bound PostgreSQL planning queries because its iterator buffers results; keep SQLite cursor reads and preserve indivisible oversized events. Reuse the reset lifecycle and real manual/budget compaction regressions. (cherry picked from commit 7cfc564) Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Related: #191847
Problem and solution
Large transcripts can exhaust the compaction worker before the next agent turn. Complete compaction intentionally disables bounded-replay limits; the previous selector parsed and retained every selected payload in a worker-side Map.
The existing selector now produces a payload-free compaction plan, retaining ancestry/selection metadata and at most two full anchors for existing predicates. Selected payloads stream through the existing acknowledged hydration transport under the same read snapshot. The host verifies completeness and reconstructs semantic sequence order before returning the existing bounded result. Ordinary bounded hydration and cold-archive restoration retain their owners.
The heap rig adds a synthetic single-session fixture and cold-restart path for real Gateway RPC reproduction. No heap-limit increase, new configuration, schema migration, retention change, release, or backport is included.
Original reproduction and evidence
efb980423985b290f5c294ba7b13ad4c2bd074d8. At initial publication, the eight files matched the validated/reviewed snapshot (working-patch SHA-256a6fa353076c61612fd4a73a2a2ce05b4b7e0a1b832d22cb23f8bf74c0c6af9f3). Follow-up changes are recorded separately below.ERR_WORKER_OUT_OF_MEMORY; attribution observed 516,952,160 bytes of worker heap before failure.chat.send/agent.waitturns with verified 8,192-byte mock replies, and one minute of UI/status/history/catalog/subscription RPC workload. Harness and Gateway exited successfully. Compaction took 2,610 ms; sampled worker heap reached 104,388,736 bytes (99.55 MiB), with the same effective 560 MiB V8 / 512 MiB old-generation setting.git diff --checkpassed. Default test-lint preparation refused external dependency links; the owning core-config targeted lint passed without bypassing safeguards or reinstalling shared dependencies.Review follow-up — November 8, 2026
eventCount, retaining the nine-current-entry and obsolete-history assertions; enforce exact completed-turn counts only for finite requests, while rejecting duration runs with no completed turns.6/Infinity. The database-worker ratchet failed at167 -> 168before the anchor change and passes at167 -> 167afterward.compact.delegate, bounded-context, hydration-worker, and cache-TTL-prefix suites. Core and expanded focused-test typechecks, four-file targeted lint, formatting, script syntax, and diff checks passed.result.json: duration mode completed six turns; finite mode completed exactly two. Both used ten synthetic history events and verified 8,192-byte mock replies. These validate the harness fix, not a repeat of the large-history allocation benchmark.gateway-fresh-visit.http.e2e.test.ts:204(expected diagnostic heading not visible within 15 seconds). This is outside the changed files; it remains recorded, not classified as a baseline failure or silently waived.CI follow-up — November 9, 2026
cafd67afbb96b26146d714ffa38d5822182f5a64consolidates the standalone streaming test into the existing reset/compaction lifecycle regression. Five stages now compare the complete worker-hydrated snapshot with synchronous selection, including a persisted branch that excludes an abandoned message. Existing delegate tests retain large-payload and explicitstreamed-boundedcoverage. No production code or ratchet policy changed.d5e6ac43282256eb2085aff930402555109cbc60against basef01b0aae3cfcb426c703e9313a3bcb5693e33d2e: before, 6,574,514 lines versus a 6,574,502 ceiling with delta +65; after applying this patch, delta 0 and the ratchet passes despite the inherited 12-line debt. No baseline increase or exception was added.290e3d5dd5581b5309947311cd20dc3380789958reports no findings and confirms the earlier two issues are fixed. There are no inline review comments. That hosted review predates this test-only follow-up; new-head CI is not claimed green.Limits and remaining proof gap
This is a worker-allocation fix, not constant-memory summarization: the host still reconstructs the full selected context. In the original successful reproduction, observed main heap reached 2,330.26 MiB and whole-process RSS reached 4,477.75 MiB. One exceptionally large row can still exhaust worker memory while decoded.
Evidence is an isolated real Gateway with a mock model, not live-model/channel or Raspberry Pi proof. Live-provider preflight was blocked by missing approved portable authentication; host file-backed credentials were not copied. Live-model qualification requires an operator-approved portable credential source. No unrelated rebase was performed; publication remains an open PR, not a merge.