[BUG] Sub agents are not getting the custom model in SDK / CLI
Environment
- Platform (select one):
LiteLLM proxy with environment variables like ANTHROPIC_MODEL, ANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN
- Claude CLI version: 1.0.77
- Operating System: MacOS
- Terminal: iTerm2
Bug Description
I have environment variables set to point at a LiteLLM proxy.
This works well with claude code interactively and the subagents work correctly.
But when using Claude Code SDK in Python or with claude -p, the main agent works but the subagents seem to use the default model:
[ERROR] Error streaming, falling back to non-streaming mode: 400 {"error":{"message":"400: {'error': 'completion: Invalid model name passed in model=claude-sonnet-4-20250514'}","type":"None","param":"None","code":"400"}}
[ERROR] Error in non-streaming fallback: 400 {"error":{"message":"400: {'error': 'completion: Invalid model name passed in model=claude-sonnet-4-20250514'}","type":"None","param":"None","code":"400"}}
Steps to Reproduce
- Create a sub agent
- Set env vars for LiteLLM use
- Test claude interactively - works
- Test subagents in claude interactively - works
- test claude -p without calling sub agent - works
- test calude -p calling the subagent - subagents refer to default model
Expected Behavior
Subagents should utilize the model set in settings or the env vars
Actual Behavior
Sub agents don't use the model set.
Additional Context
<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