Grid of agentic pattern names on an indigo hero background

Agentic patterns for system design

Catalog of agentic design patterns with worked examples: ReAct, plan-and-execute, reflection, router, orchestrator–worker, map–reduce, supervisor, RAG-as-tool, Self-RAG, HITL, memory hygiene, pattern economics, and composition playbooks for production systems.

Patterns vs architectures vs frameworks

When interviewers ask for an "AI agent," they often want to hear which patterns you stack: route cheap requests away from expensive loops, retrieve before you act, verify before you ship, pause before you refund. This post is the pattern catalog — the building blocks behind Agentic architectures and the libraries in Agentic frameworks.

Four columns of pattern families: control, quality, scale, context.
Four families — control, quality, scale, context — most products mix across them.
01Control

ReAct · plan · router.

02Quality

Reflect · verify · CRAG.

03Scale

Map–reduce · supervisor.

04Safety

HITL · guardrails.

1. ReAct (Reason + Act)

ReAct interleaves reasoning and tool use: the model thinks about what to do, calls a tool, observes the result, and repeats. It is the default mental model for single-agent tool loops.

Thought, action, observation loop until answer.
Thought → Action → Observation — the loop behind most tool-calling agents.
  • When — unknown action sequence; small allowlisted tool set; interactive Q&A with lookups.
  • Production — use native function calling; don't parse free-text "Action:" unless you must.
  • Guards — max_steps, timeout, duplicate-tool detection, budget cap.
  • Anti-pattern — 20 tools with vague descriptions; the model thrashes.

2. Plan-and-execute

Separate planning from execution. A planner emits an ordered step list (JSON); an executor runs each step with tools or a smaller model. On failure, replan the remainder.

  • When — multi-phase tasks (research → draft → cite); compliance needs a visible plan; resume after crash.
  • vs ReAct — plan upfront reduces wandering; bad plans are expensive — validate plan length and tool feasibility.
  • Variants — plan once; replan every N steps; plan → execute → critique → revise plan.
  • Interview detail — store the plan as an artifact; executor checkpoints after each step.

3. Router / classifier

Input through router to RAG, tool agent, or human.
Route by intent, risk, and cost — agents are the expensive branch.

A lightweight router (rules, embeddings, small classifier) sends traffic to the right pattern stack:

  • FAQ / policy → RAG-only path (no tools).
  • Transactional → ReAct + action tools.
  • High risk → human queue or deny.
  • Signals — intent label, confidence, tenant tier, keyword triggers (refund, legal).

Routers save cost and reduce tool misuse. In interviews, draw the router before the agent box.

4. Reflection and critic–verify

Reflection adds a second pass: generate → critique → revise (cap rounds). Critic–verify uses a separate prompt/model role to find errors before shipping.

Generator to critic to pass or revise loop.
Cap revision rounds (2–3) — infinite reflection burns budget without eval gains.
  • When — code generation, legal/policy summaries, anything where silent errors hurt.
  • Cheaper variant — rule-based verifier (schema, citation ids exist, refund ≤ order total).
  • LLM critic — separate system prompt; never let the generator grade itself without rubric.
  • Eval — measure whether critic catches injected errors on a golden set.

5. Orchestrator–worker

Orchestrator assigning three workers subtasks.
Orchestrator decomposes; workers execute subtasks in parallel when independent.

One orchestrator breaks a goal into subtasks, assigns them to workers (LLM agents, tools, or humans), and merges results. Workers share a scratchpad or artifact store — not an unbounded group chat.

  • When — parallelizable research, multi-source gathering, "compare these three vendors."
  • Contract — each worker returns structured output (JSON) with status and citations.
  • Failure — orchestrator retries failed workers or degrades gracefully.
  • vs supervisor — orchestrator is often explicit decomposition; supervisor may delegate dynamically.

6. Map–reduce for agents

Split input, parallel map agents, reduce merge.
Classic for long documents, log analysis, and corpus-wide questions.

Map — run the same agent prompt over shards (chunks, files, time windows). Reduce — one synthesis step merges partial answers. Same pattern as big-data map–reduce; agents replace mappers.

  • When — input exceeds context; "summarize all Q3 tickets"; compliance scan across PDFs.
  • Reduce quality — reduce step is where coherence matters; often use a stronger model.
  • Cost — parallel maps spike spend; cap shard count and cache map outputs.
  • Combine with RAG — map over retrieved chunks, reduce into one answer with citations.

