Skip to content

fix: add xhigh effort typing and retain CLI stderr for exit errors#835

Open
oubeichen wants to merge 1 commit intoanthropics:mainfrom
oubeichen:codex/fix-xhigh-effort-typing-stderr
Open

fix: add xhigh effort typing and retain CLI stderr for exit errors#835
oubeichen wants to merge 1 commit intoanthropics:mainfrom
oubeichen:codex/fix-xhigh-effort-typing-stderr

Conversation

@oubeichen
Copy link
Copy Markdown

@oubeichen oubeichen commented Apr 17, 2026

Summary

Add xhigh to the Python SDK effort typing and retain CLI stderr so
non-zero subprocess exits can surface the underlying CLI error text in
ProcessError.

Background

Current Claude Code CLI versions (v2.1.112+) support xhigh as an effort level, but
the Python SDK typing still omitted it from:

  • ClaudeAgentOptions.effort
  • AgentDefinition.effort

That 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 ProcessError with:

Error output: Check stderr output for details

This made CLI-side failures harder to diagnose than necessary.

Changes

Add xhigh to the shared effort typing

Introduce a shared effort level type that includes xhigh, and use it for:

  • ClaudeAgentOptions.effort
  • AgentDefinition.effort

This 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 so
ProcessError can include the CLI error text when the subprocess exits
with 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")
  • CLI command construction for --effort xhigh
  • stderr propagation into ProcessError on subprocess failure

Verified 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.

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.
@oubeichen oubeichen force-pushed the codex/fix-xhigh-effort-typing-stderr branch from 6156d36 to cd73aba Compare April 17, 2026 07:01
@oubeichen oubeichen changed the title fix: support xhigh effort typing and propagate CLI stderr fix: add xhigh effort typing and retain CLI stderr for exit errors Apr 17, 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.

1 participant