Pattern · beginner
Tool Use Pattern
How agents call tools reliably: schemas, selection, error handling, permissions, and verification of side effects.
- tools
- function-calling
Tool use (function calling) lets models invoke external capabilities with structured arguments and observe results.
Design good tools
- Small and sharp — one clear job
- Strict schemas — types, enums, required fields
- Actionable errors — “order_id not found” beats “error”
- Idempotent writes when possible
- Document side effects in the description
Selection quality
Overlapping tools confuse models. Prefer:
- Distinct names
- Non-overlapping responsibilities
- Examples in descriptions (short)
Execution loop
model proposes tool call → validate schema → policy check → execute →
return observation → model continues
Never skip validation/policy because the model “sounded sure.”
Verification
For side-effecting tools, verify postconditions in code before reporting success to users.
MCP and portability
Standard interfaces like MCP help expose tools across hosts, but security remains your job.
Frequently asked questions
What is tool use in AI agents?
Tool use is the ability for a model to invoke external functions—APIs, databases, browsers, code runners—to observe or change the world beyond text generation.
Related reading
ReAct Pattern
ReAct interleaves reasoning traces with tool actions so agents can think, act, and observe in a loop.
Tool
A tool is an external capability an agent can invoke—such as an API, database query, browser, or code runner—via a structured interface.
MCP Explained: Model Context Protocol for Agents
What MCP (Model Context Protocol) is, why it matters for agent tool use, and how to think about servers, clients, and security.
Agent Safety and Guardrails
Practical guardrails for agentic AI: permissions, sandboxes, human approval, budgets, content filters, and audit trails.