Skip to content

Commit fc7a6de

Browse files
authored
Export EffortLevel type alias (#951)
## Summary - add a public `EffortLevel` type alias for Claude effort string levels - reuse the alias in `AgentDefinition` and `ClaudeAgentOptions` - export the alias from the package root for downstream SDK wrappers Closes #938 ## Testing - `.venv/bin/python -m pytest tests/test_types.py -q` - `.venv/bin/python -m ruff check src/claude_agent_sdk/types.py src/claude_agent_sdk/__init__.py tests/test_types.py` - `.venv/bin/python -m ruff format --check src/claude_agent_sdk/types.py src/claude_agent_sdk/__init__.py tests/test_types.py` - `git diff --check`
1 parent 1a72b69 commit fc7a6de

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/claude_agent_sdk/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
ContextUsageCategory,
6666
ContextUsageResponse,
6767
DeferredToolUse,
68+
EffortLevel,
6869
HookCallback,
6970
HookContext,
7071
HookEventMessage,
@@ -528,6 +529,7 @@ async def call_tool(name: str, arguments: dict[str, Any]) -> Any:
528529
"ClaudeSDKClient",
529530
# Types
530531
"PermissionMode",
532+
"EffortLevel",
531533
"McpServerConfig",
532534
"McpSdkServerConfig",
533535
"McpServerStatus",

src/claude_agent_sdk/types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from collections.abc import Awaitable, Callable
55
from dataclasses import dataclass, field
66
from pathlib import Path
7-
from typing import TYPE_CHECKING, Any, Literal, Protocol
7+
from typing import TYPE_CHECKING, Any, Literal, Protocol, TypeAlias
88

99
if sys.version_info >= (3, 11):
1010
from typing import NotRequired, Required, TypedDict
@@ -30,6 +30,7 @@
3030

3131
# Agent definitions
3232
SettingSource = Literal["user", "project", "local"]
33+
EffortLevel: TypeAlias = Literal["low", "medium", "high", "xhigh", "max"]
3334

3435

3536
class SystemPromptPreset(TypedDict):
@@ -96,7 +97,7 @@ class AgentDefinition:
9697
initialPrompt: str | None = None # noqa: N815
9798
maxTurns: int | None = None # noqa: N815
9899
background: bool | None = None
99-
effort: Literal["low", "medium", "high", "xhigh", "max"] | int | None = None
100+
effort: EffortLevel | int | None = None
100101
permissionMode: PermissionMode | None = None # noqa: N815
101102

102103

@@ -1864,7 +1865,7 @@ class ClaudeAgentOptions:
18641865
See https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking.
18651866
"""
18661867

1867-
effort: Literal["low", "medium", "high", "xhigh", "max"] | None = None
1868+
effort: EffortLevel | None = None
18681869
"""Controls how much effort Claude puts into its response.
18691870
18701871
Works with adaptive thinking to guide thinking depth.

tests/test_types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
"""Tests for Claude SDK type definitions."""
22

3+
from typing import get_args
4+
35
from claude_agent_sdk import (
46
AssistantMessage,
57
ClaudeAgentOptions,
8+
EffortLevel,
69
NotificationHookInput,
710
NotificationHookSpecificOutput,
811
PermissionRequestHookInput,
@@ -24,6 +27,11 @@
2427
)
2528

2629

30+
def test_effort_level_is_exported():
31+
"""EffortLevel is part of the public package API for downstream wrappers."""
32+
assert set(get_args(EffortLevel)) == {"low", "medium", "high", "xhigh", "max"}
33+
34+
2735
class TestPermissionUpdate:
2836
"""Test PermissionUpdate wire-format conversion."""
2937

0 commit comments

Comments
 (0)