Skip to content

Commit 04a39ac

Browse files
qing-antclaude
andauthored
feat(types): add "xhigh" to effort Literal (#914)
## Summary Adds `"xhigh"` to the `effort` `Literal` on both `ClaudeAgentOptions` and `AgentDefinition`, matching the CLI (`claude --help` lists `low, medium, high, xhigh, max`) and the TypeScript SDK's `EffortLevel` type. The docstring is updated to note that `xhigh` is Opus 4.7-specific and falls back to `high` on other models. Previously, type checkers rejected `ClaudeAgentOptions(effort="xhigh")` even though the CLI supports it: ``` error: Argument "effort" to "ClaudeAgentOptions" has incompatible type "Literal['xhigh']"; expected "Literal['low', 'medium', 'high', 'max'] | None" ``` Addresses the typing half of #834. The error-surfacing half (CLI validation failures surface as opaque `ProcessError` without stderr) overlaps with #798. ## Relationship to #835 #835 also adds `xhigh` plus stderr retention, but is based on a pre-#885 main and now conflicts (it touches `_stderr_task_group`, which #885 removed). This PR is the minimal, conflict-free typing-only fix; the stderr work can land via #828 or a rebased #835. ## Tests - New `test_effort_accepts_xhigh_level` (AgentDefinition serialization) and `test_build_command_with_effort_xhigh` (CLI flag construction). - Full suite: 718 passed, 2 pre-existing failures in `test_transcript_mirror.py` (eager-flush, from #905) — same baseline as #908/#909/#911/#912. - `ruff check` / `ruff format`: clean. - `mypy src/`: clean. - Live e2e proof in PR comment below. ## Changelog ### New Features - Added `"xhigh"` to the `effort` Literal on `ClaudeAgentOptions` and `AgentDefinition` (#914) --- _Generated by [Claude Code](https://claude.ai/code/session_012Qn9YazWceoUqnjM74eJvU)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3caf665 commit 04a39ac

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/claude_agent_sdk/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class AgentDefinition:
9595
initialPrompt: str | None = None # noqa: N815
9696
maxTurns: int | None = None # noqa: N815
9797
background: bool | None = None
98-
effort: Literal["low", "medium", "high", "max"] | int | None = None
98+
effort: Literal["low", "medium", "high", "xhigh", "max"] | int | None = None
9999
permissionMode: PermissionMode | None = None # noqa: N815
100100

101101

@@ -1776,14 +1776,16 @@ class ClaudeAgentOptions:
17761776
See https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking.
17771777
"""
17781778

1779-
effort: Literal["low", "medium", "high", "max"] | None = None
1779+
effort: Literal["low", "medium", "high", "xhigh", "max"] | None = None
17801780
"""Controls how much effort Claude puts into its response.
17811781
17821782
Works with adaptive thinking to guide thinking depth.
17831783
17841784
- ``"low"`` — Minimal thinking, fastest responses.
17851785
- ``"medium"`` — Moderate thinking.
17861786
- ``"high"`` — Deep reasoning (default).
1787+
- ``"xhigh"`` — Extended reasoning depth (Opus 4.7 only; falls back to
1788+
``"high"`` on other models).
17871789
- ``"max"`` — Maximum effort.
17881790
17891791
See https://docs.anthropic.com/en/docs/build-with-claude/effort.

tests/test_transport.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ def test_cli_path_accepts_pathlib_path(self):
101101
# Path object is converted to string, compare with str(path)
102102
assert transport._cli_path == str(path)
103103

104+
def test_build_command_with_effort_xhigh(self):
105+
transport = SubprocessCLITransport(
106+
prompt="test",
107+
options=make_options(effort="xhigh"),
108+
)
109+
110+
cmd = transport._build_command()
111+
assert "--effort" in cmd
112+
assert cmd[cmd.index("--effort") + 1] == "xhigh"
113+
104114
def test_build_command_with_system_prompt_string(self):
105115
"""Test building CLI command with system prompt as string."""
106116
transport = SubprocessCLITransport(

tests/test_types.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,18 @@ def test_effort_accepts_named_level(self):
599599

600600
assert payload["effort"] == "high"
601601

602+
def test_effort_accepts_xhigh_level(self):
603+
from claude_agent_sdk import AgentDefinition
604+
605+
agent = AgentDefinition(
606+
description="test",
607+
prompt="p",
608+
effort="xhigh",
609+
)
610+
payload = self._serialize(agent)
611+
612+
assert payload["effort"] == "xhigh"
613+
602614
def test_effort_accepts_integer(self):
603615
from claude_agent_sdk import AgentDefinition
604616

0 commit comments

Comments
 (0)