What to take into an interview
- Define a narrow tool contract with descriptions and typed parameters.
- Validate every model-generated argument before executing code.
- Design retries and normalization around observable failure categories.
Design schemas for correct use
A useful schema tells the model when to use the tool and gives each parameter a precise type, description, and constraint. Avoid generic names such as data or input when a domain term would reduce ambiguity.
Keep tools narrow. A tool that performs several unrelated operations is harder to describe, authorize, test, and retry safely. Separate read operations from writes when their risk and confirmation requirements differ.
Validate before side effects
Structured output improves parsing but does not make values trustworthy. Validate required fields, types, ranges, enumerations, formats, and cross-field rules in application code. Reject extra fields when they could change behavior unexpectedly.
- Check that the requested tool exists in the current allowlist.
- Apply user and tenant authorization independently of model output.
- Use idempotency keys for operations that may be retried.
- Redact credentials and sensitive payloads from logs and observations.
Handle failures by category
Retry only failures likely to be transient, such as selected timeouts or rate limits. Invalid arguments need correction, permission failures need a different path, and deterministic business-rule failures should be returned without repeated calls.
Use bounded exponential backoff with jitter and a total time budget. Preserve the final error type and enough context for the agent or operator to decide what to do next.
Normalize results for downstream reasoning
Different tools return different shapes, but an agent benefits from a consistent envelope containing status, data, error category, and trace identifiers. Normalization simplifies observations, logging, evaluation, and fallback behavior.
Test successful calls, malformed arguments, unknown tools, transient failures, permanent failures, duplicate requests, and partial batch results. Interviewers often care more about these branches than the happy-path function call.
Hands-on practice
Related coding problems
Generate a JSON Schema for a Tool
Translate a callable contract into model-readable structure.
Open problemValidate Tool Arguments Before Calling
Enforce required fields and type rules before execution.
Open problemNormalize Tool Observations for the Agent Loop
Create a consistent result shape for traces and reasoning.
Open problemBuild the foundation
Related curriculum tracks
Common questions
Frequently asked questions
Is JSON Schema validation enough for tool safety?
No. Schema validation checks shape and basic constraints. You still need authorization, domain rules, rate limits, credential scoping, and confirmation for consequential actions.
When should a tool call be retried?
Retry bounded transient failures when the operation is safe to repeat or protected by idempotency. Do not retry invalid input or permission failures without a meaningful change.
How many tools should an agent receive?
Expose the smallest relevant set for the current task. A focused allowlist reduces selection ambiguity, prompt size, and the impact of an incorrect model decision.
Practice next
Practice the model-to-software boundary
Start with schema generation, add strict validation, and finish with normalized results so your tool layer remains predictable when model output is not.