Skip to content

Commit 4e56cb1

Browse files
ashwin-antclaude
andauthored
feat: add SDK beta support with SdkBeta type and betas option (#390)
Port the SdkBeta type and betas option from the TypeScript SDK to enable SDK users to pass beta feature flags (e.g., 1M context window) to the CLI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent 2437035 commit 4e56cb1

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/claude_agent_sdk/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
SandboxIgnoreViolations,
4343
SandboxNetworkConfig,
4444
SandboxSettings,
45+
SdkBeta,
4546
SdkPluginConfig,
4647
SettingSource,
4748
StopHookInput,
@@ -345,6 +346,8 @@ async def call_tool(name: str, arguments: dict[str, Any]) -> Any:
345346
"SettingSource",
346347
# Plugin support
347348
"SdkPluginConfig",
349+
# Beta support
350+
"SdkBeta",
348351
# Sandbox support
349352
"SandboxSettings",
350353
"SandboxNetworkConfig",

src/claude_agent_sdk/_internal/transport/subprocess_cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def _build_command(self) -> list[str]:
203203
if self._options.fallback_model:
204204
cmd.extend(["--fallback-model", self._options.fallback_model])
205205

206+
if self._options.betas:
207+
cmd.extend(["--betas", ",".join(self._options.betas)])
208+
206209
if self._options.permission_prompt_tool_name:
207210
cmd.extend(
208211
["--permission-prompt-tool", self._options.permission_prompt_tool_name]

src/claude_agent_sdk/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# Permission modes
1515
PermissionMode = Literal["default", "acceptEdits", "plan", "bypassPermissions"]
1616

17+
# SDK Beta features - see https://docs.anthropic.com/en/api/beta-headers
18+
SdkBeta = Literal["context-1m-2025-08-07"]
19+
1720
# Agent definitions
1821
SettingSource = Literal["user", "project", "local"]
1922

@@ -614,6 +617,8 @@ class ClaudeAgentOptions:
614617
disallowed_tools: list[str] = field(default_factory=list)
615618
model: str | None = None
616619
fallback_model: str | None = None
620+
# Beta features - see https://docs.anthropic.com/en/api/beta-headers
621+
betas: list[SdkBeta] = field(default_factory=list)
617622
permission_prompt_tool_name: str | None = None
618623
cwd: str | Path | None = None
619624
cli_path: str | Path | None = None

0 commit comments

Comments
 (0)