Skip to content

fix(bench): ignore EPIPE when an agent exits before it reads stdin - #47

Merged
jameslcowan merged 1 commit into
mainfrom
fix/bench-stdin-epipe
Nov 12, 2026
Merged

jameslcowan merged 1 commit into
mainfrom
fix/bench-stdin-epipe

Conversation

@jameslcowan

Copy link
Copy Markdown
Collaborator

What changed

a mock run records one row per arm with the edit the agent made failed on the Windows Node 24 leg of run 43267718210 (#4, after a merge from main). The other 5 legs passed on the same commit. The harness itself crashed:

Error: write EPIPE
    at Socket.end (node:net)
    at file:///D:/a/complex-md/complex-md/bench/run.mjs:298:17
Emitted 'error' event on Socket instance

bench/run.mjs ends the agent's stdin right after spawn. The mock agent can exit before it reads stdin. The write then fails with EPIPE, and with no error handler on the stream, the harness process dies with exit code 1 before it records a row.

  • The child's stdin gets an error handler that ignores the failed write. The run still records the agent's exit code, output and result, so nothing is lost.
  • bench/agent-events.mjs, which moves with run.mjs in COMPLEX.md, reads the agent's output and needed no change.

This is the second timing flake found today, after the parallel build race in #45.

How it was tested

  • cd cli && node --test test/bench-harness.test.js test/bench-sandbox.test.js: 19 pass, 0 fail, including the sandbox tests on a host where the sandbox runs.
  • cd cli && npm test: exit 0, 838 pass, 0 fail.
  • No test forces the EPIPE: it depends on the order in which 2 processes are scheduled. The fix removes the unhandled event; it does not change what a run records.

AI assistance

  • An AI tool helped write this change. Claude Code (Claude Opus 5.5) found the cause, wrote the commit and this description.
  • Each commit the tool helped write has an Assisted-by: or a Co-Authored-By: trailer.
  • A person read the whole diff and will answer the review comments.

🤖 Generated with Claude Code

https://claude.ai/code/session_011jHASLngEodgNzogro3gQz

Problem: "a mock run records one row per arm with the edit the agent
made" failed on the Windows Node 24 leg of run 43267718210 (2026-11-12).
bench/run.mjs ended the child's stdin after spawn; the mock agent exited
before it read it, the write failed with EPIPE, and the stream had no
error handler. The harness process died with an unhandled 'error' event
and exit code 1, before it recorded any row. The same commit passed on
the other 5 legs.

Change: the child's stdin gets an error handler that ignores the failed
write. The run still records the agent's exit code, output and result,
so a closed pipe is not lost information. bench/agent-events.mjs, which
moves with this file, reads the agent's output and needed no change.

Intent: a scripted agent that exits early gives a recorded row, not a
crashed harness and a red CI leg.

Assisted-by: Claude
@jameslcowan jameslcowan added the bug Something isn't working label Nov 12, 2026
@github-actions

Copy link
Copy Markdown

COMPLEX.md: 1 hotspot touched, 1 co-change partner not in this pull request.

Hotspot Score Churn Fixes Fan in Tests
bench/run.mjs 2474 26 13 4 3
  • bench/run.mjs: Before editing this file, open parseFrontMatter in cli/src/complexmd.js, because it reads back the exact lines that frontMatter writes.

Co-change partners not in this pull request

  • bench/run.mjs changed. Unchanged: bench/agent-events.mjs (6 commits together, 86 percent). Say whether each needs a change.

Read from COMPLEX.md at base 5a26d00. The map was generated 2026-10-25 at da42d08, 15 commits behind the base. complex-md-action runs no code from this pull request.

@jameslcowan
jameslcowan merged commit 9c573ea into main Nov 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant