Skip to content

Agentic AI Patterns

An LLM agent is a model placed in a loop where it can take actions — call tools, read results, and decide what to do next — to accomplish a goal, rather than emitting a single response. The power comes from the loop; so does the risk, since a model that can act can act wrongly.

A useful distinction (from Anthropic’s Building Effective Agents): workflows orchestrate LLM calls along predefined paths, while agents dynamically decide their own steps. Prefer the simplest thing that works — most problems need a workflow, not a fully autonomous agent.

Tools are how an agent affects the world: search, code execution, API calls, database queries. The model is given tool schemas, decides which to call with what arguments, and receives the results back in context.

  • Describe tools precisely — clear names, argument descriptions, and when to use this. Underspecified schemas are a common source of tool-use failures.
  • Validate and sandbox — never execute model-chosen actions without validation; a tool that deletes or spends needs guardrails and ideally human confirmation.
  • Return structured, concise results — dump less; summarize what the model needs.
PatternHow it worksBest for
ReActInterleave Reason → Act → Observe each stepOpen-ended tasks where each step depends on the last
Plan-and-ExecuteMake a full plan first, then execute (and optionally replan)Multi-step tasks that benefit from up-front structure; fewer model calls
Reflexion (self-critique)Act, then critique and retryTasks with a checkable result (tests, validators)

ReAct is the common default; Plan-and-Execute reduces cost and drift on longer tasks by committing to a plan instead of re-deciding every step.

For concrete platform choices and recovery tests, see AI Agent Orchestration: Paperclip, Gas Town, Gas City, CAO, Agent Teams, and Orca.

Split a hard problem across specialized agents — e.g. an orchestrator that decomposes work and delegates to workers, then synthesizes. This helps when subtasks are independent (parallelizable) or need distinct expertise/tools.

Context windows are finite, so agents need memory beyond the current conversation:

  • Short-term — the running scratchpad of recent steps/observations; trim or summarize as it grows to avoid “lost in the middle.”
  • Long-term — facts persisted across sessions, typically retrieved with RAG (vector store of past interactions/knowledge) rather than stuffed into every prompt.
  • State/working memory — explicit task state (plan, todo list, intermediate results) the agent reads and updates deterministically.

Persistent assistants (Hermes Agent, Claude Duet, ChatGPT dots) and memory services such as Honcho are products built on these layers; see Persistent assistants: memory and learning.

An agent that can act turns prompt injection from a nuisance into a real-world risk: if untrusted input (a web page, a retrieved document, a tool result) can smuggle instructions into the model, it can also steer the model’s actions — calling tools, spending money, exfiltrating data. This pairing is why the OWASP Top 10 for LLM Applications lists both Prompt Injection (LLM01) and Excessive Agency (LLM06).

  • Treat all tool output as untrusted input — a document or API response can contain injected instructions; don’t let it rewrite the agent’s goals. See the defenses in Prompt Engineering Taxonomy.
  • Least privilege / minimize agency — give the agent the narrowest set of tools and permissions for the task; scope API tokens; prefer read-only where possible.
  • Human-in-the-loop for consequential actions — gate destructive, costly, or irreversible tool calls behind confirmation rather than trusting the loop.
  • Don’t use model output as a security control — validate and authorize actions server-side, outside the model.

You cannot debug an agent you can’t see. Instrument:

  • Tracing — capture every step: prompts, tool calls, arguments, results, token counts, latency. Tools like LangSmith or OpenTelemetry-based tracing make loops inspectable.
  • Guardrails & limits — cap iterations and spend; detect loops (the agent repeating the same failing action) and halt.
  • Evals — score agent runs against expected outcomes so changes don’t silently regress; see the evaluation discussion in RAG Patterns.

Recent changes

  1. docs(wiki): place persistent assistants and memory services beside orchestrators gitayam
  2. docs(wiki): compare agent orchestration platforms and evaluation methods gitayam
  3. docs(wiki): LLM engineering guides (RAG, agentic patterns, prompt taxonomy) Günther Van der Eecken
  4. feat(wiki): add 30 stub pages for all wanted-pages entries sac