Skip to content

[BUG] Custom agent model field in .claude/agents/*.md is not passed to Task tool #26064

@yudaisumie

Description

@yudaisumie

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

問題

カスタムエージェント定義(.claude/agents/*.md)のFrontmatterで model フィールドを指定しても、Task tool呼び出し時に model パラメータとして渡されない。

再現手順

  1. .claude/agents/coder.md を作成:

    ---
    name: coder
    description: コーディング実装・バグ修正専門エージェント
    model: claude-sonnet-4-5-20250929
    tools:
      - Read
      - Edit
      - Write
      - Bash
    ---
    
    あなたはプロジェクトの実装専門エージェントです。
  2. Task toolで subagent_type: "coder" を指定して呼び出す

    • 例: ユーザーが「coderエージェントで実装してください」と指示
  3. 会話ログ(~/.claude/projects/*/[session-id].jsonl)を確認

実際の動作

Task toolの inputmodel パラメータが含まれない:

{
  "name": "Task",
  "input": {
    "description": "...",
    "subagent_type": "coder",
    "prompt": "...",
    "max_turns": 60
    // ⚠️ "model" パラメータが存在しない
  }
}

結果として、サブエージェントは親のモデルを継承する(Task toolドキュメント: "If not specified, inherits from parent.")。

期待される動作

カスタムエージェント定義の model フィールドが、Task toolの model パラメータとして渡される:

{
  "name": "Task",
  "input": {
    "description": "...",
    "subagent_type": "coder",
    "model": "sonnet",  // または完全なモデルID
    "prompt": "...",
    "max_turns": 60
  }
}

これにより、.claude/agents/coder.mdmodel: claude-sonnet-4-5-20250929 と記載した場合、coderエージェントはSonnetで動作する。

影響

  • カスタムエージェントごとに異なるモデルを使い分けることができない
  • サブエージェントは常に親のモデルを継承する
  • 意図したモデルでエージェントを動作させるには、メインエージェントのモデルを手動で切り替える必要がある

ユースケース

プロジェクトで以下のようなカスタムエージェントを定義している場合:

  • architect: Opus 4.6 — 高度な設計・アーキテクチャ策定(読み取り専用)
  • coder: Sonnet 4.5 — コスト効率の良い実装・バグ修正(編集可能)

現在の動作では、architectエージェントもcoderエージェントも親のモデルを継承するため、カスタムエージェント定義の model フィールドが無視される。

環境

  • Claude Code version: 2.1.42
  • Platform: macOS / VSCode extension
  • Plan: MAX(usage-based billing)
  • Date: 2026-02-16

追加情報

  • 同様の問題: settings.jsonの "model": "opusplan" も Plan mode で反映されない(別issue)
  • 会話ログの分析により、Task tool呼び出し時に model パラメータが一貫して欠落していることを確認
  • 総使用量にはカウントされているが、モデル別の使用量(「Sonnetのみ」等)が正確にカウントされない可能性

What Should Happen?

提案される解決策

  1. カスタムエージェント定義の model フィールドを読み取り、Task toolの model パラメータに変換する
  2. モデルIDの形式を正規化(完全なID claude-sonnet-4-5-20250929 → 短縮形 "sonnet"
  3. ドキュメントに現在の動作を明記(カスタムエージェントの model フィールドはサポートされていない)

Error Messages/Logs

Steps to Reproduce

Just manually select models in each workflow.
But can't change model after planning anyways.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.42

Claude Code Version

2.1.42 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Cursor

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatform:macosIssue specifically occurs on macOSplatform:vscodeIssue specifically occurs in VS Code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions