Skip to content

fix(claude): pin Explore/Plan subagents off the inherited Opus model - #172

Merged
edge2992 merged 1 commit into
mainfrom
fix/subagent-model-pinning
Aug 6, 2026
Merged

fix(claude): pin Explore/Plan subagents off the inherited Opus model#172
edge2992 merged 1 commit into
mainfrom
fix/subagent-model-pinning

Conversation

@edge2992

@edge2992 edge2992 commented Aug 6, 2026

Copy link
Copy Markdown
Owner

問題

「subagent を作ると親の model (Opus) を引き継いでしまう」という症状を実測で切り分けた。

同一セッションでサブエージェントを3体投げ、~/.claude/projects/<proj>/<session>/subagents/agent-*.jsonl.message.model を確認:

呼び出し 実際に走ったモデル 判定
Explore + model: "haiku" 明示 claude-haiku-4-5 OK
search-specialist(frontmatter model: haiku claude-haiku-4-5 OK
Explore(model 未指定) claude-opus-5 NG

frontmatter も Agent の model パラメータも正常に機能していた。壊れていたのは組み込み Explore / Plan のみ。

原因

  • v2.1.198 以降、組み込み Explore / Plan は「main の会話モデルを継承」に変更された(それ以前は常に Haiku)。
  • Anthropic API では継承値に Opus 上限キャップが掛かるが、Bedrock ではキャップが掛からず main のモデルが直接継承される
  • さらに Explore / Plan は CLAUDE.md を読み込まない唯一のエージェント。既存の「always set model explicitly」ルールは原理的に届かない。
  • 公式ドキュメントの解決策: 同名の user/project subagent 定義が組み込みを上書きし、その model フィールドが有効になる。

変更

  • dot_claude/agents/Explore.md を追加(model: haiku、read-only tools)
  • dot_claude/agents/Plan.md を追加(model: sonnet、read-only tools)
  • dot_claude/CLAUDE.md: Explore / Plan には CLAUDE.md ルールが届かず、上記定義が backstop であることを明記(将来これらを消さないための理由付け)
  • .chezmoitemplates/claude-settings-base.json: ANTHROPIC_DEFAULT_SONNET_MODEL を削除。us.anthropic.* は Bedrock 専用IDで、base は subscribe 契約のマシンと共有されるため。sonnet / haiku 両方の pin は machine-local な overlay (~/.config/claude-overlay/overlay.jsonnet) に移した(env+ マージなので実効値は不変)

CLAUDE_CODE_SUBAGENT_MODEL は採用しなかった。frontmatter と model パラメータの両方を上書きするため、code-reviewer や実装エージェントまで一律に安いモデルへ落ちてしまう。

検証

  • make lint 全項目 pass(JSON / rendered template / merge-patch / Brewfile overlay)
  • chezmoi diff --source の semantic diff で意図した差分のみを確認: env.ANTHROPIC_DEFAULT_HAIKU_MODEL の追加のみ(modeleffortLevel の2件は本 PR と無関係な既存のライブドリフト)
  • マージ後の apply で、model 未指定の Exploreclaude-haiku-4-5-*Planclaude-sonnet-5 になることをトランスクリプトで実測確認する

Since v2.1.198 the built-in Explore and Plan subagents inherit the main
conversation's model instead of running on Haiku. On the Anthropic API that
inheritance is capped at Opus, but on Bedrock no cap applies, so exploration
and plan research ran on Opus 5 whenever the session did.

The existing CLAUDE.md rule ("always set model explicitly") cannot fix this:
Explore and Plan are the only subagents that skip CLAUDE.md entirely, so the
instruction never reaches them. Measured in a live session — an Explore call
with no model parameter ran on claude-opus-5, while search-specialist (which
has model: haiku in its frontmatter) correctly ran on claude-haiku-4-5.

Add same-named user subagent definitions, which override the built-ins and
keep their own model field, and record in CLAUDE.md why the rule above needs
this backstop.

Also drop ANTHROPIC_DEFAULT_SONNET_MODEL from the settings base template: a
us.anthropic.* ID is Bedrock-only and the base is shared with subscribe
accounts. Both the sonnet and the new haiku pin now live in the machine-local
overlay, so the effective value is unchanged.
@edge2992
edge2992 merged commit 5d5f72b into main Aug 6, 2026
9 checks passed
edge2992 added a commit that referenced this pull request Aug 6, 2026
The `haiku` / `sonnet` aliases in the Explore and Plan override definitions
added in #172 had no effect. Verified on Bedrock with a marker in the
description: the override files load (the custom description reaches the
agent) but the bare alias in `model:` is silently ignored, and both agents
still ran on claude-opus-5.

Version-form IDs resolve correctly — measured claude-haiku-4-5-20251001 for
Explore and claude-sonnet-5 for Plan. This form is provider-neutral, so it
stays valid on subscribe accounts too, unlike a us.anthropic.* ID.
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.

1 participant