Repository navigation
fix: let large sessions compact again after 2026.11.10 - #205783
Conversation
Compaction preparation runs in the session history worker. Two limits stopped large, image-heavy sessions from compacting: - Manual compaction hands the Gateway preflight facts back to the worker in the plan request. The request was charged as UTF-16 JSON (JSON.stringify(input).length * 2), several times the structured clone that actually crosses the thread boundary, so a window whose facts clone to ~110 MB was charged ~450 MB and refused outright by the pool's 256 MiB pending-bytes cap. Charge the preflight source by its v8.serialize size instead; the rest of the request keeps the existing JSON estimate. - Every preparation task (preflight, plan, render, finalize) used the default 60 s worker read deadline, so the budget path, which re-reads and decodes the whole window in one task, timed out on every turn. Thread the configured compaction timeout (agents.defaults.compaction.timeoutSeconds, via resolveCompactionTimeoutMs) into readPreparedCompaction. Refs openclaw#205752
|
🦞👀 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. |
- Charge every compaction-preparation request by its v8 structured-clone size instead of splitting plan facts from a UTF-16 JSON estimate of the rest. - Narrow the reader regression to the admission charge; the compaction-timeout forwarding keeps its integration test.
|
Codex review: needs real behavior proof before merge. What this changesThis PR changes compaction-facts request sizing and gives preparation reads the existing configured compaction timeout. Example: A large session produces a 445,943,294-byte JSON estimate with compaction.timeoutSeconds set to 600.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR addresses two concrete compaction failures still present on current main, and no introduced correctness defect was found. Reviewed head: Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway manual compaction and embedded automatic compaction send transcript preparation requests through the session-history reader to a worker; prepared plans, rendered context, and finalization facts return to the existing compaction owner. flowchart TD
A[Manual compaction] --> C[Compaction preparation owner]
B[Automatic compaction] --> C
C --> D[Session history reader]
D --> E[Worker admission and deadline]
E --> F[Transcript preparation worker]
F --> G[Summary and guarded persistence]
Technical reviewBest possible solution: Keep the compaction-specific sizing repair and propagate the existing timeout through preparation while preserving worker admission limits. Do we have a high-confidence way to reproduce the issue? The reported failures are source-reproducible: manual preflight facts reach JSON-based admission sizing, while preparation inherits a separate 60-second deadline; this read-only review ran no target code. Is this the best way to solve the issue? The repair fits the existing owners and addresses both limits without raising shared capacity or introducing configuration; retaining the existing facts-transfer design keeps the fix bounded. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 92d40cbd9821. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +34, Tests +109. Total +143 across 8 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. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed November 26, 2026, 1:10 AM ET / 06:10 UTC. |
|
Gateway proof on the exact head |
|
Maintainer override: the only red is |
|
Merged in ec31b90. Thanks @jredbeard for the report in #205752 and the fix. Manual compaction of very large, image-heavy sessions works again: the worker request is now charged by its real serialized size, so it no longer hits the 256 MiB limit just because of its JSON estimate. Compaction preparation now also uses |
Root cause: `src/config/sessions/session-transcript-worker-readers.ts:366-372` (on main) charged compaction-preparation requests as `JSON.stringify(input).length * 2` and passed no request options, so a manual plan carrying Gateway preflight facts was refused by the history pool's 256 MiB pending-bytes cap (`packages/worker-runtime/src/worker-task-capacity.ts:2`), and every preparation read fell back to the 60 s default in `session-transcript-worker-runtime.ts:183`. Fixes #205752 Thanks @jredbeard for the report, the root-cause trace and this fix. ## What Problem This Solves Since 2026.11.10 (#201304), long-running sessions with a lot of history (the report: a Slack channel session at ~835k tokens, ~415 MB since the last compaction, ~1,460 images) can't be compacted. Manual `openclaw sessions compact` fails with `worker task capacity reached [... pool pending bytes ... inputBytes=445943294]`, and budget compaction can fail with `worker task timed out` after 60 s on every turn on slower hosts. ## Why This Change Was Made 1. **Manual path, refused for size.** The Gateway preflight returns per-entry compaction facts for the whole active window and the plan request sends them back to the history worker (so planning does not extract the window twice). The reader charged that request as UTF-16 JSON: about 4.7x the structured clone that actually crosses the thread boundary, and it built a string as large as the window on the Gateway thread. `readPreparedCompaction` now charges the request by its `v8.serialize` byte length, the serializer the worker transport uses. The facts still travel and are still charged; the 256 MiB cap is unchanged and still refuses genuinely oversized requests. 2. **Preparation deadline.** Preflight, plan, render and finalize reads used the 60 s default worker read deadline regardless of `agents.defaults.compaction.timeoutSeconds`. The Gateway runner and the embedded compaction owner now pass the existing `resolveCompactionTimeoutMs(config)` (default 180 s) to those reads, the way `readTrajectoryRetention` already takes a caller-owned `timeoutMs`. Caller abort signals still apply. No config, schema or stored-data changes. ## Evidence Built Gateway, merge base vs this head, seeded session the size of the report (37,801 events, 413.7 MB transcript, 1,500 distinct base64 PNG tool results): #205783 (comment) - Manual: main refused twice (`worker task capacity reached ... inputBytes=828669298`, 7 s); this head compacted twice in 15 s (21,870,587 -> 20,708 tokens). - Preflight facts measured 174 MB as a structured clone vs 828 MB charged before. A plan with twice those facts (349 MB) is still refused with the same capacity error on this head; on main the JSON estimate throws `RangeError: Invalid string length` first. - Budget path: at the report's size preparation took ~8 s on this host on both main and this head, so the 60 s timeout did not reproduce here. The timeout change is covered by the integration regression in `compact.summary-fallback.test.ts` (red on main, green here). - Small session: unchanged on both (10,926 -> 1,140 tokens). - Regressions: `session-transcript-worker-readers.test.ts` (plan facts charged at least their clone and under the old estimate) and `compact.summary-fallback.test.ts` (`timeoutSeconds: 600` reaches every preparation read), both red on main. Production +18/-2, tests +103 against the merge base. ## Merge danger Two-way door: a revert restores the old charge and the 60 s deadline; nothing is written or migrated. Blast radius: compaction-preparation reads only (Gateway manual compaction and embedded compaction). Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit ec31b90) Release adaptation: Git merged the Gateway import hunk into the release layout cleanly; no production or test behavior was adapted. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
|
Awesome - thanks for taking it seriously and merging @obviyus! Glad to help |
…one fail open (#205687) Report private flush output as progress without forwarding content. Time out only the stalled flush, count the failure under the existing policy, and allow compaction and the reply to continue. Let compaction report its own deadline before the reply watchdog backstop. Release adaptation: preserve the release session-store routing and queued follow-up refresh imports, and omit the unrelated harness artifact spelling refactor. The stall guard uses only the watchdog progress contract; document the reply behaviour. The large-transcript compaction worker fix (#205783) is already in the parent line and remains intact. Companion audit found no later same-path or PR/SHA follow-up on pinned main. (cherry picked from commit 26f82df) Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Root cause: `src/config/sessions/session-transcript-worker-readers.ts:366-372` (on main) charged compaction-preparation requests as `JSON.stringify(input).length * 2` and passed no request options, so a manual plan carrying Gateway preflight facts was refused by the history pool's 256 MiB pending-bytes cap (`packages/worker-runtime/src/worker-task-capacity.ts:2`), and every preparation read fell back to the 60 s default in `session-transcript-worker-runtime.ts:183`. Fixes openclaw#205752 Thanks @jredbeard for the report, the root-cause trace and this fix. ## What Problem This Solves Since 2026.11.10 (openclaw#201304), long-running sessions with a lot of history (the report: a Slack channel session at ~835k tokens, ~415 MB since the last compaction, ~1,460 images) can't be compacted. Manual `openclaw sessions compact` fails with `worker task capacity reached [... pool pending bytes ... inputBytes=445943294]`, and budget compaction can fail with `worker task timed out` after 60 s on every turn on slower hosts. ## Why This Change Was Made 1. **Manual path, refused for size.** The Gateway preflight returns per-entry compaction facts for the whole active window and the plan request sends them back to the history worker (so planning does not extract the window twice). The reader charged that request as UTF-16 JSON: about 4.7x the structured clone that actually crosses the thread boundary, and it built a string as large as the window on the Gateway thread. `readPreparedCompaction` now charges the request by its `v8.serialize` byte length, the serializer the worker transport uses. The facts still travel and are still charged; the 256 MiB cap is unchanged and still refuses genuinely oversized requests. 2. **Preparation deadline.** Preflight, plan, render and finalize reads used the 60 s default worker read deadline regardless of `agents.defaults.compaction.timeoutSeconds`. The Gateway runner and the embedded compaction owner now pass the existing `resolveCompactionTimeoutMs(config)` (default 180 s) to those reads, the way `readTrajectoryRetention` already takes a caller-owned `timeoutMs`. Caller abort signals still apply. No config, schema or stored-data changes. ## Evidence Built Gateway, merge base vs this head, seeded session the size of the report (37,801 events, 413.7 MB transcript, 1,500 distinct base64 PNG tool results): openclaw#205783 (comment) - Manual: main refused twice (`worker task capacity reached ... inputBytes=828669298`, 7 s); this head compacted twice in 15 s (21,870,587 -> 20,708 tokens). - Preflight facts measured 174 MB as a structured clone vs 828 MB charged before. A plan with twice those facts (349 MB) is still refused with the same capacity error on this head; on main the JSON estimate throws `RangeError: Invalid string length` first. - Budget path: at the report's size preparation took ~8 s on this host on both main and this head, so the 60 s timeout did not reproduce here. The timeout change is covered by the integration regression in `compact.summary-fallback.test.ts` (red on main, green here). - Small session: unchanged on both (10,926 -> 1,140 tokens). - Regressions: `session-transcript-worker-readers.test.ts` (plan facts charged at least their clone and under the old estimate) and `compact.summary-fallback.test.ts` (`timeoutSeconds: 600` reaches every preparation read), both red on main. Production +18/-2, tests +103 against the merge base. ## Merge danger Two-way door: a revert restores the old charge and the 60 s deadline; nothing is written or migrated. Blast radius: compaction-preparation reads only (Gateway manual compaction and embedded compaction). Co-authored-by: Ayaan Zaidi <[email protected]>
Root cause: `src/config/sessions/session-transcript-worker-readers.ts:366-372` (on main) charged compaction-preparation requests as `JSON.stringify(input).length * 2` and passed no request options, so a manual plan carrying Gateway preflight facts was refused by the history pool's 256 MiB pending-bytes cap (`packages/worker-runtime/src/worker-task-capacity.ts:2`), and every preparation read fell back to the 60 s default in `session-transcript-worker-runtime.ts:183`. Fixes #205752 Thanks @jredbeard for the report, the root-cause trace and this fix. ## What Problem This Solves Since 2026.11.10 (#201304), long-running sessions with a lot of history (the report: a Slack channel session at ~835k tokens, ~415 MB since the last compaction, ~1,460 images) can't be compacted. Manual `openclaw sessions compact` fails with `worker task capacity reached [... pool pending bytes ... inputBytes=445943294]`, and budget compaction can fail with `worker task timed out` after 60 s on every turn on slower hosts. ## Why This Change Was Made 1. **Manual path, refused for size.** The Gateway preflight returns per-entry compaction facts for the whole active window and the plan request sends them back to the history worker (so planning does not extract the window twice). The reader charged that request as UTF-16 JSON: about 4.7x the structured clone that actually crosses the thread boundary, and it built a string as large as the window on the Gateway thread. `readPreparedCompaction` now charges the request by its `v8.serialize` byte length, the serializer the worker transport uses. The facts still travel and are still charged; the 256 MiB cap is unchanged and still refuses genuinely oversized requests. 2. **Preparation deadline.** Preflight, plan, render and finalize reads used the 60 s default worker read deadline regardless of `agents.defaults.compaction.timeoutSeconds`. The Gateway runner and the embedded compaction owner now pass the existing `resolveCompactionTimeoutMs(config)` (default 180 s) to those reads, the way `readTrajectoryRetention` already takes a caller-owned `timeoutMs`. Caller abort signals still apply. No config, schema or stored-data changes. ## Evidence Built Gateway, merge base vs this head, seeded session the size of the report (37,801 events, 413.7 MB transcript, 1,500 distinct base64 PNG tool results): #205783 (comment) - Manual: main refused twice (`worker task capacity reached ... inputBytes=828669298`, 7 s); this head compacted twice in 15 s (21,870,587 -> 20,708 tokens). - Preflight facts measured 174 MB as a structured clone vs 828 MB charged before. A plan with twice those facts (349 MB) is still refused with the same capacity error on this head; on main the JSON estimate throws `RangeError: Invalid string length` first. - Budget path: at the report's size preparation took ~8 s on this host on both main and this head, so the 60 s timeout did not reproduce here. The timeout change is covered by the integration regression in `compact.summary-fallback.test.ts` (red on main, green here). - Small session: unchanged on both (10,926 -> 1,140 tokens). - Regressions: `session-transcript-worker-readers.test.ts` (plan facts charged at least their clone and under the old estimate) and `compact.summary-fallback.test.ts` (`timeoutSeconds: 600` reaches every preparation read), both red on main. Production +18/-2, tests +103 against the merge base. ## Merge danger Two-way door: a revert restores the old charge and the 60 s deadline; nothing is written or migrated. Blast radius: compaction-preparation reads only (Gateway manual compaction and embedded compaction). Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit ec31b90)
Root cause:
src/config/sessions/session-transcript-worker-readers.ts:366-372(on main) charged compaction-preparation requests asJSON.stringify(input).length * 2and passed no request options, so a manual plan carrying Gateway preflight facts was refused by the history pool's 256 MiB pending-bytes cap (packages/worker-runtime/src/worker-task-capacity.ts:2), and every preparation read fell back to the 60 s default insession-transcript-worker-runtime.ts:183.Fixes #205752
Thanks @jredbeard for the report, the root-cause trace and this fix.
What Problem This Solves
Since 2026.11.10 (#201304), long-running sessions with a lot of history (the report: a Slack channel session at ~835k tokens, ~415 MB since the last compaction, ~1,460 images) can't be compacted. Manual
openclaw sessions compactfails withworker task capacity reached [... pool pending bytes ... inputBytes=445943294], and budget compaction can fail withworker task timed outafter 60 s on every turn on slower hosts.Why This Change Was Made
readPreparedCompactionnow charges the request by itsv8.serializebyte length, the serializer the worker transport uses. The facts still travel and are still charged; the 256 MiB cap is unchanged and still refuses genuinely oversized requests.agents.defaults.compaction.timeoutSeconds. The Gateway runner and the embedded compaction owner now pass the existingresolveCompactionTimeoutMs(config)(default 180 s) to those reads, the wayreadTrajectoryRetentionalready takes a caller-ownedtimeoutMs. Caller abort signals still apply.No config, schema or stored-data changes.
Evidence
Built Gateway, merge base vs this head, seeded session the size of the report (37,801 events, 413.7 MB transcript, 1,500 distinct base64 PNG tool results): #205783 (comment)
worker task capacity reached ... inputBytes=828669298, 7 s); this head compacted twice in 15 s (21,870,587 -> 20,708 tokens).RangeError: Invalid string lengthfirst.compact.summary-fallback.test.ts(red on main, green here).session-transcript-worker-readers.test.ts(plan facts charged at least their clone and under the old estimate) andcompact.summary-fallback.test.ts(timeoutSeconds: 600reaches every preparation read), both red on main.Production +18/-2, tests +103 against the merge base.
Merge danger
Two-way door: a revert restores the old charge and the 60 s deadline; nothing is written or migrated. Blast radius: compaction-preparation reads only (Gateway manual compaction and embedded compaction).