[BUG] Sub agents are not getting the custom model in SDK / CLI

Resolved 💬 3 comments Opened Aug 13, 2025 by manojlds Closed Aug 19, 2025

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

  1. Create a sub agent
  2. Set env vars for LiteLLM use
  3. Test claude interactively - works
  4. Test subagents in claude interactively - works
  5. test claude -p without calling sub agent - works
  6. 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. -->

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