Summary
Agent tools are callable capabilities through which an agent can observe or affect its environment. A tool may wrap an API, database operation, browser, file system, code runtime, business process, physical device, or another agent. Good tool design does more than make a function callable. It gives the model a clear contract, gives the runtime enforceable boundaries, and gives operators enough evidence to decide whether an action actually succeeded. The most useful tools combine explicit schemas, least-privilege access, predictable failure semantics, observable execution, and testable success criteria.Why It Matters
Traditional application code usually calls functions along paths chosen by a developer. An agent can choose a tool and generate its arguments dynamically from natural-language context. That flexibility introduces failure modes that ordinary function signatures do not handle by themselves:- the agent selects a plausible but incorrect tool
- generated arguments are structurally valid but unsafe for the current user
- a timeout causes a consequential action to run twice
- a tool reports local success while the downstream system never changes
- an oversized result consumes context without helping the next decision
- an unstructured error leads the agent into an expensive retry loop
Mental Model
This article uses a repo-native six-contract model to organize tool-design concerns drawn from API, protocol, security, reliability, and risk-management guidance:description contract: what the tool does, when to use it, and what side effects it can createinput contract: the allowed arguments, types, constraints, and required identifiersauthority contract: which principal may perform which action on which resourceexecution contract: timeout, retry, cancellation, concurrency, and idempotency behaviorresult contract: structured success, error, receipt, and verification dataevidence contract: in this handbook, the traces, receipts, and outcome checks required to make execution independently testable
- a
resourceis something external, such as a database or email service - a
toolis the controlled interface to that resource - a
tool callis one proposed invocation with concrete arguments - a
tool resultrecords what the execution boundary observed
Architecture Diagram
This handbook distinguishes two verification steps:local action confirmationasks whether the tool boundary accepted or completed the operation it was asked to performdownstream-effect verificationasks whether the external system reached the intended state
End-To-End Example
Consider a user asking for a refund:- The agent selects
create_refund_request. - The input schema validates the order ID, amount, currency, and reason.
- The runtime verifies that the user may act on the order.
- Policy determines whether supervisor approval is required.
- An idempotency key prevents a retry from creating a duplicate request.
- The tool returns a structured status, operation ID, and allowed next actions.
- A follow-up read verifies that the refund request exists in the downstream system with the expected amount and approval state.
Tool Landscape
Agent tools appear through several implementation surfaces:function toolsexpose application code with a name, description, and input schemaprotocol toolsuse contracts such as MCP to advertise inputs, structured outputs, and behavioral annotationshosted toolsprovide managed capabilities such as search, retrieval, code execution, or computer useagent toolsexpose another bounded agent as a callable capability
Make Schemas Explicit
Use a narrow name and description, typed properties, required fields, enums, length or range constraints, and explicit handling of additional properties. Descriptions should explain preconditions and side effects, not only restate the tool name. The following MCP-style tool definition uses JSON Schema to constrain its input:Keep Authority Narrow
Grant the tool only the access it needs for the current task. Prefer scoped, short-lived credentials and resource-level permissions over broad credentials shared across the whole agent runtime. Useful boundaries include:- separate read tools from write tools
- separate drafting from publishing or sending
- require approval for consequential or irreversible effects
- bind authorization to the initiating user and target resource
- re-check policy at execution time instead of trusting model-generated claims
Treat Tool Outputs As Untrusted Data
A tool result may contain content supplied by users, websites, documents, or external services. The runtime should not assume that this content is trusted merely because it arrived through an approved tool. Keep data and instructions separate. Validate structured outputs, sanitize rendered content, limit which results may influence consequential actions, and require fresh authorization before a result can trigger a higher-privilege tool. For example, text returned by a search or email tool may ask the agent to upload files, reveal credentials, or invoke an administrative tool. That text is data to analyze, not authority to expand the current task. This boundary follows the threat model described by the OWASP Top 10 for Agentic Applications: access to a legitimate tool does not make every instruction or data item returned through that tool trustworthy.Define Failure And Retry Semantics
Return errors that distinguish invalid input, missing authorization, approval requirements, conflicts, rate limits, temporary dependency failures, terminal business failures, and unknown outcomes. Include whether retrying is safe. Consequential tools should accept an idempotency key or equivalent operation identifier. If a response is lost after execution, the same logical operation can then return the original result instead of producing the side effect twice. Bound retries by count, time, and cost; never let the model infer unlimited retry policy from a generic error string. This follows established reliability guidance: AWS recommends making mutating operations idempotent and explicitly controlling and limiting retries.retryable: false means that repeating the same call without changing its
authorization state will not help. It does not mean that the workflow is
permanently blocked: the agent may request approval or submit a
policy-compliant amount.
Return Evidence, Not Just Text
A result such asDone is hard to verify. Prefer structured results containing
status, stable resource identifiers, timestamps, versions, receipts, and the
next valid actions. For large outputs, return a summary plus pagination or an
artifact reference rather than flooding the model context.
Observability should connect the user request, tool call, policy decision,
execution attempt, external receipt, verification check, latency, and error
classification under one trace or operation identifier. Sensitive arguments
still need redaction and access control. This model aligns with
OpenTelemetry traces,
which represent a request path as related spans under shared trace context.
The NIST AI Risk Management Framework 1.0
provides the broader governance context for defined responsibilities,
measurement, monitoring, and risk controls around AI systems.
Make Success Testable
This article uses three levels of success to make tool behavior testable:contract success: the tool accepts valid inputs and rejects invalid onesexecution success: authorization, side effects, retries, and errors behave according to policytask success: independent evidence shows that the intended downstream state was reached
Tradeoffs
- Narrow tools are easier to authorize and test, but too many similar tools can make selection harder and consume more context.
- Rich schemas reduce ambiguity, but complex schemas may be difficult for some models or clients to follow consistently.
- Strict validation catches malformed calls early, but it cannot replace business rules or authorization checks.
- Automatic retries improve resilience for transient failures, but unsafe retries can duplicate irreversible effects.
- Detailed traces improve debugging and evaluation, but they can expose sensitive arguments or results if access and redaction are weak.
- Downstream verification provides stronger evidence, but it adds latency, cost, and sometimes another privileged read.
- Human approval can reduce blast radius, but approval fatigue turns a control into a rubber stamp if every routine action requires confirmation.
- expose the narrowest capability that can complete the task
- validate structure, authorization, and business policy separately
- make consequential operations idempotent where possible
- return structured results with stable identifiers and retry guidance
- distinguish local completion from downstream-effect verification
- test the tool boundary independently from the model and end to end with it
Citations
- Official source: OpenAI function calling
- Official source: OpenAI Agents SDK tools
- Official specification: MCP tools
- Official specification: MCP Schema Reference
- Official guide: JSON Schema
- Official reference: JSON Schema enumerated values
- Official reference: JSON Schema string constraints
- Official reference: JSON Schema object properties
- Official guidance: OWASP Top 10 for Agentic Applications
- Official guidance: NIST AI Risk Management Framework 1.0
- Official guidance: AWS idempotent operations
- Official guidance: AWS retry limits
- Official documentation: OpenTelemetry traces
Reading Extensions
- Agent Runtime Building Blocks
- Reasoning And Control Patterns
- Browser And Computer-Use Patterns
- Agent Security And Prompt Injection
- Protocols And Interoperability
- Evaluation And Observability
- Patterns Overview
Update Log
- 2026-08-01: Added the initial repo-native draft on schemas, least-privilege boundaries, failure semantics, observability, and testable success criteria.
