Repository navigation
fix(sessions): spread env for exact-entries worker reads - #158789
FkyBird1982 wants to merge 1 commit into
Conversation
- Windows platform-semantics env proxies from cloneEnvWithPlatformSemantics cannot cross the worker structured-clone boundary, so cron isolated agent turns failed at setup with DataCloneError before the model ran - spread env when preparing the exact-entries input, matching the existing readRowFacts behavior, and add a regression test
|
🦞👀 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: blocked before merge. What this changesThis PR copies the environment into a plain object before submitting exact session-entry reads to a worker. Example: An isolated agentTurn automation runs on Windows with OpenClaw 2026.9.6.
Review scores
ProductKind: Bug fix · Worth it: No · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain The repair is superseded by a merged fix, but the same author's paired issue remains open; the keep-open guard requires maintainer judgment before retiring this PR. Priority: P3 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherCron setup and session admission request session entries through the history worker, which reads SQLite and returns entries and lifecycle facts. flowchart LR
A[Automation or session admission] --> B[Exact entry reader]
B --> C[Environment snapshot]
C --> D[Worker transport]
D --> E[SQLite session read]
E --> F[Entries and lifecycle facts]
Technical reviewBest possible solution: Retain the landed storage-fact capture and coordinate retirement of this redundant PR with its paired report. Do we have a high-confidence way to reproduce the issue? The supplied Windows production traces establish the historical Proxy-transfer failure; current main captures a plain storage environment, and no current-main execution was performed. Is this the best way to solve the issue? The original snapshot addresses the demonstrated clone failure, but the landed replacement is more complete because it also handles store discovery and restores Windows environment semantics inside the worker. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f694a7e6821e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +4, Tests +34. Total +38 across 2 files. Added test files: 1. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel 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 (3 earlier review cycles)Reviewed October 10, 2026, 10:43 AM ET / 14:43 UTC (Revision 4). |
|
Independent Windows reproduction and fix verification for this PR (tracks #157067). Environment: OpenClaw 2026.9.6 (eb377ac), npm install, Node v26.7.0, Windows 11 x64. Impact observed: since upgrading to 2026.9.6, every isolated Offending field: I wrapped Fix verification: a second preload spreads
Minimal proof of the mechanism: structuredClone(new Proxy({ A: "1" }, {})); // DataCloneError
structuredClone({ ...new Proxy({ A: "1" }, {}) }); // { A: "1" }One note for review: on current |
|
Independent production verification of this exact fix shape, from a separate Windows deployment (tracks #157067 / #157986). Environment: OpenClaw 2026.9.6 (eb377ac), npm install, Node v24.16.0, Windows 11 x64, gateway as a scheduled task. Impact observed: since the 2026.9.6 upgrade, every isolated Root cause confirmed: identical to the thread — Fix verification (equivalent boundary, one layer downstream): instead of patching the reader, we applied the same env snapshot as a local hot patch at the transport boundary ( One note for maintainers: spreading at the transport layer also covers any other worker path that could carry a platform-semantics env; spreading inside +1 for this PR from a production deployment. |
|
Cross-link from a Windows field report (OpenClaw 2026.9.7, Node 24.18.0): the same uncloneable env also breaks the rpc/http request builder, which this PR's reader-side change does not cover. Evidence: instrumenting the generic pool's A local workaround that restored all ten agents: a plain string snapshot of |
|
Thanks @FkyBird1982 for the diagnosis, production evidence, and focused fix. This exact-entry repair is already covered by #160075, merged as a181c3f1d908, so I’m closing this PR as superseded. Verified on current main The proposed boundary fix and regression are already represented on main. #158788 remains open for its release-verification discussion; the separately reported rpc/http path is outside this PR’s repair. |
Fixes #157986 (also reported as #158788)
Problem
On Windows, cron isolated agent turns fail at setup with
DataCloneError: #<Object> could not be cloned. | unavailable(2026.9.6, see the issue for the full postmortem).cloneEnvWithPlatformSemanticsreturns a proxy-wrapped env on Windows; the proxy reaches the exact-entries worker input and cannot cross the structured-clone boundary atworker.postMessage.Solution
Spread env when preparing the
session-exact-entriesworker input insession-transcript-worker-readers.ts, matching the existingreadRowFactsbehavior two readers above. This is the one boundary everyreadExactEntriescaller crosses, so the fix covers all callers regardless of which one passes a platform-semantics env.Impact
Windows-only defect; other platforms already submit a plain object, and the spread is a no-op for them. No behavior change beyond making the input cloneable.
Evidence
readExactEntries' input shape (kind, env, sessionKeys, lifecycleSessionKey, projection, includeMembers, includeAuthorization, continuation, database) matched thesession-exact-entriesrequest exactly.session-transcript-worker-readers.test.tssubmits through a stubbedrunRequestwith a proxied env and asserts the prepared input survivesstructuredClone.After-fix run trace (production, redacted)
Before the boundary fix, the same job failed at setup in 43 ms:
{ "jobId": "b3b0aeb6-52c3-4574-8999-5f240551e9de", "action": "finished", "status": "error", "completionStatus": "failed", "error": "DataCloneError: #<Object> could not be cloned. | unavailable", "durationMs": 43, "runAtIso": "2026-09-26T16:57:18.617+08:00", "jobName": "<redacted: local OneNote sync job>" }After deploying an equivalent boundary fix (the deployed hot patch retries the same
worker.postMessageinput as a JSON round-trip at the pool boundary; this PR instead spreads env before submission — both act on the same env object at the same structured-clone boundary), the same job succeeded on manual trigger and then again on its natural schedule:{ "jobId": "b3b0aeb6-52c3-4574-8999-5f240551e9de", "action": "finished", "status": "ok", "completionStatus": "succeeded", "durationMs": 25206, "runAtIso": "2026-09-26T17:57:18.687+08:00", "provider": "zai", "model": "glm-5.3-flash", "usage": { "input_tokens": 10374, "output_tokens": 180, "total_tokens": 26170, "cache_read_tokens": 15616 }, "jobName": "<redacted: local OneNote sync job>", "summary": "<redacted>" }A second agentTurn job on the same instance (daily web briefing, different schedule) also completed after the fix:
{ "jobId": "0a648e82-4f2c-47ad-8a47-adc12e232b0e", "status": "ok", "completionStatus": "succeeded", "durationMs": 93799, "runAtIso": "2026-09-26T17:17:12.567+08:00", "provider": "zai", "model": "glm-5.3-flash", "usage": { "input_tokens": 31711, "output_tokens": 2193 }, "jobName": "<redacted: daily web intel briefing job>", "summary": "<redacted: multi-section briefing generated and delivered>" }Job names, summaries, and delivery targets are redacted (local business content); all status, timing, usage, and error fields are verbatim from
openclaw cron runs <jobId>on the affected Windows instance.Test cost
The new test is a single pure unit test with an injected request runner (no worker, no database, no timers). Measured locally on Windows (
pnpm test src/config/sessions/session-transcript-worker-readers.test.ts --maxWorkers=1):