Skip to content
Mastering Claude

Home / Context and cost

Context and cost8 minApplication

A sub-agent costs before it has done any work

A subagent costs before it has done any work, because its conversation already contains items you did not write, loaded again at every launch. With no tools field it inherits every tool, and with no model named it runs on the same model as you. List its tools and name its model by role.

A subagent is a separate conversation that Claude Code opens for a task. Before its first instruction, that conversation already contains items you did not write, and every launch loads them again. A subagent's cost is therefore made of this startup and of the work requested.

What a subagent contains at the start

The subagents documentation lists, among other things, what it receives: its own system prompt with environment details, every level of CLAUDE.md files the main conversation loads, the full content of the skills named in its skills field, the MCP servers in its mcpServers field, and the start of its memory file if memory is on. For tools, the rule is the reverse of what one assumes: with the tools field omitted, the subagent inherits every tool available. The more items at the start, the heavier the first call.

A custom agent with listed tools

A file placed in .claude/agents/ defines an agent that Claude can launch by name. This one keeps only what its task requires:

---
name: reader
description: Reads files and reports what they contain, without changing anything.
tools: Read, Grep, Glob
model: haiku
---
You read the requested files and report the facts found, with the file name.
You do not judge and you change nothing.

The three listed tools are the only ones this agent can use, and model: haiku gives it a small model. The documentation specifies that Claude Code watches these folders and picks up an added or edited file within a few seconds; after creating the very first file in an agents folder, a session restart is needed.

Naming the model by role

With no model named, the documentation gives this order: the call's parameter, then the model field of the definition, then the CLAUDE_CODE_SUBAGENT_MODEL variable, then the main conversation's model. A subagent that received nothing else therefore runs on the same model as you, with nothing flagging it at launch; the /tasks command shows the model on the subagent's row. A mechanical collection (read, list, extract) can go to a small model; writing and analysis to a mid-size model; the judge, who must refute, to the most capable. The effort level is set the same way: the Agent tool accepts an effort parameter for a given launch, and an agent's definition can set its own.

Measure before concluding

The real weight of each item is read on your own setup, not in an average. The lesson on the bill shows where to read consumption by item; apply it to a default subagent, then to the same work given to the restricted agent.

Figure 1

Which model a subagent takes, in order

RankSource of the model
1The model parameter of the call itself.
2The model field of the agent's definition (inherit designates the main model).
3The CLAUDE_CODE_SUBAGENT_MODEL variable, if set.
4The main conversation's model.
The table ranks the four sources that decide a subagent's model, from the strongest to the weakest.
Figure 2

Two agent definitions for the same reading task

Default agent

No tools or model field: every available tool, and the main conversation's model.

Restricted agent

tools: Read, Grep, Glob and model: haiku: three tools and a small model for a task that only reads.

The left column leaves everything at its default, the right column fixes the tools and the model in the agent's file.
Calibrate it yourself

A team configures a Claude Code session with a large CLAUDE.md file and several MCP servers. It launches five subagents to read five configuration files, then reads a total of 4.20 dollars on /cost for this reading task.

Write in one sentence what this situation establishes, and in one sentence what it does not establish.

What to remember
  • A subagent receives at the start its prompt, the CLAUDE.md files, and the skills and MCP servers it is given by name, and each weighs on the first call.
  • An omitted tools field gives the agent every available tool: restricting is an explicit act.
  • With no model named, a subagent runs on the main conversation's model, nothing flags it at launch, and /tasks displays it.
  • The model is split by role: small to collect, mid-size to write, the most capable to judge.
  • An agent's startup cost is measured on the same task given first to a default agent and then to a restricted one.
Do this now

Create an empty test folder, add a three-line notes.txt file to it, then a .claude/agents/reader.md file copied from the example. Start Claude Code in that folder, ask the reader agent to report the content of notes.txt, then type /cost and note the line. Make the same request to an unnamed subagent in a fresh session, and compare the two lines.

Check the source

Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.