Tool calling: the model asks, your harness does
I build Settl, an expense-splitting app, solo with Claude, and for months I assumed the model was editing my files. It never has. It emits a request as structured text, and the program around it decides whether to run that request. That one distinction explains most of what looks like magic.
What actually crosses the wire
A language model takes tokens and produces tokens. No filesystem, no shell, no network. When you give it tools, you send tool definitions with the conversation: a name, a description, a JSON Schema for the arguments. If it uses one, it emits a structured block:
{
"type": "tool_use",
"id": "toolu_01A...",
"name": "write_file",
"input": { "path": "src/config.ts", "contents": "export const timeoutMs = 5000\n" }
}
That is the model's entire contribution: text with a shape. Nothing has happened to your disk, and if you stopped here nothing would.
The loop, one turn at a time
Your harness, Claude Code or your editor or fifty lines of your own script, runs the rest:
1. parse pull the tool_use block out of the response
2. validate check arguments against the schema you published
3. authorise ask the user, check an allowlist, or refuse
4. execute actually write the file, run the query, call the API
5. append add a tool_result with the same id, then call the model again
Step 5 is why the model appears to know what happened: the result comes back as another message in the conversation, read the way it reads anything you type. The loop repeats until a turn arrives with no tool call in it.
A tool result costs context like any other text, so a tool that dumps a 200 KB file spends your window on one call. And arguments that fail validation are not a crash, they are a message you hand back.
A tool the model cannot see does not exist
The tool list is sent per request. If write_file is not in the list on this call, no amount of
prompting produces a write, and no permission dialog appears, because there was never a proposal
to approve. The honest answer to "why can it not do X":
- Not in the list. Never offered, and it cannot discover it or ask for it.
- In the list, stopped at step 3. Blocked by policy or by you, and it sees a refusal it can act on.
- In the list, ran, failed quietly. The worst case, and the next section is about it.
So the security boundary is your harness, not the model's cooperation. Anything you do not want done, do not ship as a tool. Sandboxes, allowlists, and confirmations live at step 3, in your code, not in a prompt asking nicely.
Tool descriptions are prompt surface
Name, description, and every parameter description are sent on every request. They are prompt, weighted and billed like prompt, and the only documentation the model gets. Ambiguity you leave there comes back as wrong arguments:
name: log_expense
description: Record a shared expense and split it between people. Use when the user mentions
paying for something with or for others. Amount is the total paid, not
the per-person share.
required: description, amount
- Name for the intention.
log_expensegets picked correctly.createTxnRecordgets guessed. - Say when to use it, not only what it does. Selection fails more often than execution.
- Put the ambiguity in the description. One clause about totals versus shares kills a class of wrong calls.
- Fewer tools beat more. Thirty means it spends attention choosing: settl.fyi/social/build-an-mcp.
Make failures readable, not silent
A tool that fails and returns an empty string has taught the model it succeeded. It then tells your user the file was written, and nothing contradicts it. Return sentences with recovery in them:
bad: {}
bad: Error: ENOENT
good: No file at src/confg.ts. Closest matches: src/config.ts, src/config.test.ts.
good: Rejected: amount must be an integer in minor units. Got "48.00", did you mean 4800?
When to add a tool and when to keep talking
- Add one when the action lands outside the conversation, or needs data the model cannot have: the filesystem, a live balance, someone's calendar.
- Do not wrap what the model already does well. A "summarise" tool is a round trip that burns a slot in the list.
- Ship read-only tools first. They teach you how the model phrases requests before you let it write. A search tool brings its own failure modes: settl.fyi/social/how-it-knows-your-docs.
Run this on your codebase
Paste this into a session in the repo that defines your tools:
Audit the tool surface this project exposes to a model. Report before changing anything.
1. List every tool definition: name, description, required parameters. If they come from more
than one place, tell me where the real per-request list is assembled.
2. For each, read only its description and schema as your sole documentation, and tell me the
most plausible wrong call you would make.
3. Find every tool whose failure path returns nothing, an empty object, or an exception the
caller swallows. Those make the next turn guess.
4. Which tools change data, spend money, or contact a person, and does the harness ask before
running them?
5. Estimate the largest result each tool can return in characters, and flag any that can
exceed 10,000 untruncated.
Give me 1 to 5 as a table. Then write the replacement failure messages for step 3: one plain
sentence each, what went wrong and what to try instead.