anomalyco / anomalyco/opencode

core: bash tool discards captured stdout/stderr when a command times out

Open
#45,881 0 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 28, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When a bash command exceeds its timeout, the tool returns only the static message Command exceeded timeout of N ms. Retry with a larger timeout... — all output captured before the timeout is dropped. That partial output (test progress, build logs, debugger messages) is usually the most diagnostic information available about why the command hung, and the model has no way to recover it.

Root cause
  • packages/core/src/process.ts:183-188: Effect.timeoutOrElse(collect, ...) interrupts the collect fiber on timeout, discarding the partial buffer it already accumulated (up to the MAX_CAPTURE_BYTES cap).
  • packages/core/src/tool/bash.ts: the timeout branch maps the failure to Effect.succeed(undefined) and returns only the fixed notice; result.output is never consulted because result is undefined.
Reproduction

Invoke the bash tool with:

{"command": "echo CRITICAL-PROGRESS; sleep 30", "timeout": 2000}

Result contains only the timeout notice; CRITICAL-PROGRESS (emitted well before the deadline) is lost.

Expected

The timeout result should include whatever output was captured before the deadline, e.g.:

Command exceeded timeout of 2000 ms. Output captured before timeout:
CRITICAL-PROGRESS
Suggested direction

On the timeout path, drain the still-live process handle's buffer (short bounded grace period) and include it in the tool result, keeping the existing timeout: true marker. Happy to implement if the approach sounds reasonable.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.