Skip to main content
Building agents from scratch every time is slow and error-prone. Experienced builders reuse patterns — tested solutions to recurring problems — to accelerate development and reduce risk. This article catalogs common agentic patterns, explains when to apply them, and shows how they fit together in production systems for reliable, auditable AI agents.

Augmented LLM

At the core of most agents is the Augmented LLM pattern: take a base LLM and equip it with three complementary capabilities:
  • Retrieval — fetch relevant external knowledge (embeddings, vector search, or document stores).
  • Tools — execute actions (APIs, browser automation, shell commands, calculators).
  • Memory — persist and recall context across sessions or tasks.
The LLM remains the central orchestrator while Retrieval, Tools, and Memory provide the external functionality that turns a general model into an agent that can do real work.
A stylized diagram titled "AUGMENTED LLM" with a central "LLM — BASE MODEL" node connected to three boxes labeled "RETRIEVAL (Look up information)," "TOOLS (Take actions)," and "MEMORY (Remember context)" on a dark grid background. The graphic uses retro pixel fonts and includes a small robot logo in the corner.
Every production agent should start as an augmented LLM: combine a reliable base model with robust retrieval, well-defined tools, and persistent memory.

Pattern 2 — Tool selection

When an agent can call multiple tools, reliable tool selection is essential. The agent chooses tools based on the descriptions and interfaces you provide, so invest in precise tool manifests. Poor tool manifests are ambiguous and lead to wrong decisions:
A clear manifest includes purpose, typed parameters, return schema, and guidance on when to use the tool:
Best practices for tool selection:
  • Use concise, explicit descriptions that explain purpose and limits.
  • Define parameter types and validation rules.
  • Provide an explicit return schema to make parsing predictable.
  • Include guidance about when to use the tool (and when not to).
Invest in typed tool manifests, structured outputs, and interface documentation so the LLM can reliably pick and call the right tool.

Pattern 3 — Structured output

When agent outputs feed downstream systems (APIs, databases, analytics), enforce machine-readable structure. Structured output improves predictability, simplifies validation, and reduces error-prone parsing. Use strict schemas (JSON Schema or equivalent) and validate model responses before acting on them. Example JSON Schema:
Tips:
  • Provide the schema to the model in the system prompt and instruct: “Always respond with valid JSON conforming to the provided schema.”
  • Parse and validate the model output; re-prompt or use fallback logic if validation fails.
  • When possible, use model-provider features that enforce response schemas or typed outputs.

Pattern 4 — Guardrails

Guardrails are automated checks and rule systems that constrain agent behavior. They protect against prompt injection, harmful content, data leaks, and other undesired actions. Implement guardrails both before and after the agent runs.
  • Input guardrails: sanitize and validate user requests (prompt-injection detection, authorization checks, scope enforcement).
  • Output guardrails: validate and sanitize agent responses (format enforcement, hallucination detection, PII redaction).
These checks usually form a pipeline: user input → input guardrails → agent processing → output guardrails → user
An infographic titled "Guardrails" showing a pipeline from user input to an agent to user output, with left-side "Input Guardrails" (block prompt injection, filter content, verify request scope) and right-side "Output Guardrails" (catch hallucinations, enforce format, no data leaks). The bottom shows the pipeline: input → checks → agent → checks → output.
Always validate both inputs and outputs. Guardrails are critical for any user-facing agent or agent that handles sensitive data.

Pattern 5 — Human-in-the-loop

Not every decision should be fully automated. For irreversible, costly, or legally-sensitive actions, require explicit human approval. Human-in-the-loop patterns insert checkpoints so people can review and confirm high-stakes operations. Example flow:
  • Agent: “I found a flight for $280 at 2:30 p.m. on Friday. Should I book it?”
  • User: confirms
  • Agent: proceeds only after confirmation
Design explicit confirmation flows and audit trails for approvals. Store decisions in logs for accountability and compliance.
A dark retro-style infographic titled "HUMAN-IN-THE-LOOP" showing "Pattern 5 — Pause for High-Stakes Actions" with a mock assistant note that Zippy found a $280 flight at 2:30pm Friday. To the right it asks "Should I go ahead and book it?" with big green YES and red NO buttons and examples of hard-to-reverse actions like purchases and messages.
Require explicit confirmations for actions that are destructive, costly, or privacy-sensitive — and log those approvals for auditability.

Pattern 6 — Model fallback

Models and providers can experience outages, rate limits, or degraded performance. Implement model fallback so the agent stays available and responsive when a primary model fails. A simple fallback chain example:
  1. Try Anthropic Claude —> if unavailable,
  2. Try OpenAI GPT-4 —> if unavailable,
  3. Try Google Gemini.
Services like OpenClaw and similar platforms can help by supporting multiple providers and automated failover to maintain uptime.
A retro-style infographic titled "MODEL FALLBACK" showing a fallback flow where CLAUDE (Anthropic) and GPT-4 (OpenAI) are marked "FAIL" while GEMINI (Google) is marked "SUCCESS." A legend on the right lists supported providers: Anthropic, OpenAI, Google, and AWS Bedrock.

Combining patterns

These patterns are complementary and commonly used together in production agents:
  • Augmented LLM: always start here.
  • Tool selection: necessary when the agent exposes multiple action primitives.
  • Structured output: required when downstream systems consume agent output.
  • Guardrails: must be present for user-facing or sensitive workflows.
  • Human-in-the-loop: use for irreversible or high-risk actions.
  • Model fallback: add when uptime, resilience, or cross-provider diversity matters.
Apply patterns thoughtfully: pick the minimal set that addresses your reliability, safety, and compliance goals.

Patterns quick reference

Links and references Patterns solve concrete operational problems. Use them together to build agents that are reliable, auditable, and safe for production.

Watch Video