Braj Kishore
JourneyVaultML FoundationsAI PM GuideAgenticNewsWork With MeMentorshipPulseNow
Say hi

Hiring · Building · Investing

Have a system — or a team —that needs to scale?

info@avyxon.ai

Usually replies within a day · track record here

JourneyVaultML FoundationsAI PM GuideAgenticNewsWork With MeMentorshipPulseNow
LinkedInXYouTubeSubstackInstagramThreadsFacebookDiscordGitHubTopmate
© 2026 Braj Kishore · Bengaluru, INThink Big · Start Small · Scale Fast
Agentic engineering
Lesson 06Patterns

Tools are the product

When an agent underperforms, the instinct is to change the model or rewrite the prompt. Far more often the tools are the problem: vague names, untyped arguments, enormous return payloads, errors that vanish. The model is doing its best with an interface nobody would ship to a human.

A human who cannot work out what to pass to your interface will ask you. The model will not ask. It guesses, it guesses differently on each turn, and you read that variance as model flakiness and go shopping for a better model.

That one difference is the whole lesson. The agent-computer interface deserves every bit of the care you would give a human-facing one, and then some, because it has no way to ask for clarification. Which is why most agent quality problems turn out to be tool design problems in a costume.

Four claims, in order. One: schema constraint does more work than prompt wording. Two: errors belong in the return value, not in a stack trace. Three: response size is a state-management problem rather than a formatting one. Four: the tool description is the real prompt — the part of your system the model reads most carefully and your users never see at all.

Writing effective tools for AI agentsAnthropic · 11 Sep 2025Building effective agentsAnthropic · 19 Dec 2024
Interactive · the line most people put in the wrong place

What strict: true enforces, and what it does not

Same schema file, two completely different guarantees. Select any keyword for the detail.

Enforced by the sampler · 6 keywordsA violating call is not unlikely. It cannot be emitted at all.
An invalid status cannot be sampled.
Held to the single declared value.
The listed keys are always present.
An unexpected key cannot appear.
Part of the schema the grammar is compiled from.
The named formats — the uuid on customer_id — are covered.
Not enforced · 5 keywordsRead by the model, usually respected, never guaranteed. Your handler still owns them.
The failure it admits
days=0 arrives anyway. The handler clamps it, or nothing does.
days=365 arrives anyway. The handler clamps it, or nothing does.
A string shorter than you declared still arrives.
A string longer than you declared still arrives.
A value that does not match the regex still arrives.

Everything on the top lane depends on one flag. Without strict: true, all eleven keywords are hints.

What a strict schema actually enforces

strict: true is not a stronger request. It compiles your schema into a grammar and constrains sampling to schema-valid tokens. A violating call is not unlikely. It cannot be emitted at all. The guarantee Anthropic documents is precise: the tool input follows the schema, and the tool name is always valid.

That is the difference between a schema and a prompt, in one line. A prompt asks. A grammar removes the option.

The part almost everyone gets wrong is which lines that covers. Inside the strict subset: enum, const, required, additionalProperties: false, default and the named string formats. The sampler enforces every one of those.

Outside it: minimum, maximum, minLength, maxLength and pattern. Those five are prose. The model reads them and usually respects them, but nothing enforces them, so your handler still owns them. Asserting otherwise is a common way to lose an interview to someone who has read the limitations page.

Interactive · what the model actually sees

The same capability, defined two ways

Switch the definition, then select any line. The badge tells you whether that line is enforced by the sampler, read as prose, or absent — and the panel at the bottom lists what each version still lets through.

The description, verbatim

“Query the system”

Four words. It does not say what is queried, what comes back, how much comes back, or what an empty result means. The description is the part of the tool definition the model reads most closely, and this one carries no information at all.

5 lines · select one
Not stated

"name": "query"

Absent from the definition entirely. The model has to infer it, and it will infer differently on different turns. You will read that as flakiness.

Named for the implementation, not the domain. The name is the first thing the model matches against a user request, and this one matches everything equally badly. search_orders would have done most of the routing work for free.

Failure modes this version still admits · 4
  • A call with no arguments at all, because nothing is required.
  • Extra invented properties your handler has never seen.
  • A different query dialect on each turn, which reads as model flakiness rather than as an interface defect.
  • An empty result the model interprets as an error and retries — the confused-retry loop, and the most expensive of these.

