CLAUDE_CODE_SUBAGENT_MODEL acts as hard override — ignores agent frontmatter model and call-level model param (2.1.236)

Status Open
Reported on v2.1.236
Maintainer reply None cached
Activity 0 comments · opened Sep 1, 2026

Summary

With CLAUDE_CODE_SUBAGENT_MODEL set (via project settings.json env or shell env), the subagent model resolution ignores BOTH an agent definition's frontmatter model: field and the Agent tool call's model parameter — the env var acts as a hard override. Documented precedence (sub-agents docs § Model Resolution Order) is: call-level param > frontmatter > CLAUDE_CODE_SUBAGENT_MODEL > inherit.

Environment

  • Claude Code 2.1.236, macOS (darwin 25.6.0)
  • CLAUDE_CODE_SUBAGENT_MODEL=haiku set in project .claude/settings.json env block

Reproduction

  1. Create ~/.claude/agents/model-pin-test-opus.md:
---
name: model-pin-test-opus
description: test agent, answers model identity
tools: Read
model: opus
---
State verbatim which model powers you per your system context. Nothing else.
  1. With the env var set, run:
claude -p --model claude-opus-4-8 "Dispatch agent model-pin-test-opus once with prompt 'state your model'. Relay its reply verbatim."
  1. Subagent replies: "You are powered by the model named Haiku 4.5. The exact model ID is claude-haiku-4-5-20251001." Same result with frontmatter model: claude-fable-5, and same result when the parent passes a call-level model: "opus" param on the Agent tool call.
  1. Re-run identical test with env -u CLAUDE_CODE_SUBAGENT_MODEL: frontmatter pins resolve correctly (opus pin → Opus 4.8, claude-fable-5 pin → Fable 5).

Impact

A project using the env var as a cheap default silently downgrades every typed agent that pins its own model — including plugin agents such as review agents pinning model: sonnet. Quality degradation is invisible: no warning, agents just run on the small model.

Secondary issue

In agent frontmatter, the alias model: fable silently falls back to the default subagent model (no error); the full id model: claude-fable-5 works. Either the alias should resolve (it is accepted by the Agent tool's call-level enum) or an invalid frontmatter value should warn.

View original on GitHub ↗