Skip to main content

05. Design Patterns

Tool-Use Pattern

The Tool-Use pattern is how an agent deliberately chooses capabilities — answer, call a tool, or escalate — under a catalog and policy, then feeds observations back into the loop. Mechanics live in Module 03; this lesson is the design shape you compose with routing, planning, and reflection.

What you will learn

  • Define Tool-Use as a design pattern (not just an API)
  • Describe select → validate → execute → observe → recover
  • Apply least-privilege tool catalogs and routing
  • Compose Tool-Use with parallel, plan, and reflect patterns
  • Answer interview questions with short, solid answers
Agent decides among final answer, tool invoke, or human escalate
Interview staple: Tool-Use = decide among answer / tools / escalate under policy.

Definition

Tool-Use is the design pattern where an agent’s control loop may select named capabilities (search, DB, ticket, shell, browser) with arguments, have a runtime execute them safely, and continue from structured observations — instead of inventing facts or side effects in plain text.

It sits among Design Patterns because almost every other pattern (routing, parallelization, orchestrator, planning, reflection) either chooses tools, batches them, or audits their results. For schemas and runtime detail, see Module 03 Tool Calling.

Introduction

This lesson (#5 in Design Patterns) follows Reflection and Planning. Plans name tools; reflection often judges tool outcomes.

Next: Multi-Agent Collaboration and Hierarchical Patterns — how tool-using agents share work.

Why Tool-Use is a pattern

  • Separates “what the model wants” from “what the system allows”
  • Grounds agents in live systems instead of hallucinations
  • Makes permissions, audits, and budgets enforceable in code
  • Composes cleanly with route / parallel / plan / reflect shapes

The decide triangle

Every turn, a tool-using agent should choose among a small set of exits — not an open-ended “do anything.”

Goal and catalog into decide then answer tool or escalate
If the catalog is huge, route first to a smaller allowlist.
  • Final answer - no further side effects this turn
  • Tool call(s) - one or many under concurrency caps
  • Escalate / ask - human or safer agent when unsure or blocked
  • Refuse - policy denial is a valid outcome, not a crash

Lifecycle inside one call

Treat each tool invocation as a mini-pipeline owned by your runtime, not by the model.

Select validate execute observe recover loop for tools
Recover means structured errors the model can act on — not stack traces dumped into chat.
  • Select - model proposes name + args from the allowlist
  • Validate - schema, types, business rules, authz
  • Execute - timeouts, idempotency keys, audit log
  • Observe - normalized success/error payload
  • Recover - retry, alternate tool, replan, or escalate

Catalog design and least privilege

  • Few sharp tools beat dozens of vague ones
  • Descriptions must say when NOT to use the tool
  • Split read vs write; require confirmation on irreversible writes
  • Per-route / per-role allowlists (compose with Routing)
  • Hide secrets from the model; inject credentials in the runtime

Compose with other patterns

Tool-Use is the “verb layer.” Other patterns decide which verbs, how many, and when to check quality.

Route tools, parallel tools, and plan plus reflect compositions
Route catalogs; parallelize independent reads; plan writes; reflect after risky side effects.
  • Routing - shrink the catalog per intent
  • Parallelization - fan-out independent reads; join carefully
  • Planning - name tools in steps before high-cost writes
  • Reflection / evaluator - critique observations and drafts
  • Orchestrator - workers get different tool allowlists

Failure modes

  • Tool spam - looping the same call; cap repeats per tool
  • Wrong tool - vague descriptions; fix catalog + routing
  • Unsafe execution - model args trusted blindly; always validate
  • Opaque errors - model cannot recover; return structured faults
  • Catalog bloat - too many tools; accuracy collapses

Program / implementation notes

Keep a ToolRegistry: name → schema → handler → policy. Drive max_tool_rounds and per-tool rate limits from config.

  • Log tool_name, args_hash, latency, outcome for evals
  • Prefer idempotent writes where possible
  • Deep dive: Module 03 Tool Calling, Function Calling and Action Execution
  • Next: Multi-Agent Collaboration and Hierarchical Patterns

Advantages and limitations

  • Advantage: real actions and grounded data
  • Advantage: clear security boundary in the runtime
  • Advantage: composable with every other design pattern
  • Limitation: bad catalogs cause wrong or endless calls
  • Limitation: each call adds latency and cost
  • Limitation: side effects need careful ops and rollback story

Key points

  • Tool-Use = decide among answer / tools / escalate under policy.
  • Runtime owns validate → execute → observe → recover.
  • Least privilege: small, sharp catalogs per route/role.
  • Compose with routing, parallel, plan, and reflection.
  • Cap rounds and repeated calls to stop tool spam.
  • Mechanics detail lives in Module 03 Tool Calling.

FAQs

Is Tool-Use the same as function calling?

Function calling is a common API mechanism. Tool-Use is the broader design pattern: catalogs, policy, execution, observation, and composition with other patterns.

How many tools should one agent see?

As few as needed for the current route — often under ~10 focused tools. Large catalogs confuse models; route or orchestrate instead.

When should tools run in parallel?

When calls are independent reads without shared mutable state. Cap concurrency and define a join policy.

Where does MCP fit?

MCP is a packaging/protocol for exposing tools and resources to clients. The Tool-Use pattern still applies on top of whatever protocol you use.

Interview questions

  1. What is the Tool-Use pattern in Agentic AI?

    Answer A control pattern where the agent may select allowed tools, a runtime executes them under policy, and observations feed the next decision.

  2. How does Tool-Use differ from plain chat completion?

    Answer Chat only emits text. Tool-Use can trigger real side effects through a gated runtime and continue from structured results.

  3. Name the stages of a safe tool invocation.

    Answer Select, validate (schema + authz), execute with timeout/logging, observe a structured result, then recover or continue.

  4. How do you stop agents from looping on tools?

    Answer Max tool rounds, per-tool repeat caps, budgets, and escalation when the same call fails twice.

  5. How does routing help Tool-Use?

    Answer It shrinks the tool allowlist per intent so the model chooses among fewer, more relevant capabilities.

  6. Give a composition example.

    Answer Route to “research,” parallelize three search tools, draft an answer, then reflect against a citation checklist before final answer.

Related topics

Practice task

Complete each numbered practice step in a notebook or doc before opening the next lesson.

  1. List 8 tools for a support agent; mark each read-only or write.
  2. Design two route allowlists (billing vs tech) with ≤5 tools each.
  3. Write the validate checks you would run before a “refund” write tool.
  4. Define max_tool_rounds and a rule for “same tool failed twice.”
  5. Answer interview questions 1, 3, and 5 in two sentences each.