Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ venv/
ENV/
env/
.venv
uv.lock

# IDEs
.vscode/
Expand Down
5 changes: 5 additions & 0 deletions src/claude_agent_sdk/_internal/transport/subprocess_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ def _build_command(self) -> list[str]:
# String mode: use --print with the prompt
cmd.extend(["--print", "--", str(self._prompt)])

if self._options.max_thinking_tokens is not None:
cmd.extend(
["--max-thinking-tokens", str(self._options.max_thinking_tokens)]
)

# Check if command line is too long (Windows limitation)
cmd_str = " ".join(cmd)
if len(cmd_str) > _CMD_LENGTH_LIMIT and self._options.agents:
Expand Down
2 changes: 2 additions & 0 deletions src/claude_agent_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ class ClaudeAgentOptions:
setting_sources: list[SettingSource] | None = None
# Plugin configurations for custom plugins
plugins: list[SdkPluginConfig] = field(default_factory=list)
# Max tokens for thinking blocks
max_thinking_tokens: int | None = None


# SDK Control Protocol
Expand Down
11 changes: 11 additions & 0 deletions tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ def test_build_command_with_options(self):
assert "--max-turns" in cmd
assert "5" in cmd

def test_build_command_with_max_thinking_tokens(self):
"""Test building CLI command with max_thinking_tokens option."""
transport = SubprocessCLITransport(
prompt="test",
options=make_options(max_thinking_tokens=5000),
)

cmd = transport._build_command()
assert "--max-thinking-tokens" in cmd
assert "5000" in cmd

def test_build_command_with_add_dirs(self):
"""Test building CLI command with add_dirs option."""
from pathlib import Path
Expand Down