Reusable AI patterns

AI
Patterns

Agent workflow patterns for structuring AI systems and prompt patterns for controlling LLM behavior.

Agent Patterns

13 patterns

Prompt Chaining

Sequence multiple LLM calls with conditional gates and branching paths.

workflowchaining

Routing

Classify user input and route it to the right handler or specialist agent.

classificationrouting

Parallelization

Fan out tasks to multiple LLM calls simultaneously and aggregate results.

performanceparallel

Orchestrator Workers

Delegate subtasks from an orchestrator to specialized worker agents.

orchestrationdelegation

Evaluator Optimizer

Loop between generator and evaluator LLMs (including self-critique) to iteratively improve outputs against quality criteria.

evaluationoptimization

Autonomous Agent

Build an agent with a ReAct loop: think, act, observe, and plan.

agentsreact

Tool Calling

Enable LLMs to call external APIs, databases, and functions via structured interfaces.

toolsfunctions

Retrieval-Augmented Generation

Retrieve relevant context from your data sources using vector search and hybrid retrieval to ground LLM responses with citations.

ragretrieval

Planner Executor Verifier

One stage plans the work, another executes it, and a verifier checks completion before the system advances.

planningverificationcontrol

Approval-Gated Actions

Let the model decide what action is needed, but require human or policy approval before side effects happen.

guardrailsapprovalssafety

Model Cascade Routing

Start with a cheaper or faster model, escalate to a stronger model only when confidence or complexity requires it.

routingcostlatency

Memory Tiering

Split state into working memory, session memory, and long-term memory with explicit write/read rules.

memorystatecontext

Trace and Eval Flywheel

Capture traces, grade them, turn failures into datasets, and iteratively improve prompts, tools, and routes.

evalsobservabilityquality