The constrained version has fewer failure modes, not none. What it buys is the removal of every malformed call, which is most of what teams are debugging when they say the model is unreliable. What survives is semantic — right shape, wrong question — and that is an eval problem, not a schema one.

Tool use with ClaudeClaude Developer PlatformStrict tool useClaude Developer PlatformStructured outputs — JSON Schema limitationsClaude Developer Platform

Written out, the difference between the two definitions is about eight lines. The enum does the heaviest lifting, and it only does it because strict is set. Drop that one flag and the same enum becomes a hint. An invalid status is then entirely possible.

tools.py
SEARCH_ORDERS = {
    "name": "search_orders",
    "strict": True,          # without this, everything below is a hint
    "description": (
        "Find orders for one customer. Returns at most 20, newest "
        "first. An empty list means the customer has no orders in "
        "the window - this is not an error, do not retry."
    ),
    "input_schema": {
        "type": "object",
        "properties": {
            "customer_id": {"type": "string", "format": "uuid",
                            "description": "From get_customer_profile."},
            "status": {"type": "string", "enum": [
                "placed", "in_transit", "delivered", "cancelled",
            ]},
            # minimum/maximum are OUTSIDE the strict subset: the model
            # reads them, the sampler does not enforce them.
            "days": {"type": "integer", "minimum": 1, "maximum": 90,
                     "default": 30},
        },
        "required": ["customer_id"],
        "additionalProperties": False,
    },
}


def search_orders(customer_id, status=None, days=30):
    days = max(1, min(int(days), 90))     # the handler still owns this
    rows = ORDERS.search(customer_id, status, days)[:20]
    return json.dumps([
        {"id": r.id, "status": r.status, "total": r.total_inr,
         "placed_at": r.placed_at.isoformat()}
        for r in rows                      # four fields, not the raw row
    ])
The enum, the required list and additionalProperties are enforced by the sampler. The bounds on days are not — they are read, usually respected, and clamped by your handler anyway. Both facts belong in the same definition.
The model reads every tool description. Your users read none of them. That asymmetry is what makes descriptions the highest-leverage prompt surface you own. It also makes them an attack surface, and a documented one: instructions hidden in a description are visible to the model and invisible to the person clicking approve.

Errors are a control surface, not an exception

An agent told that a query failed can correct itself. An agent whose process died cannot. That single asymmetry is why tool handlers catch rather than raise.

It also means the string you return is product copy, not a log line. “ERROR: order_id must be seven digits, got ABC123” produces a corrected call on the next turn. ValidationError produces the same wrong call again. Same failure, and the difference is entirely in what you wrote.

Anthropic’s own guidance puts it the same way: error responses are worth prompt-engineering, to communicate specific and actionable improvements rather than opaque error codes or tracebacks.

One consequence catches people out. A retry loop inside your handler is often wrong. It hides from the model the one piece of information that would let it stop repeating itself.

One exception to catch-everything: anything that says your side is broken rather than the call being wrong. An auth failure, a dead dependency, a budget cap. Those should stop the run. Feed them to the model and it will spend six more turns trying to route around them.

Response size is a state problem

A tool that returns forty thousand tokens has not made a formatting mistake. The whole message array is rebuilt and resent on every iteration, so you pay for that result on every subsequent turn of the run. It also dilutes attention across every subsequent decision. The bill arrives twice: once in money, once in quality.

Anthropic caps Claude Code tool responses at 25,000 tokens by default, and reports a concise response format using roughly a third of the tokens of the verbose one for the same content. Same information, a third of the cost.

The same arithmetic applies to the definitions themselves. They are billed as input tokens on every request, whether or not anything calls them. Five MCP servers — GitHub, Slack, Sentry, Grafana, Splunk — measured 58 tools and about 55K tokens of definitions before the conversation started. Anthropic’s internal systems reached 134K.

Deferred loading removed about 85% of that. It also moved tool-selection accuracy from 49% to 74% on Opus 4, and from 79.5% to 88.1% on Opus 4.5, on their MCP evaluation. So trimming what the model sees is not only a cost fix. It is a quality fix.

Carry one threshold out of this. Selection accuracy starts to degrade once you exceed roughly thirty to fifty available tools. Below that, deferred loading is machinery you do not need. Above it, the reflex to “add another agent” is usually an expensive way to avoid pruning a tool list.

Introducing advanced tool useAnthropic · 24 Nov 2025Tool search toolClaude Developer Platform

MCP: the seam, and the supply chain

Write tools against MCP rather than a framework’s native tool API and they survive a framework migration. That is not hypothetical — the frameworks lesson has the receipts.

Two things about the protocol are worth knowing as of the 2026-07-28 revision. The first is that MCP is now stateless at the protocol layer. The initialize/initialized exchange and the Mcp-Session-Id header are retired, so any request can land on any server instance behind a plain round-robin load balancer. If your server carried state across calls, the migration path is a tool-design change: mint an explicit handle from a tool and have the model pass it back as an argument.

The second is the security consequence of everything above. The model reads descriptions and the user does not, so instructions hidden in a description are a documented attack. Invariant Labs demonstrated it against Cursor in April 2025. A poisoned add tool caused the assistant to read and transmit ~/.ssh/id_rsa and ~/.cursor/mcp.json, while the approval dialog showed a benign, simplified call. The related move they name is the rug pull: a server changing a tool description after the client has already approved it.

The control for both is boring. Pin MCP server versions, and re-read the tool descriptions on every version bump. A rug pull changes the description, not the API, so a dependency bump that only diffs the interface will never see it.

Which of these you should actually build

Three of these are one-line changes that no stage should skip. One is real infrastructure a seed team should deliberately not build — and being able to say why is more useful than having built it.

Interactive · calibrate to your stage

What to actually do about this, at your size

Nearly all guidance on this topic is written for one company size and then read by everyone. Pick yours — the list re-sorts, and what you should deliberately not build drops to the bottom.

  • Strict schemas on every toolNon-negotiable

    strict: true, enums instead of free strings, required fields, additionalProperties: false.

    At this stage · Same flag, now with a lint in CI that fails any tool definition without it — because the eleventh tool is the one somebody adds in a hurry.

  • Errors returned, never raisedNon-negotiable

    Catch in the handler, return a readable string with is_error set, and let the model correct itself.

    At this stage · Now with the error strings themselves treated as copy: “ERROR: order_id must be 7 digits, got ABC123” recovers; “ValidationError” does not.

  • Response-size budget per toolDo it

    A hard cap on tool result size with explicit truncation and a documented follow-up call, rather than whatever the upstream API returns.

    At this stage · Now on every tool, because a 40k-token result is not a formatting problem: it is resent on every subsequent turn of the run and paid for each time.

  • Tool definitions as a reviewed artefactDo it

    Descriptions reviewed like a public API, MCP server versions pinned, and every version bump re-reading the descriptions.

    At this stage · Descriptions now go through review, because they are prompt text with a non-human consumer that will never file a bug about an ambiguous one.

  • Deferred tool loadingCheap version

    Tool definitions discovered on demand rather than loaded into context up front — tool search, or your own registry lookup.

    At this stage · Worth measuring rather than building: count the tokens in your tools array. If it is under ten thousand and you are under thirty tools, the answer is still no.

Nothing is optional at this stage. That is itself the finding — the cost of the control set is part of the cost of operating here.

Prompt cachingClaude Developer Platform

A system that made the tools the fix

🇧🇷 Brazil, Mexico, Colombia

Nubank — collapsing three tool calls into one

131m
customers served
100%
of conversations audited
3 → 1
calls per card-delivery task

Nubank’s card-delivery agent originally had the model orchestrate three steps: check status, verify address, trigger re-order. They replaced all three with a single deterministic API that handles the sequence internally, leaving the model one decision to make. Their framing is the shortest statement of the principle anyone has published: “if it’s deterministic, don’t make the LLM do the work.” They also moved from a survey sample to a secondary auditor model reviewing 100% of conversations against binary criteria — correctness, conciseness, preference alignment.

The lesson is about where reliability gets bought. Three model-decided steps give you three chances to be wrong and three round trips of context. One composite tool gives you one of each. Nothing about the model changed, yet a dashboard reads the result as a model improvement — which is exactly why “show me your tool definitions” is a faster diagnostic on a struggling agent than any amount of prompt review. Note what the 100% audit buys, too: at a sample rate, a tool that fails on one argument shape is invisible.

