Repository navigation
feat(exec): write background exec output to a file named in the exit wake - #199992
Conversation
…wake A Gateway-host exec now writes all stdout and stderr, in order, to an owner-only temp file (the web_fetch spill location and retention) up to a 64 MiB hard limit. The exit wake ends with 'Full output: <path> (<N> bytes)' when it omits output, and a foreground result or process log that lost output at the 200k in-memory cap names the same file. Sandbox, node and durable commands keep today's behavior. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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 changesGateway-host exec commands save output in private temporary files and expose recovery paths when wakes or results omit output. Example: A background command prints FIRST_LINE_MARKER, 500,000 characters, and LAST_LINE_MARKER.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides useful output recovery, fixes both earlier review findings, and has no new actionable defect identified; checks for the reviewed head remain pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe exec runtime captures command output, the process registry retains bounded memory windows, and completion notifications and process tools expose results to the agent. flowchart TD
A[Gateway exec command] --> B[Output capture]
B --> C[Bounded process memory]
B --> D[Private output file]
C --> E[Exit settlement]
D --> E
E --> F[Wake or tool result]
F --> G[Agent reads saved output]
Technical reviewBest possible solution: Keep streamed capture with the existing private-file owner and shared footer contract, preserving bounded memory and explicit partial-file disclosure. Do we have a high-confidence way to reproduce the issue? Current-main source retains only bounded output, and the supplied paired Gateway traces demonstrate loss and recovery of the first marker; no target code was executed during this review. Is this the best way to solve the issue? The change uses the existing process lifecycle, private temporary-file location, and spill-footer contract without adding another storage manager or changing sandbox and remote-node behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b3ee20852674. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +120, Tests +48, Docs +2, Other +1. Total +171 across 16 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:
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 16, 2026, 1:17 AM ET / 06:17 UTC (Revision 2). |
…pped files partial Co-authored-by: obviyus <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Review findings at 143113e:
|
|
Landed in 202514e. A background Gateway-host exec now writes its full output to a file. The exit wake names the file path and size, and |
Nested Vitest temp-path relocation could send the native-close capability probe outside the fixture guard. Its rejection disabled explicit close and caused hundreds of transcript-worker replacements during reload continuations. Select the owned temp root in the preload guard and remove the late reset. Regression fails before the fix; 12 isolation tests, Node continuation/revocation product tests, and the exact Bun CI group pass at the unchanged timeout. check:changed passes except the exact-parent dead export introduced by #199992. Codex review is clean.
…art (#200020) * fix: recover saved Responses state and retry completion delivery after restart * fix: preserve streamed replay bytes without repeated metadata parsing * fix: scope saved argument replay to its source provider * test: satisfy conditional braces in replay regression * test(gateway): await steering admission before releasing tool * fix(agents): retry returned saved-state delivery failures * fix(agents): preserve delivery suppression before state repair * fix(test): initialize guarded temp root before SQLite probes Nested Vitest temp-path relocation could send the native-close capability probe outside the fixture guard. Its rejection disabled explicit close and caused hundreds of transcript-worker replacements during reload continuations. Select the owned temp root in the preload guard and remove the late reset. Regression fails before the fix; 12 isolation tests, Node continuation/revocation product tests, and the exact Bun CI group pass at the unchanged timeout. check:changed passes except the exact-parent dead export introduced by #199992. Codex review is clean.
…wake (openclaw#199992) ## Summary A background exec now writes its full output to a file. The exit wake gives the agent the file path, so the agent can read only the part that it needs with `read`. No output is lost at the 200k in-memory cap. - A Gateway-host exec writes stdout and stderr, in arrival order, to one owner-only file while it runs. - The exit wake ends with `Full output: <path> (<N> bytes)` when it omits output. The wake no longer says "process log has the rest" for these commands. - A foreground result or a `process poll`/`log` result that lost output at the in-memory cap names the same file, instead of "earlier output was discarded". - The in-memory window and tail for `process poll`/`log` do not change. ## Design: reuse the existing spill storage - The file uses the `web_fetch` record-time spill location: `private-temp-file.ts`, OS temp directory, `0600`, random name, exclusive create. `openPrivateTempFileStream` is a streamed variant beside `writePrivateTempFile`. - Retention is the same as for `web_fetch` spill files: the OS temp-directory cleanup. The file survives a Gateway restart. - The footer is the shared `formatFullOutputFooter`, and foreground results set `details.fullOutputPath`. Thus the existing record-time truncation in `tool-result-truncation.ts` keeps the path visible when it cuts the result. - One render function (`renderExecOutputFile`) owns the path text for the wake, the foreground result and the process log. - Hard limit: 64 MiB per file (`EXEC_OUTPUT_FILE_MAX_BYTES`). Later output is discarded and the footer says so. Documented in `docs/tools/exec.md`. - OpenClaw keeps the file only when a result or wake omits some of its output. Otherwise the file is removed at exit. - No DB table, no schema or stored-row change, no protocol change. ## Not covered (today's behavior stays) - **Sandbox exec:** a sandboxed `read` cannot reach host temp files. No file; the wake keeps today's text. - **Node exec:** runs on another machine through its own path. No file; the wake keeps today's text. - **Durable exec:** already keeps its own log artifact. No new file. - **`tools.fs.workspaceOnly`:** `read` cannot reach the temp directory. This is the same limit as for `web_fetch` spill files. The agent can read the file with `exec`. - **Foreground output cut only by the model result budget (under 200k):** no file. That cut happens at record time, after the process ends; adding it there is not trivial. ## Proof Tier: **source** (`ocx src`, scratch Gateway, scripted OpenAI-compatible model). A background command prints `FIRST_LINE_MARKER`, 500,000 `x`, then `LAST_LINE_MARKER`, and exits. The scripted model reacts to the exit wake: if it finds `Full output: <path>`, it calls `read` with `limit: 1`. Base (`2f1cec388d24`, merge base): ```text -- model request: wake-without-path Exec completed (…, code 0, 3s), last 2000 of 500036 output chars (process log keeps the last 200000; earlier output was discarded): xxxx… LAST_LINE_MARKER ``` Head: ```text -- model request: wake-with-path Exec completed (…, code 0, 3s), last 2000 of 500036 output chars: xxxx… LAST_LINE_MARKER Full output: <tmp>/openclaw-exec-7be8d1051799b5b6.log (500036 bytes) -- model request: read-result FIRST_LINE_MARKER [2 more lines in file. Use offset=2 to continue.] file: bytes=500036 first=FIRST_LINE_MARKER last=LAST_LINE_MARKER mode=600 ``` - The files of both head runs were still present after their scratch Gateways stopped. - Exact head `143113e4` rerun: same result (`Full output: … (500036 bytes)`, `read` returns `FIRST_LINE_MARKER`). - A foreground result whose file reached the 64 MiB limit sets `spillTruncated`, so history elision keeps it marked partial. - Tier **vitest-source** (`ocx test`): - `bash-tools.exec-background-followup.test.ts`: the wake text and path, and a 500,010-char background output that is complete in the file. - `bash-tools.exec-runtime.test.ts`: a timeout wake after the 1,000-char cap; the file has all of the output. - `session-tool-result-guard.test.ts`, `bash-tools.process.poll-timeout.test.ts`: unchanged behavior. - `pnpm tsgo:core`, `pnpm check:test-types`, oxlint and oxfmt pass. - Tier **full**: `ocx build --dts` passes; `node dist/entry.js --version` prints `OpenClaw 2026.11.3` (first head). Co-authored-by: Ayaan Zaidi <[email protected]>
…art (openclaw#200020) * fix: recover saved Responses state and retry completion delivery after restart * fix: preserve streamed replay bytes without repeated metadata parsing * fix: scope saved argument replay to its source provider * test: satisfy conditional braces in replay regression * test(gateway): await steering admission before releasing tool * fix(agents): retry returned saved-state delivery failures * fix(agents): preserve delivery suppression before state repair * fix(test): initialize guarded temp root before SQLite probes Nested Vitest temp-path relocation could send the native-close capability probe outside the fixture guard. Its rejection disabled explicit close and caused hundreds of transcript-worker replacements during reload continuations. Select the owned temp root in the preload guard and remove the late reset. Regression fails before the fix; 12 isolation tests, Node continuation/revocation product tests, and the exact Bun CI group pass at the unchanged timeout. check:changed passes except the exact-parent dead export introduced by openclaw#199992. Codex review is clean.
Summary
A background exec now writes its full output to a file. The exit wake gives the agent the file path, so the agent can read only the part that it needs with
read. No output is lost at the 200k in-memory cap.Full output: <path> (<N> bytes)when it omits output. The wake no longer says "process log has the rest" for these commands.process poll/logresult that lost output at the in-memory cap names the same file, instead of "earlier output was discarded".process poll/logdo not change.Design: reuse the existing spill storage
web_fetchrecord-time spill location:private-temp-file.ts, OS temp directory,0600, random name, exclusive create.openPrivateTempFileStreamis a streamed variant besidewritePrivateTempFile.web_fetchspill files: the OS temp-directory cleanup. The file survives a Gateway restart.formatFullOutputFooter, and foreground results setdetails.fullOutputPath. Thus the existing record-time truncation intool-result-truncation.tskeeps the path visible when it cuts the result.renderExecOutputFile) owns the path text for the wake, the foreground result and the process log.EXEC_OUTPUT_FILE_MAX_BYTES). Later output is discarded and the footer says so. Documented indocs/tools/exec.md.Not covered (today's behavior stays)
readcannot reach host temp files. No file; the wake keeps today's text.tools.fs.workspaceOnly:readcannot reach the temp directory. This is the same limit as forweb_fetchspill files. The agent can read the file withexec.Proof
Tier: source (
ocx src, scratch Gateway, scripted OpenAI-compatible model). A background command printsFIRST_LINE_MARKER, 500,000x, thenLAST_LINE_MARKER, and exits. The scripted model reacts to the exit wake: if it findsFull output: <path>, it callsreadwithlimit: 1.Base (
e9c805458136, merge base):Head:
ocx test):bash-tools.exec-background-followup.test.ts: the wake text and path, and a 500,010-char background output that is complete in the file.bash-tools.exec-runtime.test.ts: a timeout wake after the 1,000-char cap; the file has all of the output.session-tool-result-guard.test.ts,bash-tools.process.poll-timeout.test.ts: unchanged behavior.pnpm tsgo:core,pnpm check:test-types, oxlint and oxfmt pass.ocx build --dtspasses;node dist/entry.js --versionprintsOpenClaw 2026.11.3 (076dc6c).