Skip to content

Conversation

@szwang
Copy link
Collaborator

@szwang szwang commented Nov 7, 2025

Add support for automatic model fallback when primary model is overloaded. The Python SDK passes the fallback_model parameter to the Claude CLI, which handles the validation and fallback logic.

Changes:

  • Add fallback_model parameter to ClaudeAgentOptions
  • Pass --fallback-model to CLI subprocess
  • Add test for fallback model command building

The validation that fallback_model != model happens at the CLI layer, keeping the SDK implementation simple and focused on parameter passing.

Add support for automatic model fallback when primary model is overloaded.
The Python SDK passes the fallback_model parameter to the Claude CLI,
which handles the validation and fallback logic.

Changes:
- Add fallback_model parameter to ClaudeAgentOptions
- Pass --fallback-model to CLI subprocess
- Add test for fallback model command building
- Add example demonstrating fallback model usage
- Add implementation documentation

The validation that fallback_model != model happens at the CLI layer,
keeping the SDK implementation simple and focused on parameter passing.
Use model shorthands 'opus' and 'sonnet' instead of non-existent
'claude-opus-4-5' model name in the fallback model example and test.
The example cannot reliably demonstrate the actual fallback behavior
since Opus overload is not guaranteed during example execution. The test
coverage is sufficient to show how to use the fallback_model parameter.
@szwang szwang requested a review from dltn November 7, 2025 14:13
@szwang szwang changed the title Add fallback model handling like TypeScript SDK Add fallback model handling for parity with TypeScript SDK Nov 7, 2025
@szwang szwang merged commit ff425b2 into main Nov 7, 2025
43 of 52 checks passed
@szwang szwang deleted the claude/add-fallback-model-011CUtd3KGkDTCQuhzwxy89s branch November 7, 2025 19:25
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.

4 participants