Skip to content

fix(agents): avoid shell snapshot stdout pipe failures - #100744

Merged
vincentkoc merged 4 commits into
openclaw:mainfrom
lsr911:fix/shell-snapshot-stream-errors
Jul 6, 2026
Merged

vincentkoc merged 4 commits into
openclaw:mainfrom
lsr911:fix/shell-snapshot-stream-errors

Conversation

@lsr911

@lsr911 lsr911 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where shell snapshot helper commands could crash OpenClaw if their unused stdout pipe emitted a stream error.

Why This Change Was Made

Both runShell callers only consume the child exit status, while snapshot capture output is already redirected to a private temporary file. The helper now spawns with ignored stdio instead of creating and draining an unused stdout pipe, removing the error source entirely.

The original report and fix direction remain credited to @lsr911. The maintainer repair replaces the standalone proof script with durable coverage of the production shell-snapshot path.

User Impact

Shell snapshot capture and validation no longer expose an unused stdout stream that can emit an unhandled error. Existing fallback, timeout, and process-tree cleanup behavior is unchanged.

Evidence

  • node scripts/run-vitest.mjs src/agents/shell-snapshot.spawn.test.ts src/agents/shell-snapshot.test.ts - 14/14 passed.
  • Regression red check: restoring stdio: ["ignore", "pipe", "ignore"] makes shell-snapshot.spawn.test.ts fail on the production spawn contract.
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/shell-snapshot.ts src/agents/shell-snapshot.spawn.test.ts - passed.
  • ./node_modules/.bin/oxfmt --check src/agents/shell-snapshot.ts src/agents/shell-snapshot.spawn.test.ts - passed.
  • git diff --check origin/main...HEAD - passed.
  • codex review --base origin/main - no findings; confirmed ignored stdio is the correct fix because neither caller consumes stdout.

Focused local proof only. Testbox was intentionally not used because Blacksmith is unavailable.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling size: XS labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 6:08 AM ET / 10:08 UTC.

Summary
The PR changes shell snapshot helper subprocesses to use ignored stdio instead of an unused stdout pipe and adds a production-path spawn regression test.

PR surface: Source -6, Tests +71. Total +65 across 2 files.

Reproducibility: yes. from source inspection, but not from an executed current-main repro in this read-only review. Current main creates an unused child stdout pipe without an error listener, and Node's EventEmitter source throws on unhandled error events.

Review metrics: 1 noteworthy metric.

  • runShell output consumers: 2 status-only callers, 0 stdout readers. This supports that ignoring stdio removes the pipe failure mode without dropping shell-snapshot capture data.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal output or logs from a real OpenClaw shell-snapshot or host exec run after the fix, or get an explicit maintainer proof override.
  • Rerun or clear the exact-head CI gate after the unrelated base failures are resolved.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR provides focused test/lint output and regression coverage, but no redacted live shell-snapshot or host exec behavior proof after the fix; screenshots are not needed, terminal output or logs would be enough if private paths and secrets are redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Real behavior proof is still test-only: the PR body and comments show focused tests, lint, formatting, and a regression red-check claim, but not a redacted live OpenClaw shell-snapshot or host exec run after the fix.
  • [P1] The exact-head CI run was not clean during review, so landing still needs the repo-native CI gate to resolve, be retried, or receive an explicit maintainer proof decision for unrelated failures.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow stdio-ignore fix with the production-path regression test after a maintainer either receives real shell-snapshot or host exec proof, or explicitly overrides the external-PR proof gate.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Human handling is needed because there is no narrow code defect for ClawSweeper to repair; the remaining blockers are proof sufficiency and normal exact-head CI/merge gating.

Maintainer decision needed

  • Question: Should this external contributor PR require live shell-snapshot or host exec proof before merge, or is the maintainer repair plus focused tests enough for a proof override?
  • Rationale: The code path is now cleanly covered, but the external-PR proof gate requires real behavior proof beyond tests unless a maintainer intentionally overrides it.
  • Likely owner: vincentkoc — vincentkoc is assigned, pushed the repair commits, and has adjacent stream-error history, making them the best available proof-sufficiency owner.
  • Options:
    • Require live proof (recommended): Ask for a redacted terminal transcript or logs from a real OpenClaw shell-snapshot or host exec run after the fix before clearing proof.
    • Override proof gate: A maintainer can explicitly accept the focused tests and maintainer repair as sufficient proof for this internal crash path before landing.

Security
Cleared: No concrete security or supply-chain regression was found; the diff removes an unused pipe and adds a focused test without changing dependencies, secrets, permissions, downloads, or package resolution.

