Skip to content

feat: export EffortLevel as a named TypeAlias#939

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

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

Conversation

@algojogacor
Copy link
Copy Markdown

Summary

Fixes #938

Extracts the inline Literal[low, medium, high, xhigh, max] into a named EffortLevel TypeAlias, matching the existing pattern used by other literals in the codebase (PermissionMode, SettingSource, SdkBeta, McpServerConnectionStatus, etc.).

Why

  1. Single source of truth — downstream SDK wrappers currently must inline the same Literal[...] type, which drifts when values change (e.g. xhigh was added between 0.1.71 and 0.1.77). With an exported alias, consumers can from claude_agent_sdk import EffortLevel and stay in sync automatically.

  2. Consistency — the same file already exports several similar small literals as named aliases. effort was the only one inlined at use sites.

  3. Future-proofing — when the literal values expand again, only the alias definition needs updating.

Changes

  • src/claude_agent_sdk/types.py:
    • Added TypeAlias to typing imports
    • Added EffortLevel: TypeAlias = Literal[low, medium, high, xhigh, max]
    • Updated ClaudeAgentOptions.effort (line 99) to use EffortLevel
    • Updated ThinkingConfig.effort (line 1867) to use EffortLevel
  • src/claude_agent_sdk/__init__.py:
    • Added EffortLevel to imports and __all__

Testing

  • ruff check passes with no errors
  • Type compatibility is preserved (the alias resolves to the same Literal[...] at runtime)

Extract the inline Literal['low', 'medium', 'high', 'xhigh', 'max']
into a named EffortLevel TypeAlias, matching the pattern used by other
permission/configuration literals (PermissionMode, SettingSource, etc.).

This provides a single source of truth for downstream consumers wrapping
the SDK, avoiding drift when the literal values change across versions.

Changes:
- Added EffortLevel TypeAlias to types.py
- Updated ClaudeAgentOptions.effort and ThinkingConfig.effort to use it
- Exported from __init__.py and __all__

Fixes 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