You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bash tool discards captured partial output on runner error (timeout/cancel), returning only the error reason #153
When the Bash command runner returns an error (timeout, cancellation, no-shell), the Bash tool throws away the partial stdout/stderr the runner already captured and returns only command failed to run: <err>. A command that produced useful output before being killed by its timeout tells the model nothing actionable.
The non-zero-exit path is fine (it returns full output + exit code) — only the runner-error path loses information.
Where it happens
The runner does return the captured output alongside the error:
res:= tool.CommandResult{
Stdout: stdout.String(), // captured-so-far (capped buffers)Stderr: stderr.String(),
ExitCode: 0,
}
ifcerr:=ctx.Err(); cerr!=nil {
returnres, cerr// res HAS the partial output
}
But the Bash tool discards res entirely on any error:
internal/adapter/tools/bash.go — Execute:
res, err:=bt.runner.Run(ctx, args.Command, ws.Root())
iferr!=nil {
// res (with partial Stdout/Stderr) is dropped herereturnsession.NewToolError(in.ID, fmt.Sprintf("command failed to run: %v", err)), nil
}
So a command that times out after emitting output returns only command failed to run: context deadline exceeded.
Proposed fix
On a runner error, still surface the captured res.Stdout/res.Stderr (same combined-output formatting as the success path), then append a clear reason line, e.g.:
<partial stdout/stderr captured so far>
[command timed out after <N>ms; output above is partial]
Distinguish timeout vs cancel vs no-shell in the trailer. Keep it a tool error (is_error: true) so the model knows it failed, but give it the recoverable output to adapt (re-run with a longer timeout_ms, narrow the command, etc.).
Acceptance
A Bash command that produces output then hits its timeout_ms returns that output plus a clear timeout reason, as a tool error.
The success and non-zero-exit paths are byte-for-byte unchanged.
Test covers the timeout-with-partial-output case (innocuous command, e.g. echo hi; sleep 5 with a short timeout — assert the captured hi survives).
Related: sibling Subagent empty-return issue #152 — both are the same anti-pattern of a failure path discarding recoverable information.
Activity
fix(tools): preserve Bash partial output on runner timeout/cancel