diff --git a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py index 0fc02b56..d669a412 100644 --- a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py +++ b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py @@ -125,6 +125,9 @@ def _build_command(self) -> list[str]: if self._options.model: cmd.extend(["--model", self._options.model]) + if self._options.fallback_model: + cmd.extend(["--fallback-model", self._options.fallback_model]) + if self._options.permission_prompt_tool_name: cmd.extend( ["--permission-prompt-tool", self._options.permission_prompt_tool_name] diff --git a/src/claude_agent_sdk/types.py b/src/claude_agent_sdk/types.py index 17c1a986..e375bee2 100644 --- a/src/claude_agent_sdk/types.py +++ b/src/claude_agent_sdk/types.py @@ -521,6 +521,7 @@ class ClaudeAgentOptions: max_budget_usd: float | None = None disallowed_tools: list[str] = field(default_factory=list) model: str | None = None + fallback_model: str | None = None permission_prompt_tool_name: str | None = None cwd: str | Path | None = None cli_path: str | Path | None = None diff --git a/tests/test_transport.py b/tests/test_transport.py index dc6c980a..a5a80d0f 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -131,6 +131,22 @@ def test_build_command_with_options(self): assert "--max-turns" in cmd assert "5" in cmd + def test_build_command_with_fallback_model(self): + """Test building CLI command with fallback_model option.""" + transport = SubprocessCLITransport( + prompt="test", + options=make_options( + model="opus", + fallback_model="sonnet", + ), + ) + + cmd = transport._build_command() + assert "--model" in cmd + assert "opus" in cmd + assert "--fallback-model" in cmd + assert "sonnet" in cmd + def test_build_command_with_max_thinking_tokens(self): """Test building CLI command with max_thinking_tokens option.""" transport = SubprocessCLITransport(