III · Tool Use & EnvironmentMature★★

Tool Use

also known as Function Calling, Tool Calling, Action Use

Let the LLM produce typed calls against an external toolkit instead of producing free-form text the surrounding system has to parse.

This pattern helps complete certain larger patterns —

  • used-byReAct★★Interleave a single thought, a single tool call, and a single observation per step so the agent reasons over fresh evidence.
  • specialisesModel Context Protocol★★Standardise how agents discover and call tools so that a tool written once is usable by any conformant agent.
  • used-byAgentic RAG★★Replace static retrieve-then-generate with autonomous agents that plan, choose sources, retrieve iteratively, reflect, and re-query.
  • used-byMemGPT-Style PagingTreat the LLM context window as RAM and external storage as disk, with the model issuing tool calls to page memory in and out.
  • used-byTool-Augmented Self-CorrectionSelf-correct LLM outputs by interactively critiquing them with external tools (search, code execution, calculator).
  • used-byParallel Tool Calls★★Allow the model to emit several independent tool calls in one assistant turn; the host executes them in parallel.
  • used-byAgent-as-Tool EmbeddingWrap a sub-agent (with its own loop, prompt, and tool palette) behind a single function-shaped tool signature, so the parent agent calls it like any other tool and never sees the sub-agent's internal turns.
  • used-byAugmented LLM★★Build the foundational agent block as an LLM augmented with retrieval, tools, and memory that the model actively chooses to use, rather than a bare-model call.

Context

A team is building an agent that has to affect the outside world: read a customer record, cancel an order, write a row to a database, render a chart, post to a channel. The model alone cannot do these things safely or correctly, and the surrounding system needs deterministic, validated operations to act on intent.

Problem

If the model speaks only free-form text, the host has to parse intent out of prose on every turn: the model invents field names, mis-spells operations, returns half-structured Markdown, or buries the actual command in an explanation. Invalid calls are caught only when downstream code crashes, and audit trails for which operations were attempted have to be reconstructed from natural language. The model is good at expressing intent and weak at producing perfectly typed structure without a schema to validate against.

Forces

  • The model is good at intent, weak at typed structure.
  • The host system needs deterministic operations to act.
  • Schema rigidity reduces the model's freedom; too much rigidity loses recall.

Example

A customer-support agent receives 'cancel my order #4471.' Instead of writing free-form text the surrounding code has to parse, it emits a structured call: cancel_order({order_id: '4471'}). A validator checks the call against the API's schema; the executor runs it; the agent gets back {status: 'cancelled', refund_amount: 49.99}. The model never has to guess at field names or formatting.

Diagram

Solution

Therefore:

Define a typed tool palette. The model emits tool calls conforming to a JSON Schema; the host validates and executes; results return as structured tool results. The agent becomes a thin client of a deterministic toolkit.

What this pattern forbids. The model cannot affect state except through a registered tool with a typed signature.

The smaller patterns that complete this one —

  • usesStructured Output★★Constrain the model's output to conform to a JSON Schema (or similar typed shape).
  • generalisesBrowser AgentExpose websites to the agent through a structured DOM/accessibility tree plus a small action vocabulary, sitting between raw HTML and pixel-level Computer Use.
  • generalisesCode Execution★★Let the model emit code, run it in a sandbox, and treat the run as the answer instead of trusting the model to compute in its head.
  • generalisesTool Result Caching★★Cache the result of expensive deterministic tool calls keyed by their arguments so repeat calls within a session return immediately.
  • generalisesTool DiscoveryLet the agent discover available tools at runtime rather than hardcoding the tool list at agent build time.
  • generalisesToolformerTrain the model to learn when and how to call tools through self-supervised data, without human annotation.
  • generalisesAgent-Computer InterfaceDesign the tool surface for an LLM agent specifically, with affordances different from human-facing CLIs.
  • generalisesWorld Model as Tool·Let a planning agent invoke a generative world model as a tool to roll out hypothetical futures before committing to an action, treating the world model as a callable simulator rather than a training target.

And the patterns that stand alongside it, or against it —

  • alternative-toHallucinated ToolsAnti-pattern: trust the model to invoke only the tools it has been given, then debug calls to functions that do not exist.
  • alternative-toNaive-RAG-FirstAnti-pattern: reach for naive RAG before checking whether the knowledge actually needs retrieval.
  • alternative-toSchema-Free OutputAnti-pattern: parse free-form model output for downstream code instead of using structured output.
  • complementsAwarenessMaintain the agent's explicit knowledge of its own tools, capabilities, environment, and current context as queryable state.
  • alternative-toCode-as-Action AgentHave the agent emit a code snippet as its action each step, executed in a constrained interpreter, instead of emitting JSON tool calls; tool composition becomes function nesting and control flow inside the snippet.
  • alternative-toJSON-Only Action SchemaAnti-pattern: restrict the agent's action language to JSON tool-call dictionaries even for tasks where code-as-action (functions composing, loops, conditionals over results) would be the natural shape.
  • complementsLarge Action Models (LAMs)·Use a model class specifically trained for action execution (tool calls, UI navigation, workflow steps) rather than text generation, when the workload is dominated by reliably completing actions in real systems.
  • complementsMRKL Systems (Modular Neuro-Symbolic)★★Route each request through an LLM dispatcher to specialized symbolic or neural expert modules (calculator, knowledge base, code executor) rather than asking one LLM to do everything; integrate the modules' results for the final response.
  • complementsPerformative Message★★Inter-agent messages are typed by communicative intent (request, inform, propose, accept, refuse, query) rather than by free-form prose, so receivers can dispatch on act type.
  • complementsCrawler Dispatcher★★Route each incoming URL to a domain-specific crawler through a central dispatcher mapping URL patterns to registered crawler classes.
  • complementsHierarchical Tool SelectionOrganise tools into a tree of categories so the agent first picks a branch and then a specific tool within it.
  • complementsTool Transition Fusion·Mine tool-call telemetry for high-probability X-then-Y transitions and fuse those pairs into a single composite tool, shrinking the planner's step count.

Neighbourhood

Click any neighbour to follow the language. Scroll to zoom, drag to pan.

Used in recipes

Used in frameworks

Show 108 more

References

Provenance