Tool Calling & Tool Contracts
19 questionsDONEUNLOCKEDLOCKED
Tool Calling & Tool Design Interview Questions
Tools are an interface whose user is a model. Names and descriptions that steer selection, schemas and structured outputs, errors the model can recover from, parallel calls, side effects and idempotency, and what to do when an agent has a hundred tools.
Worked answers that trace the run, put each decision on the right side of the authority line, and end with the follow-ups and scoring a panel applies.
You have 5 free answers unlocked here.Sign in free for 1 more · 13 are premium.
01–08Foundationsthe mechanisms behind this topic, and the terms a panel uses for them0/8 done
09–15Core questionsthe questions this topic is most often tested on, with full worked answers0/7 done
16–19Field scenariosopen-ended designs, incidents and trade-offs where you must state what is missing0/4 done
The concepts behind Tool Calling & Tool Contracts
Lessons behind these answers. The opening lessons are free; deeper ones are Premium.
Foundational
Tool ContractsA tool contract is everything the model sees about a tool (name, description, parameter schema) plus what it gets back (the result and the errors). The model rereads it every turn and chooses among tools by it, so it is written for a model: one decision per tool, few required arguments with enums and formats, no identity parameters, compact results with ids and pagination, and side effects stated plainly.Foundational
Tool Errors as ObservationsWhen a tool fails, the harness classifies the failure. Transient failures (timeouts, rate limits, 5xx on idempotent reads) are retried inside the dispatcher with backoff and a budget, so the model never sees them. Failures the model can act on (a bad argument, an unknown id, a business rule) go back as structured observations that say what was wrong and what to do. Failures nobody in the run can fix end the run or escalate. Swallowing errors, returning raw stack traces and retrying everything are the three common ways to get it wrong.Core
Structured Outputs and Constrained DecodingStructured outputs constrain a model's generation so its output matches a schema, typically by masking tokens that would break the grammar at each step. That guarantees syntax and, for supported schema features, types and enums. It does not guarantee semantics: a valid refund call can name the wrong order or an amount larger than the charge. A harness checks three layers (parse, schema, meaning), repairs with a bounded, specific error, and handles truncation at the token limit.Sign in
Advanced
Parallel Tool CallsModels can return several tool calls in one turn. A dispatcher that runs them all concurrently is fast and wrong. Classify each tool as read or write and name the resource it touches; run independent reads in parallel; run writes in order; refuse conflicting writes to the same resource in one turn; give each call its own timeout and failure; and return results paired with their call ids in the order the model issued them.🔒 Premium
Advanced
Idempotent Side EffectsAn agent can attempt the same write more than once through four paths: a transport retry after a timeout, the model re-issuing a call whose result it never saw, a crashed run replaying a step, and two branches acting concurrently. An idempotency key derived from the business intent (the order and the action), stored by the receiving service with the first response, makes repeats return the original result. When a downstream system has no idempotency support, the harness records the intent first, checks before acting, and reconciles anything uncertain.🔒 Premium
Advanced
Large Tool SurfacesSelection accuracy falls and per-turn cost rises as an agent's tool list grows, especially when tools overlap. The fixes, in order: consolidate endpoint-shaped tools into decision-shaped ones and namespace the rest; project the tool list per task so a run only sees what its task needs; load definitions on demand through a tool search step; or route requests to specialist agents with small tool sets. Each fix is judged on a labelled tool-selection set, and dynamic tool lists are placed so they do not break the prompt cache.🔒 Premium
Advanced
Malformed Tool Calls: What the Harness Repairs, Rejects and RescuesA malformed tool call is a request the dispatcher cannot run as written. They come in a short catalogue: JSON wrapped in a code fence or followed by commentary, a value of the wrong type that parses exactly, a missing or extra argument, an unknown tool name, and a call written in the text instead of the tool-call field. The harness handles each in one of three ways. It repairs only what cannot change the model's intent (strip a fence, convert "8611" to 8611 when the schema says integer). It rejects everything else with an error that names the field, the rule and the exact value to send instead, capped at one or two attempts. And it rescues a call the model wrote as text by returning an observation that tells it to use the tool-call field, never by parsing the prose into a call. The split is measured: how often each case occurs per model, and how often the model recovers on the next turn.🔒 Premium
Advanced
Tool Results That Fit the ContextA tool result enters the context once and is reread on every later turn of the run, so its size is paid many times over, and its shape decides whether the model can act on it. The same backend answer can be returned in several shapes: raw records, projected fields, a page with a cursor and a total, a summary computed for the question, or a reference the model can fetch again. Choosing among them is a design decision measured on two axes, tokens per run and answer accuracy on a labelled task set, and the measurement usually shows that the answer-shaped result wins on both. Rules follow: project to the fields the next step uses, precompute what the model would otherwise infer, page large results and say the total, never let a partial list look complete, and keep bulk out of the history by returning a reference the model can expand on demand.🔒 Premium
Advanced
Testing Tools Without a ModelMost tool bugs have nothing to do with the model, and testing them through the model is slow, costly and noisy. Four kinds of test need no model at all: example tests on the function, contract checks that the name, description, schema and result shape give a model what it needs, seeded fuzzing over generated inputs so bad arguments produce typed refusals and never crashes, and a fake backend that behaves like the real service including its timeouts, errors and partial failures. The model enters only for selection: a small labelled set of requests, run several times, checking which tool it chose and what arguments it filled. Splitting the tests this way makes the first four fast and deterministic in CI and keeps the one that needs a model small enough to run on every change.🔒 Premium
Unlock all 19 answers · $25
All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.
6 months · One payment · No auto-renewal