fix: add xhigh effort typing and retain CLI stderr for exit errors#835
Open
oubeichen wants to merge 1 commit intoanthropics:mainfrom
Open
fix: add xhigh effort typing and retain CLI stderr for exit errors#835oubeichen wants to merge 1 commit intoanthropics:mainfrom
oubeichen wants to merge 1 commit intoanthropics:mainfrom
Conversation
Add `xhigh` to the shared effort level type so `ClaudeAgentOptions.effort` and `AgentDefinition.effort` stay aligned with current Claude Code CLI support. Keep the existing stderr forwarding behavior in `_handle_stderr()` for callbacks and `debug-to-stderr`, and always pipe stderr so `ProcessError` can include the CLI error text when the subprocess exits with a non-zero status. Fall back to the previous generic error text when no stderr is available to preserve existing caller expectations. Add regression tests covering: - `ClaudeAgentOptions(effort="xhigh")` - `AgentDefinition(effort="xhigh")` - CLI command construction for `--effort xhigh` - stderr propagation into `ProcessError` on subprocess failure Refs anthropics#834.
6156d36 to
cd73aba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
xhighto the Python SDK effort typing and retain CLI stderr sonon-zero subprocess exits can surface the underlying CLI error text in
ProcessError.Background
Current Claude Code CLI versions (v2.1.112+) support
xhighas an effort level, butthe Python SDK typing still omitted it from:
ClaudeAgentOptions.effortAgentDefinition.effortThat left the typed SDK surface out of sync with current CLI behavior.
Separately, when the CLI failed during startup or argument validation,
the SDK raised a generic
ProcessErrorwith:Error output: Check stderr output for detailsThis made CLI-side failures harder to diagnose than necessary.
Changes
Add
xhighto the shared effort typingIntroduce a shared effort level type that includes
xhigh, and use it for:ClaudeAgentOptions.effortAgentDefinition.effortThis keeps the typing aligned with current Claude Code CLI support and
avoids duplicating the allowed literal set in multiple places.
Retain CLI stderr for exit errors
Keep the existing live stderr forwarding behavior in
_handle_stderr()for callbacks and
debug-to-stderr, and always pipe stderr soProcessErrorcan include the CLI error text when the subprocess exitswith a non-zero status.
When no stderr is available, the SDK still falls back to the previous
generic message so existing caller expectations remain unchanged.
Tests
Add regression coverage for:
ClaudeAgentOptions(effort="xhigh")AgentDefinition(effort="xhigh")--effort xhighProcessErroron subprocess failureVerified with:
./.venv/bin/python -m pytest tests/test_types.py tests/test_transport.py tests/test_errors.py -q ./.venv/bin/python -m ruff check src/claude_agent_sdk/types.py src/claude_agent_sdk/_internal/transport/subprocess_cli.py tests/test_types.py tests/test_transport.py Refs #834.