Claude Code subagents: set model: haiku and tools in .claude/agents

Claude Code subagents: set model: haiku and tools in .claude/agents

Mihai Perdum
Mihai Perdum
Author

9 min readNovember 28, 2026

Key takeaways

  • A 4-line frontmatter (name, description, tools, model) in .claude/agents/todo-finder.md was enough for Claude to delegate to it by name.
  • The main session ran on claude-opus-5-5; the subagent's metadata file and every assistant line in its transcript say claude-haiku-5-5.
  • With tools: Grep, Read the subagent made exactly 1 tool call, a Grep, and found both TODO lines in calc.py (lines 2 and 5).
  • Grep also matched the word TODO inside the agent's own .md file; the main session noticed and left it out of the count of 2.

A Claude Code subagent runs on the model named in the model: line of its file in .claude/agents/, unless Claude passes a model of its own when it starts it. You can check which model really ran in the subagent's own transcript under ~/.claude/projects/. Google's suggestions for "claude code subagents" on 24 November 2026 include "model" and "model selection", and on GitHub issue #10993 (closed for inactivity in January) asked how the model field and the CLAUDE_CODE_SUBAGENT_MODEL setting interact. Below is a run that shows both the file and the check.

A subagent is a helper Claude starts for one task. It works in its own context window, with its own instructions. You can give it its own model and a short list of tools. When it's done it hands one answer back, and the main conversation never sees its searching and reading. You define one as a Markdown file with YAML frontmatter (a few settings lines between two --- lines) in .claude/agents/.

I wanted the answer from a run, so we wrote a subagent that finds TODO comments, told it to use Haiku and only two tools, and ran it from a session on Opus. Everything below comes from that run: Claude Code 2.1.330 on macOS 27.2.1, 24 November 2026.

Note

Prerequisites: Claude Code installed and signed in (claude --version printed 2.1.330 for us), on a plan that can use Haiku. A terminal. About 10 minutes.

Claude Code subagent frontmatter: the model and tools fields

From the subagents page of the Claude Code docs, the four you'll set first:

Field

What it does

If you leave it out

name

The id Claude and you use to call the agent

Required

description

When Claude should hand work to it

Required

tools

Comma-separated list of the tools the agent may use

It inherits every tool available to subagents; in background mode, the default, that is a smaller built-in set than a foreground subagent gets

model

sonnet, opus, haiku, fable, inherit or a full model id

Claude Code walks its model order (below) and ends at the main conversation's model

inherit means the subagent uses whatever model the main conversation uses. When more than one thing names a model, the docs give an order in which the first match wins. First comes a model that Claude itself passes when it starts the subagent. Then the model field in your agent file. Then the CLAUDE_CODE_SUBAGENT_MODEL environment variable. Last, the main conversation's model.

The exception is CLAUDE_CODE_SUBAGENT_MODEL_FORCE set to 1 (Claude Code 2.1.257 or later): then Claude Code ignores the model field and Claude can't pass a model, so CLAUDE_CODE_SUBAGENT_MODEL wins. Set FORCE alone and subagents run on the main conversation's model.

That order is newer than many forum answers. The Claude Code changelog entry for 2.1.251 says the environment variable used to override everything and now only sets the default. It isn't set in our settings.json or shell.

Build and run the subagent

  1. 1

    Create the project

    a folder with a Python file holding two TODO comments. Result: grep -n TODO calc.py prints lines 2 and 5.

  2. 2

    Write .claude/agents/todo-finder.md

    frontmatter with tools: Grep, Read and model: haiku, then the instructions. Result: head -6 shows the four settings between two --- lines.

  3. 3

    Ask Claude to use the agent

    start claude, then name the agent in your request. Result: Claude reports the two TODO lines from calc.py.

  4. 4

    Check which model ran

    run cat on the subagent's .meta.json file, then the grep over its transcript. Result: "model":"claude-haiku-5-5" in both.

  5. 5

    Check which tools it used

    run the grep that lists the subagent's tool calls. Result: one Grep call and the handback.

Step 1: Create the project

  1. In a terminal, run:
bash
1mkdir agents-demo && cd agents-demo
2printf 'def add(a, b):\n    # TODO: handle strings\n    return a + b\n\n# TODO: add a subtract function\n' > calc.py
3grep -n TODO calc.py
  1. You should see:
text
12:    # TODO: handle strings
25:# TODO: add a subtract function

Step 2: Write the agent file

  1. Make the folder:
bash
1mkdir -p .claude/agents
  1. Save this as .claude/agents/todo-finder.md:
markdown
1---
2name: todo-finder
3description: Finds TODO comments in the project and lists them with file and line. Use when the user asks what is left to do in the code.
4tools: Grep, Read
5model: haiku
6---
7
8You list TODO comments. Search the project with Grep for the text TODO.
9Answer with one line per hit in the form `<file>:<line>: <comment text>`, then one line with the total count.
10Do not edit any file.
  1. Check it: head -6 .claude/agents/todo-finder.md should show the four settings lines between two --- lines.

Everything after the closing --- becomes the subagent's instructions. Claude decides when to hand work over from the name and the description, as the docs put it: "Claude uses each subagent's description to decide when to delegate tasks".

A file in .claude/agents/ belongs to the project. Put it in ~/.claude/agents/ and you get it in your other projects on this machine too.

Step 3: Ask Claude to use the agent

  1. Start Claude Code in the folder:
bash
1claude
  1. If Claude Code asks whether you trust the folder, accept. Our session ran in auto permission mode (the mode where Claude runs commands without asking each time; Shift+Tab cycles the modes); if yours asks to approve a step, approve it.
  2. Type:
text
1Use the todo-finder agent to list what is left to do in this project.
  1. You should see Claude start the agent and then report two TODOs. In our run Claude called the Agent tool with "subagent_type": "todo-finder" and a brief of its own, and first replied that it had started the agent in the background.

That brief widened the search. Besides TODO it asked for FIXME (a note marking broken code), XXX (the same idea) and HACK. The agent file asks for TODO only. The prompt Claude writes when it starts a subagent reaches the subagent next to its instructions. So Claude's brief can widen what the agent does.

When the subagent finished, the main session answered (lines left out are marked ...):

text
1There are 2 TODOs left in the project, both in `calc.py`:
2
3- `calc.py:2`: handle strings
4- `calc.py:5`: add a subtract function
5
6...
7
8The agent's own definition file, `.claude/agents/todo-finder.md`, also contains the word "TODO", but only in its instructions, so it wasn't counted.
9
10...

The agent's own definition file contains the word TODO, and Grep found it. I think that one is worth remembering. When you search a project for a word, your .claude folder is part of the project.

A blue robot at a desk holds a magnifying glass while a small yellow robot in red running shoes hurries toward a stack of printed pages
Illustration, generated locally with ERNIE-Image. The main session wrote a brief and handed the search to todo-finder. The manager keeps the big desk; the runner gets the cheaper shoes.

Step 4: Check which model ran

Claude Code saves each session as a JSON Lines file under ~/.claude/projects/, in a folder named after the project path. Subagents get a subagents folder inside a folder named after the session id, with a transcript and a small metadata file per run.

  1. Exit Claude (/exit), then run:
bash
1ls ~/.claude/projects/*agents-demo*/*/subagents/
2cat ~/.claude/projects/*agents-demo*/*/subagents/*.meta.json
  1. You should see a .jsonl and a .meta.json file, and "model":"claude-haiku-5-5" in the metadata. Ours:
text
1agent-adf7691bc2ef72df7.jsonl
2agent-adf7691bc2ef72df7.meta.json
3{"agentType":"todo-finder","isBuiltIn":false,"launchedWithDefaults":true,"description":"Find TODOs in project","toolUseId":"toolu_013vK6PzkLtsjaNSwAXN1W5Q","spawnDepth":1,"requestShape":"background","requestNonInteractive":true,"model":"claude-haiku-5-5","pickedEffortModel":"claude-opus-5-5","finished":true}

Your ids will differ. haiku in the frontmatter became the full model id. Right model. Right file. The same file also has "pickedEffortModel":"claude-opus-5-5", a field the docs don't describe; it matches the main session's model.

I wouldn't stop at the metadata file. An open issue, #85592, reports that it records the model that was requested, which can differ from the one that ran. The subagent's own replies settle it.

  1. Run this. The first grep keeps only the lines Claude wrote ("type":"assistant"), because the request lines in the same file also mention the main session's model:
bash
1grep '"type":"assistant"' ~/.claude/projects/*agents-demo*/*/subagents/agent-*.jsonl | grep -o '"model":"[^"]*"' | sort | uniq -c
  1. You should see one line, with every count on claude-haiku-5-5. Ours:
text
1   3 "model":"claude-haiku-5-5"

Your count will differ: each line in the file is one block of a reply (thinking, text or a tool call), and a second run of ours printed 5. What matters is that the lines say haiku and nothing else. I'd trust these lines over the metadata file.

Step 5: Check which tools it used

  1. Run:
bash
1grep '"type":"assistant"' ~/.claude/projects/*agents-demo*/*/subagents/agent-*.jsonl | grep -o '"type":"tool_use","id":"[^"]*","name":"[^"]*"' | grep -o '"name":"[^"]*"' | sort | uniq -c
  1. You should see one Grep and one SubagentHandback. Ours:
text
1   1 "name":"Grep"
2   1 "name":"SubagentHandback"

The subagent made one Grep call, then SubagentHandback, the call a subagent uses to send its answer back to the main session. The agent used only Grep; Read was allowed too, but Grep had already returned the matching lines with their line numbers. I can't tell you from this run what it would do if asked for a tool outside its list; we did not test that. I'd still keep the list this short for any helper that only reads.

A small robot with a magnifying glass finds two yellow sticky notes on a long printed page of code
Illustration, generated locally with ERNIE-Image. One Grep call, two hits, lines 2 and 5 of calc.py. It also found a third note pinned to its own job description.

When the subagent model in your frontmatter seems ignored

I'd check the per-message "model" lines from Step 4 first, since they come from the replies themselves. If they show a model you didn't set, look at the Agent call in the main transcript: a "model" in its input beats your frontmatter, because it's first in the order above. Ours had none. None at all. This jq command lists the input keys of the Agent call:

bash
1jq -c 'select(.type=="assistant") | .message.content[]? | select(.type=="tool_use" and .name=="Agent") | .input | keys' ~/.claude/projects/*agents-demo*/*.jsonl

It should print one list per Agent call. Ours printed:

text
1["description","prompt","subagent_type"]

No "model" in that list means Claude did not pass one. Then I'd look at the frontmatter: model: has to sit between the two --- lines and be spelled as one of the values in the table. Last, check whether CLAUDE_CODE_SUBAGENT_MODEL_FORCE is set in your environment or in the env block of a settings file.

Subagents sit next to two other ways of extending Claude Code. A PreToolUse hook is a script that can block a tool call, and a skill is a set of instructions Claude loads into the main conversation. A subagent gets a separate context and, as here, a model you pick. If you're choosing which model to give a helper, our agentic benchmarks compare models on the same coding tasks.

Clean up

bash
1cd .. && rm -r agents-demo

Check it: ls agents-demo should print No such file or directory.

Key takeaways

  • You have a project subagent in .claude/agents/todo-finder.md that runs on Haiku with Grep and Read allowed, and the "model" lines in its transcript under ~/.claude/projects/<project>/<session>/subagents/ show the model that ran.
  • In our run it used one Grep call, no shell, no edits.
  • Claude's own brief to the subagent can widen its task, and a model Claude passes in that call beats the frontmatter.
  • Not covered here: permissionMode, a subagent's own skills or hooks, and the /agents command.
ShareXLinkedIn

Tags

claude-codeclaude-code-subagentssubagentsfrontmatterclaude-haiku

Comments

0

Add a comment

Confirm your address using the email we send. You can unsubscribe at any time. Your email stays private and this does not sign you up for the newsletter.