Review details

Best possible solution:

Land the narrow stdio-ignore fix with the production-path regression test after a maintainer either receives real shell-snapshot or host exec proof, or explicitly overrides the external-PR proof gate.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection, but not from an executed current-main repro in this read-only review. Current main creates an unused child stdout pipe without an error listener, and Node's EventEmitter source throws on unhandled error events.

Is this the best way to solve the issue?

Yes for the code shape: ignoring stdio is narrower than adding a no-op listener because both runShell callers only consume status and capture output is read from a private temp file. Proof sufficiency remains unresolved for merge.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fa70403403da.

Label changes

Label justifications:

  • P2: This is a bounded agent exec reliability fix with limited blast radius and remaining proof/CI merge gates.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides focused test/lint output and regression coverage, but no redacted live shell-snapshot or host exec behavior proof after the fix; screenshots are not needed, terminal output or logs would be enough if private paths and secrets are redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source -6, Tests +71. Total +65 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 9 -6
Tests 1 71 0 +71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 74 9 +65

What I checked:

  • Repository policy read: Root and scoped agents policy were read fully; the review applied the PR depth, scoped agent-test, proof, and external-PR evidence guidance. (AGENTS.md:35, fa70403403da)
  • Current main still has the risky pipe: Current main's runShell creates a stdout pipe and reads from child.stdout even though callers only use status, so the PR is not obsolete on main. (src/agents/shell-snapshot.ts:449, fa70403403da)
  • PR head removes the unused pipe: At PR head, runShell uses stdio: "ignore" and resolves only status, which removes the stdout stream that could emit unhandled errors. (src/agents/shell-snapshot.ts:449, ce669bdb5587)
  • Both callers are status-only: validateSnapshot checks result.status, while captureShellSnapshot redirects capture output to a private temp file and reads that file after runShell returns. (src/agents/shell-snapshot.ts:244, fa70403403da)
  • Production-path regression coverage added: The new test calls maybeWrapCommandWithShellSnapshot through the production wrapper and asserts the subprocess spawn options use ignored stdio. (src/agents/shell-snapshot.spawn.test.ts:44, ce669bdb5587)
  • Runtime entry point checked: The host exec runtime calls maybeWrapCommandWithShellSnapshot before constructing the child argv for non-sandbox execution. (src/agents/bash-tools.exec-runtime.ts:788, fa70403403da)

