Skip to content

Conversation

@ihanikos
Copy link

When the CLI subprocess exits with non-zero code, ProcessError was raised with stderr="Check stderr output for details" instead of the actual stderr content. This makes debugging impossible since real error messages (e.g. "No conversation found with session ID") are never surfaced.

Changes:

  • Add _stderr_lines buffer to collect all stderr output
  • Drain stderr task group before checking exit code
  • Pass collected stderr content to ProcessError

Fixes #437

When the CLI subprocess exits with non-zero code, ProcessError was raised
with stderr="Check stderr output for details" instead of the actual stderr
content. This makes debugging impossible since real error messages (e.g.
"No conversation found with session ID") are never surfaced.

Changes:
- Add _stderr_lines buffer to collect all stderr output
- Drain stderr task group before checking exit code
- Pass collected stderr content to ProcessError

Fixes anthropics#437
stderr was only piped when a callback or debug mode was set. Without
either, stderr went to the terminal and _stderr_lines stayed empty,
making the ProcessError fix ineffective.
The CLI sends an 'errors' list in result messages (e.g. when a session
cannot be found), but ResultMessage was missing this field so the error
details were silently dropped during parsing.
phil65 added a commit to phil65/claude-agent-sdk-python that referenced this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude-agent-sdk swallows API error messages, returns unhelpful "Unknown error"

1 participant