Skip to content

types: export EffortLevel as a named TypeAlias#940

Open
vibeyclaw wants to merge 1 commit intoanthropics:mainfrom
vibeyclaw:feat/effort-level-type-alias
Open

types: export EffortLevel as a named TypeAlias#940
vibeyclaw wants to merge 1 commit intoanthropics:mainfrom
vibeyclaw:feat/effort-level-type-alias

Conversation

@vibeyclaw
Copy link
Copy Markdown

Summary

Resolves #938.

The effort field's Literal["low", "medium", "high", "xhigh", "max"] was inlined at two use sites in types.pyClaudeAgentOptions (line 99) and ThinkingConfig (line 1867). This PR extracts it into a named TypeAlias called EffortLevel and exports it from __init__.py, following the existing pattern used by PermissionMode, SdkBeta, SettingSource, and other aliases in the same file.

Changes

  • src/claude_agent_sdk/types.py: add EffortLevel TypeAlias near the other named literals at the top of the file; replace the two inline Literal[...] usages with it.
  • src/claude_agent_sdk/__init__.py: import and export EffortLevel alongside PermissionMode.

Why this matters

  1. Single source of truth — downstream wrappers can now write from claude_agent_sdk import EffortLevel instead of copying the literal.
  2. Automatic drift protection — when the literal expands (as "xhigh" did between 0.1.71 and 0.1.77 per ClaudeAgentOptions.effort typings are outdated, and CLI validation failures are surfaced as opaque ProcessError #834), consumers who import EffortLevel pick up the change for free.
  3. Consistency — the same file already exports a dozen similar small literals as named aliases; effort was the only one left inline.

Testing

No behavior change — this is a pure typing refactor. Existing tests should pass unchanged.

The effort field's Literal["low", "medium", "high", "xhigh", "max"] was
inlined at two use sites (ClaudeAgentOptions and ThinkingConfig). This
follows the same pattern already used by PermissionMode, SdkBeta,
SettingSource, and other named type aliases in the same file.

Benefits:
- Single source of truth for downstream consumers who wrap the SDK
- Exported from __init__.py so callers can write
  `from claude_agent_sdk import EffortLevel`
- Any future expansion of the literal (like xhigh in anthropics#834) propagates
  automatically to all users

Closes anthropics#938
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.

Export EffortLevel as a named TypeAlias from claude_agent_sdk.types

1 participant