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 --versionprinted 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
[[steps]]
- Create the project — a folder with a Python file holding two TODO comments. Result:
grep -n TODO calc.pyprints lines 2 and 5. - Write .claude/agents/todo-finder.md — frontmatter with
tools: Grep, Readandmodel: haiku, then the instructions. Result:head -6shows the four settings between two---lines. - Ask Claude to use the agent — start
claude, then name the agent in your request. Result: Claude reports the two TODO lines fromcalc.py. - Check which model ran — run
caton the subagent's.meta.jsonfile, then thegrepover its transcript. Result:"model":"claude-haiku-5-5"in both. - Check which tools it used — run the
grepthat lists the subagent's tool calls. Result: oneGrepcall and the handback.
Step 1: Create the project
- In a terminal, run:
mkdir agents-demo && cd agents-demo printf 'def add(a, b):\n # TODO: handle strings\n return a + b\n\n# TODO: add a subtract function\n' > calc.py grep -n TODO calc.py - You should see:
2: # TODO: handle strings 5:# TODO: add a subtract function Step 2: Write the agent file
- Make the folder:
mkdir -p .claude/agents - Save this as
.claude/agents/todo-finder.md:
--- name: todo-finder description: 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. tools: Grep, Read model: haiku --- You list TODO comments. Search the project with Grep for the text TODO. Answer with one line per hit in the form `<file>:<line>: <comment text>`, then one line with the total count. Do not edit any file. - Check it:
head -6 .claude/agents/todo-finder.mdshould 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
- Start Claude Code in the folder:
claude 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.
Type:
Use the todo-finder agent to list what is left to do in this project. - 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 ...):
There are 2 TODOs left in the project, both in `calc.py`: - `calc.py:2`: handle strings - `calc.py:5`: add a subtract function ... The 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. ... 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.
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.
- Exit Claude (
/exit), then run:
ls ~/.claude/projects/*agents-demo*/*/subagents/ cat ~/.claude/projects/*agents-demo*/*/subagents/*.meta.json - You should see a
.jsonland a.meta.jsonfile, and"model":"claude-haiku-5-5"in the metadata. Ours:
agent-adf7691bc2ef72df7.jsonl agent-adf7691bc2ef72df7.meta.json {"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.
- Run this. The first
grepkeeps only the lines Claude wrote ("type":"assistant"), because the request lines in the same file also mention the main session's model:
grep '"type":"assistant"' ~/.claude/projects/*agents-demo*/*/subagents/agent-*.jsonl | grep -o '"model":"[^"]*"' | sort | uniq -c - You should see one line, with every count on
claude-haiku-5-5. Ours:
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
- Run:
grep '"type":"assistant"' ~/.claude/projects/*agents-demo*/*/subagents/agent-*.jsonl | grep -o '"type":"tool_use","id":"[^"]*","name":"[^"]*"' | grep -o '"name":"[^"]*"' | sort | uniq -c - You should see one
Grepand oneSubagentHandback. Ours:
1 "name":"Grep" 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.
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:
jq -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:
["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
cd .. && rm -r agents-demo Check it: ls agents-demo should print No such file or directory.
[[takeaways]]
- You have a project subagent in
.claude/agents/todo-finder.mdthat 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
modelClaude passes in that call beats the frontmatter. - Not covered here:
permissionMode, a subagent's own skills or hooks, and the/agentscommand.
Originally published on leanzero.net. More Atlassian, Forge and local-AI write-ups at leanzero.net/blog, and if you're planning a migration or a Forge app, that's what we do: leanzero.net/services.





