Skip to content

fix(agents): harden tool search child streams#101295

Merged
steipete merged 1 commit into
mainfrom
codex/fix-tool-search-code-mode-stream-errors
Jul 7, 2026
Merged

fix(agents): harden tool search child streams#101295
steipete merged 1 commit into
mainfrom
codex/fix-tool-search-code-mode-stream-errors

Conversation

@steipete

@steipete steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Code-mode tool_search spawned an unused stdout pipe and left stderr stream errors unhandled. A broken diagnostic pipe could therefore surface as an uncaught error event instead of rejecting the tool call cleanly.

Supersedes #101022 after the contributor fork head became unstable during maintainer fixup. The original author remains credited in the commit.

Why This Change Was Made

The worker already returns logs and results over IPC, so stdout is ignored instead of creating an unused pipe. Stderr failures now flow through the existing once-only settlement path, which rejects pending work and terminates the unusable child without duplicating lifecycle policy.

The one-off proof script and redundant testing export from the submitted branch are omitted. A focused regression exercises the real spawn owner, stderr rejection, child termination, and exact stdio contract.

User Impact

Code-mode Tool Search fails cleanly when its child diagnostic stream breaks, instead of risking a gateway crash or stranded request. Normal IPC results and stderr diagnostics are unchanged.

Evidence

  • Fresh Codex autoreview on the final two-file patch: clean; no accepted/actionable findings.
  • Targeted oxfmt and git diff --check: clean.
  • Sanitized direct AWS Crabbox, provider aws, lease cbx_b04650d7e1c8, run run_4f37de478300, exact head 411d3260ea455417dbd251ca3a48a32fd1117e4b: focused test passed 1/1. Broker fallback to t3.small required an 8 GiB swap file after a prior undersized lease was OOM-killed during dependency installation before tests.
  • Exact-head hosted CI run 28838695336: 71 relevant checks succeeded, none pending/failing.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Jul 7, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 411d3260ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/tool-search.ts
Comment on lines +2159 to +2160
child.stderr?.on("error", (error) => {
settle(() => reject(error));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Abort bridged calls on stderr stream failure

When the new stderr error path fires while model-authored code is awaiting openclaw.tools.call(...), this settles the code-mode promise and kills the child but never aborts bridgeAbortController; the in-flight runCodeModeBridgeRequest still passes that un-aborted signal through ToolSearchRuntime.call to the target tool, so side-effectful or long-running catalog tools can continue running after tool_search_code has already failed. Abort the bridge controller before rejecting on this stream-failure path so it matches the timeout/parent-abort cleanup behavior.

Useful? React with 👍 / 👎.

@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready at 411d3260ea455417dbd251ca3a48a32fd1117e4b.

  • Worker logs/results remain IPC-only; unused stdout is now ignored.
  • Stderr stream failures reject through the existing once-only settlement path and terminate the unusable child.
  • Focused regression proves stderr rejection, child termination, and exact stdio configuration.
  • Original fix(agents): handle stderr stream errors in tool_search_code child #101022 contributor credit is preserved in the maintainer commit.
  • Sanitized AWS Crabbox proof: provider aws, lease cbx_b04650d7e1c8, run run_4f37de478300, exact head, focused test 1/1 passed. Broker fallback to t3.small required an 8 GiB swap file; the prior undersized lease failed during dependency installation before tests.
  • Exact-head hosted CI: run 28838695336, 71 relevant checks succeeded, none pending/failing.
  • Fresh final-head Codex autoreview: clean, no accepted/actionable findings.
  • Targeted oxfmt and git diff --check: clean.

Known proof gaps: none.

@steipete
steipete merged commit 118e5bd into main Jul 7, 2026
131 of 137 checks passed
@steipete
steipete deleted the codex/fix-tool-search-code-mode-stream-errors branch July 7, 2026 03:25
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant