anthropics / anthropics/claude-code
[BUG] opusplan mode overrides subagent model frontmatter, ignoring agent config
- 主要言語
- Python
- スター
- 145k
- フォーク
- 23.1k
- PR マージ指標
- PR 指標を取得中
説明
### Preflight Checklist
- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
### What's Wrong?
opusplan mode overrides custom subagent model value in frontmatter — so a custom Explore agent always runs on Opus regardless of the custom agent config. Also confirmed it was actually using the custom agent definition, so only the model was changed. (It did not use the standard Explore agent that defaults to main session model)
### What Should Happen?
Custom agents (Explore) should run on the model defined in frontmatter regardless of main-conversation model/mode
### Error Messages/Logs
```shell
```
### Steps to Reproduce
1. Define ~/.claude/agents/Explore.md (override) with model: haiku.
2. Set main model to opusplan, invoke a task that spawns Explore.
3. Compare the Explore task's own JSONL transcript (referenced task output under /tmp/claude-*/.../tasks/*.output) — all turns show claude-opus-5, not haiku.
4. Repeat with main model set to plain opus (manual plan-mode toggle) — Explore correctly runs on Haiku.
Custom subagent frontmatter:
```markdown
---
name: Explore
description: Read-only search & exploration agent
model: haiku
tools: Bash, Read
---
```
### Claude Model
Other
### Is this a regression?
I don't know
### Last Working Version
_No response_
### Claude Code Version
2.1.266
### Platform
Anthropic API
### Operating System
macOS
### Terminal/Shell
Terminal.app (macOS)
### Additional Information
- With main model set to plain opus (plan mode toggled manually via Shift+Tab//plan instead of the opusplan alias): Explore runs on Haiku as expected. ✅ (task transcripts all show claude-haiku-4-5-20251001)
- With main model set to opusplan: the identical Explore frontmatter override is silently ignored — Explore runs on claude-opus-5 every time. ❌ (task transcripts both 100% claude-opus-5, zero haiku turns)
- /tasks UI is also misleading in this failure mode: it reported "Haiku" for the Explore row even though the subagent's own transcript proves every API call went to Opus.
Impact: No way to pin subagent models when using opusplan, since it appears to force Opus onto all subagents regardless of their own frontmatter.
Additional context: A PreToolUse hook on the Agent tool that rewrites updatedInput.model for subagent_type == "Explore" was also attempted but logging indicated the main session was not passing in a model override. According to the [docs](https://code.claude.com/docs/en/sub-agents#choose-a-model) if the invocation doesn't specify, it should use the subagent's model frontmatter.
```json
{
"tool_name": "Agent",
"tool_input": {
"subagent_type": "Explore",
"model": null
}
}
```
Related to https://github.com/anthropics/claude-code/issues/67942 - but that one appears to have closed when the Explore agent default changed, it was not fixed.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Reproduce by creating ~/.claude/agents/Explore.md with model: haiku, running with the main model set to opusplan, and checking /tmp/claude-*/.../tasks/*.output for the subagent transcript. Compare against plain opus with manual plan mode. Done means opusplan respects the subagent frontmatter model and the /tasks UI matches the actual transcript model.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- markdown
- 領域
- ai-infra-agents, cli
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 52/100