# Claude Code主模型设为Opus 4.6时调用Opus 5子Agent的方式

**URL:** <https://linux.do/t/topic/2722792>\
**Category:** 开发调优\
**Tags:** 人工智能\
**Created:** [2026 年8 月 8 日 04:08 UTC](https://linux.do/t/topic/2722792 "2026-08-08T04:08:24Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![GanDoorling](https://cdn.ldstatic.com/user_avatar/linux.do/gandoorling/32/1939585_2.png) [@GanDoorling](https://linux.do/u/GanDoorling)\
发布日期： [2026 年8 月 8 日 04:08 UTC](https://linux.do/t/topic/2722792/1 "2026-08-08T04:08:24Z")

</div>

个人体验发现 Opus 4.6 的写作能力和文风是目前 A÷ 系列模型里最好的，AI 味相对较少，对话中很少不说人话。Opus 4.7 之后的模型却做不到（Opus 4.5 本来更好，但已被官方停用）。所以我设置了 Claude Code 的主会话默认模型为 Opus 4.6，需要更强推理和编程能力时再派 Opus 5 子 Agent 去干活或者拓展思考。

但新版 CC 调用子 Agent 的工具限制 `model` 参数只接受别名枚举（`sonnet`/`opus`/`haiku`/`fable`），不接受完整 model ID。主会话是 Opus 4.6 时，`model:"opus"` 解析出来的还是 Opus 4.6，无法切换到 Opus 5。

绕过方法为用 `.claude/agents/` 自定义 Agent 定义文件。比如在 `.claude/agents/opus5.md` 里写为：

```markdown
---
name: opus5
description: General-purpose agent pinned to Claude Opus 5
model: claude-opus-5
---

You are a general-purpose agent powered by Claude Opus. Execute the task given in the prompt thoroughly and precisely. Return results directly — no preamble, no trailing summary.

```

frontmatter 的 `model` 字段支持完整 model ID，不受别名枚举限制。文件建好后重启 CC 生效。

然后可以在 CLAUDE.md 里加一段，让主会话模型知道怎么用：

```markdown
## 子 Agent 模型切换

- Agent 工具的 `model` 参数只支持别名（sonnet/opus/haiku/fable），无法区分同系列版本（如 Opus 4.6 vs 5）
- 需要指定模型版本时，用 `.claude/agents/` 下的自定义 Agent 定义文件，通过 `subagent_type` 调用
- 当前可用：`subagent_type:"opus5"` → Claude Opus 5

```

验证方式：查本地 JSONL 日志（`subagents/*.jsonl`），API 响应里 `message.model` 字段返回 `claude-opus-5`（服务端返回）。

## 附：CC 自己总结的三种子 Agent 模型指定方式对比

| 方式 | 支持完整 model ID | 优先级 |
| --- | --- | --- |
| `CLAUDE_CODE_SUBAGENT_MODEL` 环境变量 | 是 | 最高（覆盖一切，不推荐） |
| `.claude/agents/*.md` frontmatter `model` | 是 | 中 |
| Agent 工具 `model` 参数 | 否（枚举限制） | 低 |

注意不要在 `.claude/settings.json` 里设置 `CLAUDE_CODE_SUBAGENT_MODEL` 环境变量，它会覆盖所有子 Agent 的模型选择，导致无法按需切换。

---

_[View the full topic](https://linux.do/t/topic/2722792)._
