anomalyco / anomalyco/opencode
core: bash tool discards captured stdout/stderr when a command times out
@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 thecollectfiber on timeout, discarding the partial buffer it already accumulated (up to theMAX_CAPTURE_BYTEScap).packages/core/src/tool/bash.ts: the timeout branch maps the failure toEffect.succeed(undefined)and returns only the fixed notice;result.outputis never consulted becauseresultisundefined.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.