7. Supervisor and pipeline stages

Supervisor pattern

A supervisor agent assigns tasks to specialists, reviews output, and decides completion. Handoffs are typed messages (goal, inputs, done criteria) — see multi-agent section in Agentic architectures.

Pipeline / assembly line

Fixed stages with different prompts/models: outline → draft → fact-check → edit. Less "emergent agent," more deterministic stage graph with LLM nodes. Prefer this when the sequence is stable.

  • Supervisor — dynamic delegation; good for open-ended research.
  • Pipeline — predictable content workflows; easier to eval per stage.
  • Hybrid — pipeline for happy path; supervisor only on failure branches.

8. RAG + agent patterns

Agent loop with retrieve tool, action tools, and Self-RAG/CRAG.
Retrieval is usually a tool inside the agent — not a separate product silo.

RAG-as-tool

Expose search_knowledge_base(query) as one tool among many. The agent decides when to retrieve vs when to call CRM APIs. Keeps one loop; avoids hard-coding retrieve-then-generate for every query.

Iterative retrieval

Agent retrieves → partial answer → new query → retrieve again (multi-hop). Cap hops; log each query for eval.

Self-RAG / CRAG (Corrective RAG)

After retrieval, a grader scores relevance. Low score → rewrite query, try hybrid search, or refuse. Reduces confident wrong answers when context is weak. Details on retrieval in RAG.

9. HITL and guardrails

Agent step through risk check to auto execute or human approval.
Human-in-the-loop is a pattern — interrupt, approve, resume — not an afterthought.
  • HITL gate — pause before write tools, large refunds, external email, deploy.
  • Input guardrails — block jailbreaks, PII exfil patterns, off-topic abuse.
  • Output guardrails — schema validation, citation checks, policy regex.
  • Tool guardrails — argument validation, amount caps, idempotency keys.
  • Resume — durable workflow stores pending approval; webhook continues run.

10. Memory and context patterns

  • Scratchpad — short running summary of goal + progress; updated each step.
  • Observation trim — store full tool JSON in object storage; prompt gets summary + pointer.
  • Window + summarize — when history exceeds N tokens, summarize older turns.
  • Retrieve memory — episodic facts from DB/vector store per user, not full chat log.
  • Procedural skills — versioned playbooks injected when intent matches ("refund flow v3").

11. Structured output and tool discipline

Agents stay reliable when every boundary is typed:

  • Tool schemas — JSON Schema / OpenAPI; reject invalid args before execution.
  • Final answer schema — JSON mode for downstream UI (tickets, citations array).
  • State schema — graph/checkpointer stores typed state, not opaque strings.
  • Handoff schema — multi-agent messages with required fields.

See structured output techniques in Prompt engineering. In agents, structure is how you verify and automate — not optional polish.

Deterministic fallback

When the LLM fails (timeout, invalid JSON, policy block), fall back to rules: route to human, return cached FAQ, or execute a known workflow branch. Principals never leave the user staring at a 500 — pattern stacks include a degraded mode.

Pattern economics (when to add each)

PatternBuys youCostsAdd when
RouterLower $, fewer tool mistakesMisroute risk>30% traffic is FAQ/simple
ReActFlexible actionsLatency, loopsUnknown tool sequence
Plan–executeAudit, resumeBad plan taxMulti-phase + compliance
ReflectionQuality2–3× LLM callsSilent errors are expensive
Map–reduceScale over large inputParallel $ spikeContext overflow
HITLSafetyHuman latencyIrreversible writes
Self-RAGFewer wrong answersExtra retrieve/graderWeak context incidents

Principal engineer lens

  • Name the stack — "router → RAG-as-tool → ReAct → critic → HITL" is a design; "agent" is not.
  • One failure per pattern — router fixes cost; HITL fixes irreversible writes; reflection fixes silent quality bugs.
  • Caps everywhere — steps, hops, reflection rounds, map shards — unbounded loops are incident templates.
  • Test trajectories — assert tool sequence or final state, not just string match on output.
  • Degrade gracefully — human queue beats wrong refund; keyword search beats hallucination when vector path is down.

