[BUG] Monitor: script stderr is never surfaced, so a silently-broken monitor hangs with no signal
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The background Monitor tool streams only a script's stdout as event notifications. Its stderr is written to the task output file and is never surfaced to the model. If a monitor's command is broken in a way that produces only stderr — e.g. a missing binary, or a command that errors on every iteration — the monitor keeps running but never emits the intended events, and there is no signal that it is malfunctioning. The agent can wait indefinitely, unable to distinguish "silently broken" from "still waiting for the event."
What Should Happen?
output to stderr should be seen by claude to decide if the monitor-code has to be fixed or not
Error Messages/Logs
Steps to Reproduce
- Start a persistent Monitor whose poll loop uses a binary that isn't installed in the shell environment. In my case jq, on Windows Git Bash where the jq binary is absent (only gh's built-in --jq engine exists). The loop did roughly:
state=$(jq -r .state <<<"$json")
[ "$state" = "MERGED" ] && { echo "EVENT merged"; break; }
... similar branches for ci_failed / rebase ...
- Every iteration printed jq: command not found to stderr, so $state was always empty and the EVENT merged / ci_failed / rebase branches could never fire. (The one branch that did work used gh --json ... --jq, i.e. gh's embedded engine, not the missing binary — which masked the problem.)
- The monitor reported as healthy and kept polling. The watched PR actually merged, but EVENT merged was never emitted. Only after manually Read-ing the monitor's output file did ~650 lines of [stderr] jq: command not found become visible.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.218
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
Impact
Agents that rely on Monitor for a terminal condition (PR merged, CI finished/failed, build done, server ready) can hang silently and wait forever. The failure mode is indistinguishable from a healthy monitor that simply hasn't seen its event yet, so the agent has no reason to intervene.
Suggested improvements (any one would help)
- Surface a warning/notification when a monitor emits stderr — especially repeated identical lines, or command not found — while producing no stdout.
- Emit a health warning when the script exits non-zero repeatedly, or when a poll loop produces zero stdout for N intervals.
- Include a short tail of recent stderr in the periodic monitor status.
- Make the "stderr is invisible to the event stream" caveat far more prominent in the tool guidance.