Agent Tools - Design Principles is the beginner primer: what is a tool, how do you describe it, one job per tool. This page is the architectural companion: given how a harness actually works, why does fewer tools produce a more reliable agent, and what does a tool have to do to earn its place?
Everything below assumes the per-turn cost model and the reactive-executor principle from Agent Harness. If those aren’t in your head, read that first.
Why Fewer Tools = More Reliable Agent
Pi (Coding Agent) ships with four tools: read, write, edit, bash. Most competing harnesses ship 15–40+. Pi’s bet is that fewer is more reliable, not less. Four reasons, in increasing depth.
1. Per-turn schema rent
Every registered tool ships its JSON schema (name, description, parameter types, required fields, examples) in the system prompt on every turn. A typical schema runs 100–400 tokens.
| Toolset | Per-turn schema cost | Cost over 50-turn session |
|---|---|---|
| Pi (4 tools) | ~300 tokens | ~15k tokens |
| Maximal harness (40 tools) | ~10,000 tokens | ~500k+ tokens |
The model isn’t using most of those tools on most turns — but the schemas are paid every turn anyway. This is the same pattern as the always-attached set in Agent Harness: rent paid forever for capability available rarely.
2. Overlapping tools = silent drift
If a harness ships read, read_file, view, cat, head, tail, and grep, the model has to choose on every relevant turn. The choice is influenced by the four biases from Writing Conflict-Free Instructions (recency, specificity, repetition, position). Different turns produce different choices for structurally identical situations.
Overlapping tools are conflicts at the tool layer, and they fail the same way overlapping rules do: no error, just drift. One read tool with offset/limit parameters has no choice to make and no inconsistency to produce.
3. Branching factor
The reactive-executor consequence. The model’s decision every turn is: given context, emit text or a tool call. The size of the tool menu sets the branching factor of that decision.
- 4 tools → frontier models pick correctly ~99% of the time.
- 40 tools → even 95% per-call accuracy compounds badly across a 20-step task (0.95²⁰ ≈ 36%).
- Worse, seldom-used tools trigger seldom-trained behaviors. The model has weaker priors on a tool it sees rarely in training data.
A small toolset isn’t just cheaper — it concentrates the model’s probability mass on well-trained pathways.
4. The shell as a tool-of-tools
bash already contains grep, find, curl, git, npm, pytest, rg, jq, and every CLI tool ever written. Adding them as first-class tools is redundant with a capability the model already has and is extensively trained on.
Key
One
bashschema entry buys access to thousands of capabilities.
A first-class tool for any of them is per-turn rent paid for a capability the shell already provides for free. This is the architectural reason Pi refuses MCP: each MCP server re-pays the schema tax for capabilitiesbashalready covers. See CLI Tools Pattern and MCP Tools vs Custom Function Tools.
What a First-Class Tool Has to Earn
A first-class harness tool earns its schema rent only by enforcing something the shell genuinely can’t. Four earned properties:
| Property | Example | Why the shell can’t |
|---|---|---|
| Budget caps the model can’t bypass | read defaults to 2,000 lines / 50KB | cat will dump a 1M-line log into context |
| Structured output other tools depend on | read returns numbered lines so edit can anchor | cat returns raw text |
| Fail-loud preconditions | edit fails if oldText doesn’t match exactly | sed -i silently does nothing or clobbers |
| Intent legibility in the trace | write vs edit make “create” vs “modify” visible | > and sed look the same in bash history |
Worked example: Pi’s four tools
Each one passes the test:
read— enforces budget (2k-line default), produces structured output (line numbers), handles binary/images. Replacescatwith a version that won’t blow the context window.edit— fail-loud staleness detection. IfoldTextdoesn’t match, the operation fails — meaning the model’s mental model of the file is wrong. This is the killer feature: it forces a re-read instead of clobbering correct code with hallucinated content.sed -icannot do this.write— atomic full-file create/replace, single-call semantics, distinguishable fromeditin the trace. Makes “this turn created a new file” visible at a glance.bash— the escape hatch for everything else, with atimeoutargument the shell doesn’t natively give you (the harness enforces the timeout from outside).
Why write and edit are separate tools
The most common confusion: they look like two UPDATE tools. They aren’t. They have different success conditions, different failure modes, and different token economies.
write | edit | |
|---|---|---|
| Operation | Replace entire file (or create new) | Replace exact oldText with newText |
| Precondition | None — succeeds unconditionally | oldText must exist exactly once |
| What you send | Full new file contents | Just the diff |
| Failure mode | Silent overwrite | Loud failure on staleness |
| Right use | New file, or complete rewrite | Surgical change to existing file |
The separation does three jobs simultaneously:
- Token economy. Changing one line in a 2,000-line file:
writesends 2,000 lines,editsends 3. - Safety / staleness detection.
edit’s failure onoldTextmismatch is a guardrail against booboo compounding — it forces a re-read when the model’s mental model is stale, instead of silently overwriting correct code with hallucinated content. - Intent legibility. Scanning a session, you can immediately see which turns created files vs which turns modified them. Collapsing them into one tool would lose that observability.
Worked Example: Should web_search Be First-Class?
A user proposes adding web_search to a Pi-style harness — takes a query, returns top 10 results as JSON. First-class tool, or skill/CLI?
Naïve argument for first-class: “We need structured output, and a CLI’s output could be too long.”
The flaw: a well-designed CLI can already produce structured, budgeted output. wsearch --limit 10 --max-snippet-chars 200 emits clean JSON. curl ... | jq '.results[:10]' returns exactly the shape you want. The “structured output” property isn’t exclusive to first-class tools — it’s a property of whoever designed the output format.
The genuine arguments for skill/CLI:
- Schema rent ratio. First-class tool ~150–250 tokens per turn forever. Skill ~30 tokens (name + one-line description) per turn, full instructions on demand. For a capability used in 1 turn out of 20, skill is ~5–8× cheaper.
- Provider churn. Search APIs change. A CLI script is one file the user (or the agent itself) edits. A first-class tool means a harness release.
- Composability.
wsearch "rust async" | head -3 | xargs -I{} curl -s {} | rg "tokio"is a one-liner the model composes at runtime. First-class tools require chained tool calls to compose. - Pi’s empirical answer.
~/.pi/agent/skills/pi-skills/brave-search/exists as a skill, not a first-class tool.
The narrow case where first-class wins: when the capability needs to enforce something the shell genuinely can’t — credential handling that must never appear in CLI args, deterministic session-wide rate-limiting, or harness-level UI rendering (a search-results pane the TUI knows how to show).
Verdict: Skill, not first-class tool. Same answer Pi gives.
The Underlying Principle
Key
The default for new capabilities is “skill or CLI.” The burden of proof is on first-class tools.
A first-class tool earns its schema rent only by enforcing something the shell genuinely can’t: budget caps the model can’t bypass, fail-loud preconditions, structured output other tools depend on, or intent legibility in the trace. “I want structured output” is not enough — the shell does that fine. “I want it to feel native” is aesthetic, not architectural.
This is the tool-layer version of the same principle that runs through Context Window Management Strategies and Streaming in Agent Harnesses: the harness should enforce things the model can’t enforce on itself, and stay out of the way for everything else. Tools, context, sub-agents — same rule.
How This Connects to Self-Extension
A minimal toolset isn’t a limitation — it’s the foundation for Self-Extending Agents. Because bash is universal, the agent can write a script, save it to disk, and use it from the next turn onward without any harness change. The capability surface grows without the schema rent growing. This is impossible in a harness where every capability must be a first-class tool.
A maximal harness asks: “What tools should we add?” A minimal harness asks: “What scripts do you need, and where should they live?” The first scales linearly with harness releases. The second scales with the user’s filesystem.
Related Concepts
- Agent Tools - Design Principles — the beginner primer; this page is its architectural companion
- Agent Harness — the per-turn cost model and reactive-executor principle that this page assumes
- Pi (Coding Agent) — the four-tool reference implementation
- CLI Tools Pattern — how new capabilities arrive without schema rent
- MCP Tools vs Custom Function Tools — Pi’s implicit answer to MCP, grounded in the same logic
- Self-Extending Agents — what a minimal toolset enables
- Writing Conflict-Free Instructions — overlapping tools fail the same way overlapping rules do
- Context Window Management Strategies — same “harness enforces what the model can’t” principle, applied to context
- Streaming in Agent Harnesses — same principle, applied to sub-agents and observability
- Session Observability and Replay — intent legibility (write vs edit) is observability built into the tool layer
- Agent-Computer Interface (ACI) — adjacent discipline: making tools mistake-proof at the interface level
Open Questions
- Is there a principled threshold for when a frequently-used skill should graduate to a first-class tool? (Usage frequency × per-call schema cost vs skill loading cost.)
- For tools that do earn first-class status, how do you decide between exposing fine-grained variants (
read_text,read_image,read_binary) vs a single polymorphic tool (read)? Pi chose the latter; what’s the trade-off? - Could a harness amortize schema rent via prompt caching (Anthropic’s cache, OpenAI’s automatic cache) so that 40 tools cost roughly the same per turn as 4? If so, does the branching-factor argument still hold?