What to remember

  1. 1
    Constrain in the schema, not the prompt

    strict:true compiles the schema into a grammar, so malformed calls become unsamplable rather than merely discouraged. Know the subset exactly. Enforced by the sampler: enum, const, required, additionalProperties, default. Not enforced: minimum, maximum, minLength, maxLength, pattern — those are prose your handler still owns.

  2. 2
    Return errors, do not raise them

    A readable, actionable error string is a recovery opportunity that costs one turn. A stack trace is a dead trajectory. Stop the run only for failures on your side — auth, dependencies, budget.

  3. 3
    Response size is state, not formatting

    Every token a tool returns is resent on every subsequent turn and dilutes attention on every subsequent decision. Cap results, return the fields that matter, and count the tokens in your tools array — five MCP servers measured about 55K before any work happened.

  4. 4
    The description is the prompt, and a supply-chain surface

    It is the text the model reads most carefully and your users never see. Review it like a public API, document the ambiguous results — an empty list is not an error — pin server versions, and re-read descriptions on every bump.

Sources

Every source in this lesson

Primary sources wherever one exists. Where a claim is contested or vendor-reported, the lesson says so at the point it is made.

Read
  • Writing effective tools for AI agentsAnthropic · 11 Sep 2025

    The source for treating tool descriptions as a designed artefact rather than a comment. Claude Sonnet 3.5 reached state of the art on SWE-bench Verified after description refinements; Claude Code caps tool responses at 25,000 tokens by default; a concise response format used about a third of the tokens of the verbose one.

  • Introducing advanced tool useAnthropic · 24 Nov 2025

    The hard numbers on tool-definition overhead: 58 tools across five MCP servers is roughly 55K tokens before the conversation starts, and Anthropic's own systems hit 134K. Also the tool-search deltas (Opus 4 49%→74%, Opus 4.5 79.5%→88.1%) and tool use examples (72%→90% on complex parameter handling).

  • MCP Security Notification: Tool Poisoning AttacksInvariant Labs · 1 Apr 2025

    Beurer-Kellner and Fischer. Instructions hidden in a tool description are visible to the model and not to the user; their demonstration against Cursor exfiltrated ~/.ssh/id_rsa and ~/.cursor/mcp.json behind a benign-looking approval dialog. Also the definition of a rug pull: the server changes the description after approval.

  • The 2026-07-28 MCP SpecificationModel Context Protocol · 28 Jul 2026

    The initialize/initialized exchange and the Mcp-Session-Id header are retired; any request can land on any instance behind a round-robin load balancer. If your server needs state, mint an explicit handle from a tool and have the model pass it back — which is a tool-design decision, not a transport one.

  • Building AI agents for 131 million customersNubank Engineering · 23 Mar 2026

    Gupta and Braithwaite. The composite-tool argument stated in one line — “if it's deterministic, don't make the LLM do the work” — plus a 100% auditor-LLM review of conversations against binary criteria rather than a survey sample.

  • Building effective agentsAnthropic · 19 Dec 2024

    The agent-computer-interface argument in its original form, and the reason it sits alongside simplicity and transparency as one of three principles: careful tool documentation and testing.

Docs
  • Tool use with ClaudeClaude Developer Platform

    The round trip in full: a tool_use block comes back with stop_reason "tool_use", your code executes it, and the tool_result goes back on a user-role message. Also the pricing section, which states plainly that the tools parameter — names, descriptions and schemas — is billed as input tokens on every request.

  • Strict tool useClaude Developer Platform

    strict: true constrains sampling to schema-valid output — the docs name the technique, grammar-constrained sampling. Read the guarantee carefully: the input follows the schema and the tool name is always valid. That is a different and much stronger promise than validation after the fact.

  • Structured outputs — JSON Schema limitationsClaude Developer Platform

    The subset that strict mode actually enforces. enum, const, required, additionalProperties:false, default and the named string formats are in. minimum, maximum, minLength, maxLength and pattern are not. This is the paragraph most people asserting things about strict schemas have not read.

  • Tool search toolClaude Developer Platform

    Deferred loading, and the threshold worth memorising: tool selection accuracy degrades once you exceed 30–50 available tools. Note the mechanism — deferred definitions are excluded from the system-prompt prefix, so caching survives.

  • Prompt cachingClaude Developer Platform

    The cacheable prefix is built in the order tools → system → messages, so tool definitions sit at the very head of it. Changing a tool name, description or parameter invalidates that level and everything after it.

Lesson 05
Design patterns
Lesson 07
Shipping an MCP server