CLAUDE_CODE_SUBAGENT_MODEL

Updated by

CLAUDE_CODE_SUBAGENT_MODEL sets the fallback model for subagents, agent team teammates and workflow agents that get no model from the Agent call or their definition. Default: unset, so subagents inherit the main conversation's model. Values: an alias (sonnet, opus, haiku, fable) or a full model ID; inherit is the same as unset. Present since v2.1.69 or earlier and still present in v2.1.332. It is listed in the official reference.

StatusPresent in v2.1.332
AddedPresent since v2.1.69 or earlier
Defaultunset, so subagents inherit the main conversation's model
Valuesan alias (sonnet, opus, haiku, fable) or a full model ID; inherit is the same as unset
CategoryAgents and subagents
Official docsListed
Checked againstv2.1.330

How to set it

For one session, export it in the shell that starts Claude Code:

export CLAUDE_CODE_SUBAGENT_MODEL=haiku
claude

Haiku runs subagents that set no model of their own on Haiku to cut cost.

To apply it to every session, add it to the env object of a settings file:

// ~/.claude/settings.json
{
  "env": {
    "CLAUDE_CODE_SUBAGENT_MODEL": "haiku"
  }
}

Known issues

  • Since v2.1.251 a model Claude passes on the Agent call and a model field in the agent definition, including inherit, both win over this variable. Set CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 (v2.1.257+) to force one model on every subagent. Source: docs: subagents.
  • Setting it alone does not change the built-in Explore and Plan subagents, which name their own model. Source: docs: subagents.
  • An open report says the value from the settings env block was ignored in a v2.1.263 -p run while the same value from the shell worked; check the subagent transcript's model field to confirm. Source: issue #43869.

Release notes that mention it

Related variables

Frequently asked questions

What does CLAUDE_CODE_SUBAGENT_MODEL do?

Sets the fallback model for subagents, agent team teammates and workflow agents that get no model from the Agent call or their definition.

What is the default value of CLAUDE_CODE_SUBAGENT_MODEL?

Unset, so subagents inherit the main conversation's model.

What values does CLAUDE_CODE_SUBAGENT_MODEL accept?

An alias (sonnet, opus, haiku, fable) or a full model ID; inherit is the same as unset.

Which Claude Code version has CLAUDE_CODE_SUBAGENT_MODEL?

Present since v2.1.69 or earlier and still present in v2.1.332.

How do I set CLAUDE_CODE_SUBAGENT_MODEL?

Export it before starting Claude Code (export CLAUDE_CODE_SUBAGENT_MODEL=haiku), or add it to the "env" object in ~/.claude/settings.json to apply it to every session. Haiku runs subagents that set no model of their own on Haiku to cut cost.

All variables, searchable: Claude Code environment variables.