Repository navigation
fix(gateway): avoid loading inactive worker history - #145591
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 12, 2026, 12:27 AM ET / 04:27 UTC. ClawSweeper reviewWhat this changesWorker-turn preparation uses existing selected-history readers to avoid retaining inactive transcript payloads, with regression coverage for input ordering, branch ancestry, and cancellation. Merge readiness✅ Ready for maintainer review The allocation repair remains useful: both inspected main and the latest release still load the full transcript during worker preparation. No blocking defect was found in the introduced changes, and the maintainer-authored PR is protected from cleanup. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway prepares conversation history and the current input before launching an OpenClaw worker. Its transcript reader supplies the history and base leaf used to assemble the worker request while durable transcripts remain Gateway-owned. flowchart TD
A[Admitted worker turn] --> B{Input persistence state}
C[Gateway transcript] --> D[Selected history reader]
B -->|Already persisted| D
B -->|Recorder pending| D
B -->|Unrecorded input| E[Writable transcript reader]
D --> F[Validate current turn after async read]
E --> G[Prepare history and base leaf]
F --> G
G --> H[Launch worker]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +20, Tests +644. Total +664 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep transcript selection with the existing reader owner while preserving canonical input persistence, exact branch ancestry, and live admission checks. Do we have a high-confidence way to reproduce the issue? Yes, from source: prepare a worker turn on a short selected branch with substantial inactive history; current main opens the full transcript before credential preparation. This review did not execute that scenario. Is this the best way to solve the issue? Yes. Reusing the selected-context readers fixes allocation at its producer without changing storage, while retaining the writable path where append custody is required. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 366335ad9cd6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Classify recognized file suffixes before free-form artifact kind hints so metadata cannot turn logs or JSON into media without previews. Preserve the complete kind label and existing fallback for unknown or extensionless files. Make the path-redaction regression deterministic and cover conflicting media hints, existing fallback behavior, and the real HTTP gallery response. Related: #145591
Classify recognized file suffixes before free-form artifact kind hints so metadata cannot turn logs or JSON into media without previews. Preserve the complete kind label and existing fallback for unknown or extensionless files. Make the path-redaction regression deterministic and cover conflicting media hints, existing fallback behavior, and the real HTTP gallery response. Related: #145591
Classify recognized file suffixes before free-form artifact kind hints so metadata cannot turn logs or JSON into media without previews. Preserve the complete kind label and existing fallback for unknown or extensionless files. Make the path-redaction regression deterministic and cover conflicting media hints, existing fallback behavior, and the real HTTP gallery response. Related: openclaw#145591
What Problem This Solves
Fixes unnecessary Gateway memory use when cloud-worker turns begin in sessions with inactive transcript branches. Preparing a small active conversation loaded and retained the physical transcript's inactive message payloads while credentials, workspace media, and skills were prepared.
Why This Change Was Made
Use the existing selected model-context readers for recorder-owned or already-persisted input. A pending recorder keeps the synchronous read-before-persist ordering, so its own append cannot invalidate an asynchronous snapshot. Already-persisted input uses the asynchronous reader and revalidates the caller, cancellation, exact placement claim, and current transcript identity after the read.
Unrecorded input keeps its writable SessionManager, preserving captured append ancestry, conflict handling, and writer custody. The completion reader and recorder-race fallback remain unchanged. No schema, retention, or transcript-commit recovery contract changes.
User Impact
Worker turns stop retaining inactive message payloads during this preparation phase while keeping the same active history and current-input/base-leaf behavior. This is a bounded allocation repair, not a claim that all Gateway memory pressure or stalls are resolved.
Evidence
Both permanent 64-row tests fail on the unmodified producer because it hydrates 64 inactive 1 KiB messages, then pass with zero inactive payloads. The active conversation remains four messages for already-persisted input or three before recorder-owned persistence. The earlier 512-row diagnostic measured roughly 614 KB of serialized loaded payload versus under 600 bytes for the selected reader; that is a payload proxy, not a retained-heap or RSS measurement.
All 10 focused tests pass on the current candidate. They cover input/history/base-leaf parity, split logical/append leaves, canonical persistence already in flight or begun after snapshot acquisition, and cancellation, claim loss, caller revocation, and session rebinding during the asynchronous read. Existing launcher/media/handoff and SessionManager owner suites previously passed 124 tests on the integration base.
Independent P0-P2 review is clean. The revised Blacksmith wire proof passed two authenticated chat turns, history-prefix/input/base-leaf checks, completed supervisor receipts, and joined cleanup; the owned lease is completed. The native synced proof verified both producer hashes, the harness, tests, and lockfile before its build (Node 24.19.0). Its delegated checkout metadata follows the hydrated main; exact-head CI is tracked separately on this PR.
The campaign wire harness remains private rather than duplicating the maintained service suite. It uses a loopback mock provider and a separate authenticated operator.read/operator.write client; it does not establish real-provider behavior or multi-profile membership semantics. The final native changed checks passed, including typechecking, lint, dead-code and repository guards.
Exact-head CI passed after one qualified rerun of the unchanged QA gallery shard. A temporary path containing
gifdeterministically reproduces its log-as-image classification failure; the original CI failure is retained and the unrelated gallery repair is tracked separately.