anthropics / anthropics/claude-code

[BUG] opusplan mode overrides subagent model frontmatter, ignoring agent config

Aperta
#93,157 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Python
Stelle
145k
Fork
23.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

### 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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
markdown
Ambito
ai-infra-agents, cli
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.