Likely related people:

  • steipete: Authored the merged exec shell snapshot cache PR that added src/agents/shell-snapshot.ts, its tests, and the docs surface. (role: feature introducer; confidence: high; commits: 02ec70f8ac18, 0d77c84815f9, 860c9a85167e; files: src/agents/shell-snapshot.ts, src/agents/shell-snapshot.test.ts, docs/tools/exec.md)
  • RomneyDa: Authored the merged corrupt shell snapshot validation fix that modified this module and adjacent tests. (role: recent targeted shell-snapshot contributor; confidence: medium; commits: 4bb98b700c81; files: src/agents/shell-snapshot.ts, src/agents/shell-snapshot.test.ts)
  • NianJiu: Local blame for the current runShell block points to a broad recent main commit that reintroduced the whole shell-snapshot file in this checkout history, so routing confidence is low. (role: current-line history carrier; confidence: low; commits: a0c0f43ab372; files: src/agents/shell-snapshot.ts, src/agents/shell-snapshot.test.ts, docs/tools/exec.md)
  • vincentkoc: Pushed the current maintainer repair on this PR and recently carried the adjacent MCP stdio stream-error fix path. (role: recent repair and adjacent stream-error contributor; confidence: medium; commits: ce669bdb5587, 19822fc52e28, 538895533e4f; files: src/agents/shell-snapshot.ts, src/agents/shell-snapshot.spawn.test.ts, src/agents/mcp-stdio-transport.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-06T09:15:43.636Z sha efe1ba1 :: needs real behavior proof before merge. :: [P2] Exercise the production shell-snapshot path | [P2] Fix the added script lint error

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 6, 2026
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@vincentkoc
vincentkoc force-pushed the fix/shell-snapshot-stream-errors branch from efe1ba1 to b49a115 Compare July 6, 2026 09:21
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed scripts Repository scripts size: XS labels Jul 6, 2026
@vincentkoc vincentkoc changed the title fix(agents): suppress unhandled stdout stream errors in shell-snapshot runShell fix(agents): avoid shell snapshot stdout pipe failures Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer repair pushed at lsr911@b49a115.

Addressed the current review findings:

  • removed the standalone proof that duplicated the listener instead of exercising production code;
  • removed the unused stdout pipe entirely because both callers consume only exit status;
  • added durable production-path regression coverage;
  • focused format, type-aware lint, and shell-snapshot tests pass (14/14).

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added triage: blank-template Candidate: PR template appears mostly untouched. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 6, 2026
@vincentkoc vincentkoc removed the triage: blank-template Candidate: PR template appears mostly untouched. label Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Follow-up maintainer repair pushed at lsr911@fcf8172.

The prior exact-head CI guard annotation is addressed by using useAutoCleanupTempDirTracker(afterEach) in the production-path regression test.

Focused proof remains green:

  • shell-snapshot tests: 14/14 passed
  • type-aware oxlint: passed
  • oxfmt and diff check: passed
  • staged temp-directory guard: no findings

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@lsr911
lsr911 force-pushed the fix/shell-snapshot-stream-errors branch from fcf8172 to 6b39aa9 Compare July 6, 2026 09:35
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 6, 2026
@lsr911

lsr911 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — updated proof now calls the production function (via spawn patcher injecting stream errors). The proof fails if the production error handlers are removed.

@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@vincentkoc

Copy link
Copy Markdown
Member

Maintainer repair refreshed after the contributor update: lsr911@ce669bd.

This preserves both contributor commits, then:

  • removes the lint-failing spawn monkeypatch proof;
  • removes the unused stdout pipe instead of swallowing its errors;
  • adds durable Vitest coverage through the production shell-snapshot path;
  • uses the repository temp-directory cleanup helper.

Focused proof at this exact tree:

  • shell-snapshot tests: 14/14 passed
  • type-aware oxlint: passed
  • oxfmt and diff check: passed
  • temp-directory guard: no findings
  • fresh autoreview: no actionable defects

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@vincentkoc

Copy link
Copy Markdown
Member

Landing is paused at exact head ce669bdb5587ef3f7f3a98eb8e1527c1af3ee619 because the repo-native prepare-run gate requires a successful CI workflow.

Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/28783046101

The blocking failures are outside this PR's two-file diff:

  • check-lint and check-prod-types both fail on unused SessionWorktreeInfo / SessionsCreateResult imports in packages/gateway-protocol/src/index.ts, inherited from current main.
  • check-shrinkwrap hit a registry ECONNRESET while fetching @openai/codex.

The shell-snapshot patch itself has focused 14/14 tests, type-aware oxlint, oxfmt, diff check, temp-dir guard, and fresh autoreview green. I am not adding unrelated gateway or shrinkwrap changes to this contributor PR.

@vincentkoc vincentkoc added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Land-ready proof for exact head 38e27ce8549a644cd3d292a183d9e4819683c97f:

  • verified both production callers are status-only; snapshot output is redirected to the private temp file and validation discards output
  • node scripts/run-vitest.mjs src/agents/shell-snapshot.test.ts (13/13 passed)
  • node scripts/run-vitest.mjs src/agents/shell-snapshot.spawn.test.ts (1/1 passed, including red check against the old piped-stdio contract)
  • focused oxfmt, git diff --check, and test-temp guard passed
  • fresh branch autoreview with gpt-5.5 high reasoning: clean, confidence 0.86
  • exact-head GitHub Actions run 28800178740: passed, including lint, production/test types, build, shrinkwrap, all compact test shards, and QA Smoke CI
  • repo-native scripts/pr prepare-run 100744: passed with exact PR/prep head parity

No docs or changelog change is required for this narrow internal reliability fix.

@vincentkoc
vincentkoc merged commit 428ee12 into openclaw:main Jul 6, 2026
117 of 122 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
* fix(agents): suppress unhandled stdout stream errors in shell-snapshot runShell

Signed-off-by: 廖石荣 0668000909 <[email protected]>

* proof: rewrite to exercise production shell-snapshot with injected stream errors

Signed-off-by: 廖石荣 0668000909 <[email protected]>

* fix(agents): avoid unused shell snapshot stdout pipe

* chore: refresh CI after mainline drift

---------

Signed-off-by: 廖石荣 0668000909 <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
* fix(agents): suppress unhandled stdout stream errors in shell-snapshot runShell

Signed-off-by: 廖石荣 0668000909 <[email protected]>

* proof: rewrite to exercise production shell-snapshot with injected stream errors

Signed-off-by: 廖石荣 0668000909 <[email protected]>

* fix(agents): avoid unused shell snapshot stdout pipe

* chore: refresh CI after mainline drift

---------

Signed-off-by: 廖石荣 0668000909 <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 428ee12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants