Deep-Dives / Tool & Capability Design

Tool & Capability Design

Designing tools an agent can actually use — granularity, schemas, error messages, recovery, antipatterns.

  1. Designing Tools Agents Can Use
    Tools are the agent's entire API: design for a model that reads only the description and is confidently wrong, not for an engineer who read the source.
  2. Tool Granularity & Composition
    Coarse tools hide decisions and concentrate blast radius, fine tools multiply round-trips and bloat the list — and tool explosion is now a measured ~24-point selection-accuracy loss.
  3. Schemas, Contracts & Defaults
    Write minimum: 100 on a strict tool and one of three things happens: the API refuses the request, the SDK deletes the constraint and pastes it into the field description, or nothing checks it and you never find out. Every keyword falls into one of those buckets — compiled, rejected, demoted — and only the first is enforcement, which is why Anthropic's own docs spell “one to ten passengers” as a ten-value enum rather than minimum/maximum. Expressiveness is rationed now (20 strict tools, 24 optional parameters, 16 union types per request, a 180-second compile ceiling), required-first property ordering will surprise your parser, enum casing is guaranteed by nothing, and the schema is cached on a different retention track from your prompt — so no PHI in property names.
  4. Error Messages as Prompts
    A tool error is a just-in-time prompt: name the cause, echo the bad value, prescribe the corrected call, and say retryable-or-terminal — or breed a runaway retry loop.
  5. Tool Docs & Discoverability
    Claude Code defers MCP tool definitions by default, and the search that has to match your tool reads only the first 4,096 characters even though a deferred description may run to 16,384 — so the description is two documents with two different readers. Put the domain nouns and the boundary against the nearest neighbour first, the worked invocation after, and treat alwaysLoad as the decision that actually matters.
  6. Tool-Design Anti-Patterns
    An anti-pattern is defined against a calling convention, and the convention moved. The four classic signatures — kitchen-sink tool, stringly-typed args, silent failure, leaky abstraction — are now the cheap half of the audit; the expensive half is the catalog, which Anthropic's own write-up prices at 134K tokens of definitions before optimisation against roughly 500 for on-demand search. Adds the arithmetic that shows silent failure deletes your error measurement rather than raising it, why programmatic tool calling (11 of 14 models match or beat native JSON on a BFCL v4 subset) re-ranks the list, and why an 18.5% evaluator–human misalignment rate across four tool-calling benchmarks means you verify a fix on replayed traces, not a leaderboard.
  7. Tool Calling Vendor Matrix (2026)
    OpenAI (Chat Completions vs Responses API, parallel_tool_calls, custom tools with Lark/regex grammar) vs Anthropic (Programmatic Tool Calling, Tool Search Tool, Tool Use Examples) vs Gemini (OpenAPI subset, tool_choice any, multimodal function responses).
  8. Advanced Tool Orchestration
    Anthropic Tool Search Tool (85% token reduction); Programmatic Tool Calling (Claude writes Python in a sandbox that calls tools, only final results enter context); Tool Use Examples.
  9. Structured Outputs vs Tool Calls
    Two ways to constrain the model — same constrained decoding underneath, different ergonomics. Anthropic's native structured outputs GA in 2026; when to use each.
  10. JSON Schema Subsets per Vendor
    What's actually enforceable per vendor — no minLength/maxLength/minimum/maximum on Anthropic; OpenAPI subset on Gemini; strict mode requires additionalProperties:false + all required on OpenAI.
  11. Streaming Tool Calls in Practice
    Per-vendor delta accumulation, the OpenAI GPT-4.1-nano duplicate-call bug, Gemini aggregatable arguments, Anthropic streaming with parallel calls.
  12. Code as Action
    Having the model write code that calls tools took one reported workflow from 150,000 tokens to 2,000 by keeping intermediate data out of context — and the thing it spends is the action log, because policy enforcement, approval gates and audit all key on tool calls that a program never emits.
  13. Shaping Tool Results
    A tool definition costs a few hundred tokens once per turn; one unshaped result costs forty thousand and is re-sent on every turn after — and it is also the largest untrusted text block in the window. Project, rank-then-truncate, paginate, hand back a handle; one envelope and one harness-enforced ceiling for every tool.
  14. Skills vs Subagents vs MCP vs Hooks: Which to Use
    Hook for what must happen every time, MCP to reach a system, skill for know-how, subagent to keep noisy work out of context, instruction file for what every turn needs; a plugin only ships them. The deciding axis is who pulls the trigger, not context cost.
  15. Tool Annotations Are Hints, Not Gates
    MCP's four hints default pessimistically — readOnlyHint false, destructiveHint true, idempotentHint false, openWorldHint true — while the spec says to treat them as untrusted unless the server is. Put those together and the honest server that ships no annotations gets a confirmation dialog on every call while the one asserting readOnlyHint runs silently, so the interface rewards assertion. Build the risk class client-side keyed on (endpoint, package digest, tool name), pin it at install, and demote the hint to a pre-fill plus a drift alarm — including in the retry policy, where a wrong idempotentHint sends the message twice.
  16. Examples in the Tool Definition
    Your schema can declare a field optional; nothing in it can say “usually leave this out” — which is why Anthropic's own get_weather ships a third example whose entire content is a missing key. Examples are the only part of the contract where an absence is the lesson, they are schema-validated for you except when a pattern is present (then the check is skipped and the model is shown the invalid example), and they cost about 100 input tokens flat or 200 nested on every request that carries the tool. Derive each from a real trace, vary the set across any axis you do not want anchored, and assert validity in CI.