Skip to content

Commit 841ee87

Browse files
authored
Add 'auto' to PermissionMode type (#785)
## Summary Adds `"auto"` to the `PermissionMode` Literal type, bringing the Python SDK to parity with the TypeScript SDK (v0.2.91) and the CLI's `EXTERNAL_PERMISSION_MODES`. ## Problem The CLI binary (v2.1.90+) and the TypeScript SDK (v0.2.91) both support `"auto"` as a valid permission mode, but the Python SDK's `PermissionMode` type doesn't include it. Users who set `permission_mode="auto"` get a type error even though the underlying CLI accepts it. ## Changes - `src/claude_agent_sdk/types.py`: Added `"auto"` to `PermissionMode = Literal[...]` - `tests/test_types.py`: Added test case for `permission_mode="auto"` in `test_claude_code_options_with_permission_mode` ## Verification - Confirmed `'auto'` is in `EXTERNAL_PERMISSION_MODES` in the CLI source (`src/types/permissions.ts`) - Confirmed TypeScript SDK v0.2.91 already added `'auto'` to its public `PermissionMode` type - The Python SDK passes `permission_mode` as `--permission-mode <value>` to the CLI subprocess with no SDK-side validation — this is purely a type annotation fix
1 parent 13f65c8 commit 841ee87

4 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/claude_agent_sdk/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ async def set_permission_mode(self, mode: PermissionMode) -> None:
252252
- 'plan': Plan-only mode (no tool execution)
253253
- 'bypassPermissions': Allow all tools (use with caution)
254254
- 'dontAsk': Allow all tools without prompting
255+
- 'auto': Automatically determine permission mode
255256
256257
Example:
257258
```python

src/claude_agent_sdk/query.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ async def query(
5858
- 'plan': Plan-only mode (no tool execution)
5959
- 'bypassPermissions': Allow all tools (use with caution)
6060
- 'dontAsk': Allow all tools without prompting
61+
- 'auto': Automatically determine permission mode
6162
Set options.cwd for working directory.
6263
transport: Optional transport implementation. If provided, this will be used
6364
instead of the default transport selection based on options.

src/claude_agent_sdk/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# Permission modes
2424
PermissionMode = Literal[
25-
"default", "acceptEdits", "plan", "bypassPermissions", "dontAsk"
25+
"default", "acceptEdits", "plan", "bypassPermissions", "dontAsk", "auto"
2626
]
2727

2828
# SDK Beta features - see https://docs.anthropic.com/en/api/beta-headers

tests/test_types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def test_claude_code_options_with_permission_mode(self):
118118
options_dont_ask = ClaudeAgentOptions(permission_mode="dontAsk")
119119
assert options_dont_ask.permission_mode == "dontAsk"
120120

121+
options_auto = ClaudeAgentOptions(permission_mode="auto")
122+
assert options_auto.permission_mode == "auto"
123+
121124
def test_claude_code_options_with_system_prompt_string(self):
122125
"""Test Options with system prompt as string."""
123126
options = ClaudeAgentOptions(

0 commit comments

Comments
 (0)