Composing patterns

Support agent stacking router, RAG, ReAct, critic, HITL, structured reply.
Real systems stack patterns — name the stack explicitly in the interview.
Product shapeTypical pattern stackConcrete flow
Docs Q&ARouter → RAG-only"API rate limits?" → classifier → retrieve → answer + cite
Support copilotRouter → RAG-as-tool + ReAct + HITL + criticRefund request → get_order → search policy → HITL if >$50 → critic checks cite
Research reportPlan–execute → map–reduce → pipelinePlan 5 steps → map 20 sources → reduce → edit stage
Coding agentReAct + sandbox + reflection + testsEdit file → run tests → critic on diff → fix loop max 2
Long-running opsDurable workflow + ReAct + HITLTicket backlog worker; pause on deploy tool

Anti-patterns to avoid

  • Agent for everything — FAQ doesn't need ReAct.
  • Infinite agents — five roles for a two-tool task.
  • Chat room multi-agent — unbounded peer messages, no merge contract.
  • Retrieve always — wastes latency when the user wants an action.
  • No stop condition — loops until budget explodes.
  • Reflection without cap — 10 revision rounds, same error.
  • Framework as architecture — "CrewAI" is not a pattern name.
Anti-patternLooks likeReplace with
God agent40 tools, one promptRouter + specialist tool packs
Chat room agentsUnbounded peer messagesTyped handoffs + artifact store
Retrieve alwaysRAG before every actionRAG-as-tool when needed
Infinite reflect10 critique roundsCap 2 + rule verifier first
Framework cosplay"We'll use AutoGen"Name ReAct/HITL/router first

Worked pattern stack: coding agent

Product: IDE agent that edits a repo and runs tests.

  • Router — explain code → RAG over repo index; implement feature → agent path.
  • ReAct toolsread_file, write_file, run_tests, search_codebase (sandbox network deny).
  • Reflection — after tests fail, critic on diff; max 2 fix loops.
  • Verifier — tests are the oracle (deterministic), not an LLM judge.
  • HITL — force approve before git push or rm.
  • Memory — scratchpad of failing test names; don't paste full build logs.

In your interview

Prompts: "Design a refund agent," "Design a research assistant," "How would you reduce hallucinations?" "Single agent vs multi-agent?"

What to say out loud

"I'd router first: FAQ goes to RAG-only. Action requests enter a ReAct loop with retrieve, get_order, and refund tools — max 10 steps. Refunds over $50 hit an HITL interrupt. Before we reply, a critic checks policy citations and a schema validator ensures structured output with source ids. Long policy docs use map–reduce over chunks, then reduce. We eval trajectory success and citation accuracy, not just final prose."

  • Name patterns by proper nouns (ReAct, router, HITL) — interviewers recognize them.
  • Draw where each pattern starts and stops.
  • Tie each pattern to a failure it prevents.
  • Give caps: steps, reflection rounds, retrieval hops.
  • Say what you'd remove if latency budget is 3s.

Cost and performance levers

Pattern selection checklist

  • Start with router + (RAG-only | bounded ReAct).
  • Add HITL for irreversible writes on day one if money/PII/prod.
  • Add reflection when silent errors are costly and tests/rules aren't enough.
  • Add map–reduce when input exceeds context.
  • Add supervisor when skills conflict and evals prove it.
  • Cap every loop; A/B each new pattern on golden tasks.
  • Delete patterns that don't move pass rate, latency, or $/success.

Pattern regression testing

Failure modes to mention

Call out at least one dependency failure (DB down, cache stampede, queue lag, region outage) and your mitigation (timeouts, retries with jitter, degraded mode, circuit breaker).

Interview Q&A by level

Practice saying these out loud for agentic patterns. Interviewers grade clarity and judgment more than buzzwords.

Interview takeaway

Match depth to the bar: define → trade off → operate. Don't dump principal answers in an entry-level screen.

Wrapping up

Agentic patterns are the vocabulary of production AI systems: ReAct for action, router for cost, reflection for quality, map–reduce for scale, HITL for safety, RAG-as-tool for knowledge. Compose them deliberately, cap every loop, and measure trajectories — not demo magic.

Continue with Agentic architectures, Agentic frameworks, RAG, Prompt engineering, and Key technologies.

← Lattice