AI agent, orchestration & ops patterns, animated

Twenty-three patterns that come up again and again in AI agent interviews: ten core agent patterns, six ways to orchestrate several agents, and seven production (ops) patterns. Watch each flow step by step, learn when to use it and what goes wrong, then practise drawing it on a whiteboard.

How to read the diagramsPurple boxes are LLM calls, amber are tools, green are plain code or checks, pink is a human, grey is stored data, and teal is input and output. The glowing token is the request moving through the system; the caption under each diagram explains the current step. Use Copy GIF to paste a diagram into notes, docs or chat, or Download GIF to save the file.

Core agent patterns

How a single agent or workflow is shaped. Most interview questions start here.

1. Prompt chaining

Prompt chaining: input goes to LLM 1 which extracts facts, a code gate checks the result and stops on failure, LLM 2 drafts, LLM 3 polishes, then output.

How it works

  1. Break the task into fixed steps, each a focused LLM call.
  2. Add plain-code gates between steps to validate output.
  3. The developer, not the model, decides the order.

Use it when

  • The steps are known in advance (extract → draft → polish).
  • You need predictable cost, latency and easy testing.

Watch out for

  • Errors propagate: validate between steps.
  • Breaks on inputs the chain didn't anticipate.
Interview angle"Would you use an agent here?" Strong answer: "Not yet. The steps are fixed, so a chain with validation gates is cheaper and testable. I'd add agency only where the path genuinely varies."

2. Routing

Routing: a request goes to a router LLM that classifies intent and sends it to a billing agent, tech support or a general prompt, which then produce the response.

How it works

  1. A small, fast model classifies the request with structured output.
  2. Code dispatches it to a specialised prompt or agent.
  3. Each route keeps its own instructions and tools.

Use it when

  • Requests fall into distinct categories with different tools or policies.
  • One big prompt is getting confused by unrelated instructions.

Watch out for

  • Misroutes: add a confidence threshold and a fallback route.
  • Measure router accuracy separately with its own eval set.
Interview angle"How would you scale a support bot to billing, tech and sales?" Start with a router plus specialised agents; mention router evals and a "not sure → general/human" path.

3. Parallelization (fan-out / fan-in)

Parallelization: a task is split by a splitter into three workers running in parallel, whose results are merged by an aggregator into one result.

How it works

  1. Split work into independent pieces (in LangGraph: Send).
  2. Workers run at the same time.
  3. A reducer collects results; an aggregator merges them.

Use it when

  • Summarising or analysing many documents.
  • Running several checks or "votes" for reliability.

Watch out for

  • Provider rate limits: cap concurrency.
  • Cost multiplies with the number of workers.
Interview angle"Speed up a report over 200 documents." Map-reduce with bounded concurrency, a reducer key, and a cheaper model for the map step. See the LangGraph code.

4. ReAct tool loop

ReAct loop: the user asks the LLM, which acts by calling tools and observes their results in a loop, and returns a final answer when no more tool calls are needed.

How it works

  1. Reason: the model decides what it needs.
  2. Act: it requests a tool call; your code runs it.
  3. Observe: the result goes back into context. Repeat until no more tool calls.

Use it when

  • The number and order of steps can't be known in advance.
  • The default choice for a general tool-using agent.

Watch out for

  • Loops: set a step limit (recursion_limit).
  • Too many tools: split into sub-agents.
Interview angle"Explain the agent loop on the whiteboard." Draw exactly this, name the stop condition and the step limit, and say the model never executes tools itself. See the code.

5. Plan-and-execute

Plan-and-execute: a planner writes a stored plan, an executor runs each step, a re-plan check either updates the plan or finishes with the result.

How it works

  1. A strong model writes a step-by-step plan once.
  2. An executor (often cheaper) runs each step with tools.
  3. A re-plan check updates the plan or finishes.

Use it when

  • Long, multi-step tasks (data analysis, migrations, research).
  • You want the plan visible to users or reviewers.

Watch out for

  • Stale plans: always allow re-planning.
  • Over-planning simple tasks: ReAct may be enough.
Interview angle"ReAct or plan-and-execute?" ReAct adapts each step but calls the big model every time; plan-and-execute is cheaper and inspectable for long tasks but needs re-planning.

6. Reflection / evaluator-optimizer

Reflection: a generator writes a draft, an evaluator scores it against a rubric and sends feedback back to the generator until the draft passes.

How it works

  1. A generator writes a draft.
  2. An evaluator scores it against explicit criteria.
  3. Specific feedback loops back until it passes or a round limit is hit.

Use it when

  • Quality matters and criteria are clear: code, translation, structured reports.
  • Tests or rules can act as the evaluator.

Watch out for

  • Cost: cap rounds (2–3).
  • A vague rubric makes the loop pointless.
Interview angle"How would you improve answer quality without a bigger model?" Add an evaluator with a rubric (or real tests for code), cap the rounds, and measure the gain with evals.

7. Supervisor (multi-agent)

Supervisor: a supervisor agent delegates to a researcher, an analyst and a writer; each reports back to the supervisor, which produces the final report.

How it works

  1. A supervisor decides which specialist acts next.
  2. Each specialist has its own prompt, tools and context.
  3. Results return to the supervisor until the work is done.

Use it when

  • Different skills or permissions are needed on one output.
  • A single agent has too many tools or conflicting instructions.

Watch out for

  • Every hop adds latency and tokens.
  • The supervisor can become a bottleneck.
Interview angle"When is multi-agent justified?" Only when one agent measurably struggles. Start single-agent, split on evidence. See the code.

8. Handoffs (swarm / network)

Handoffs: a customer talks to a triage agent, which hands off to a billing agent, which hands off to a refund agent; the issue is resolved.

How it works

  1. Each agent can transfer control to another agent.
  2. The receiving agent now owns the conversation.
  3. No central coordinator.

Use it when

  • Conversations move between departments (sales → onboarding → support).
  • Specialists should talk to the user directly.

Watch out for

  • Lost context: pass a structured summary at each handoff.
  • Ping-pong between agents: limit handoffs per conversation.
Interview angle"Supervisor vs handoffs?" The supervisor keeps central control and is easier to trace; handoffs are more flexible and conversational but harder to debug.

9. Human-in-the-loop approval

Human in the loop: an agent proposes a refund, the graph pauses and saves a checkpoint, a human approver approves it, the refund tool runs once, and the agent replies; on rejection the agent explains instead.

How it works

  1. The agent proposes a risky action.
  2. interrupt() pauses the graph; state is checkpointed.
  3. A person approves or rejects; Command(resume=…) continues.

Use it when

  • Money, emails, deletions or anything irreversible.
  • Regulated workflows that need an audit trail.

Watch out for

  • Needs a durable checkpointer (Postgres).
  • The node re-runs on resume: keep side effects idempotent.
Interview angle"How do you stop an agent issuing a wrong refund?" Threshold-based approval with interrupt(), identity from auth, idempotency keys and an audit log. See it in the project.

10. Agentic RAG

Agentic RAG: an agent decides to retrieve, searches the vector store, grades the documents, rewrites the query and retrieves again if they are not relevant, then answers with citations.

How it works

  1. The agent decides whether it needs documents.
  2. It retrieves, then grades the results for relevance.
  3. If they miss, it rewrites the query and tries again; then answers with citations.

Use it when

  • Multi-hop or ambiguous questions over your documents.
  • Classic one-shot RAG returns irrelevant chunks too often.

Watch out for

  • Extra LLM calls add latency: cap retries.
  • Fix retrieval quality first (chunking, hybrid search, reranking).
Interview angle"Classic RAG vs agentic RAG?" Agentic RAG makes retrieval a tool the agent controls, with grading and query rewriting. Use classic RAG for simple FAQ lookups.

Orchestration patterns

Orchestration is how several agents, tools and people are coordinated: who decides the next step, how work is split, how agents share information, and what happens when something fails. These six patterns build on the core ones above; see the Agent Ops track for running them in production.

11. Orchestrator-workers

Orchestrator-workers: an orchestrator LLM decides subtasks at runtime, workers run them, a synthesizer merges the results and can send a follow-up task back to the orchestrator.

How it works

  1. An orchestrator LLM reads the task and decides the subtasks.
  2. Workers run them, often in parallel (LangGraph: a list of Send).
  3. A synthesizer merges results and can request follow-up work.

Use it when

  • You can't predict the subtasks: code changes across files, research questions.
  • Parallelization would work, but the split depends on the input.

Watch out for

  • Cap the number of subtasks and follow-up rounds.
  • Give workers clear, self-contained instructions.
Interview angle"Orchestrator-workers vs parallelization?" In parallelization the split is fixed in code; here an LLM decides it at runtime. The Q&A bank has runnable code for both.

12. Hierarchical teams

Hierarchical teams: a top supervisor delegates to a research lead and a writing lead; each lead manages two specialists and returns a summary to the top supervisor, which produces the report.

How it works

  1. A top supervisor delegates to team leads.
  2. Each lead is itself a supervisor over its own specialists (a LangGraph subgraph).
  3. Only summaries travel up, keeping each level's context small.

Use it when

  • One supervisor would have too many workers to manage well.
  • Teams need different tools, models or permissions.

Watch out for

  • Each level adds latency, tokens and places to lose detail.
  • Trace across levels with one run id.
Interview angle"How would you scale a supervisor to 20 specialists?" Group them into teams with their own leads (subgraphs), pass summaries up, and set budgets per level.

13. Event-driven background agents

Event-driven agents: a new ticket event goes to a queue, worker agents pick up jobs, a successful job stores results and notifies the user, a failed job moves to a dead-letter queue for on-call review.

How it works

  1. Events (new ticket, PR opened, nightly schedule) go to a queue.
  2. Workers pull jobs and run the agent graph; thread_id = job id, so crashes resume.
  3. Results are stored and people notified; failures go to a dead-letter queue.

Use it when

  • Work takes minutes to hours, or nobody is waiting on a chat.
  • Traffic is spiky and you need back-pressure.

Watch out for

  • Idempotency: jobs can be delivered twice.
  • Scale workers on queue depth; alert on dead letters.
Interview angle"Design an agent that triages 50k tickets a day." Queue + workers + durable checkpoints + dead-letter queue, with idempotent writes. See queues & workers code.

14. Blackboard (shared state)

Blackboard: a controller posts the goal to a shared state board; planner, researcher, writer and critic agents read from and write to the board instead of messaging each other, until the goal is met.

How it works

  1. A shared workspace holds the goal, facts, plans and drafts.
  2. Agents read it and contribute when they can help; they don't message each other.
  3. A controller decides who acts next and when the goal is met.

Use it when

  • Many specialists contribute in an order you can't fix in advance.
  • You want every intermediate result visible and auditable.

Watch out for

  • Define a schema for the board and rules for conflicting writes (reducers).
  • The board grows: summarise or prune it.
Interview angle"How do agents share information?" Compare message passing, handoff summaries and a shared state. In LangGraph the graph state is a blackboard; reducers handle concurrent writes.

15. Debate / voting (consensus)

Debate and voting: a question goes to three independent agents using different models, a judge compares their answers, they see each other's reasoning in a second round and revise, then the judge votes on the final answer.

How it works

  1. Several agents (or models) answer independently.
  2. A judge, or a simple majority vote, compares the answers.
  3. Optionally, agents see each other's reasoning and revise before a final vote.

Use it when

  • Hard reasoning or classification where one mistake is costly.
  • You want a confidence signal (agreement rate).

Watch out for

  • Cost multiplies with the number of agents and rounds.
  • Agents sharing the same model can share the same blind spot.
Interview angle"How can you make answers more reliable without fine-tuning?" Self-consistency or multi-agent voting, using disagreement to escalate to a human. The Q&A bank has a runnable voting example.

16. Cross-vendor agents: A2A + MCP

Cross-vendor agents: your agent discovers a remote agent through its agent card, sends it a task over A2A and receives streamed results, while also calling tools through an MCP server, then answers the user.

How it works

  1. Your agent discovers a remote agent from its agent card (skills, endpoint, auth).
  2. It sends a task over A2A and receives streamed status and artifacts.
  3. Tools and data are reached through MCP servers.

Use it when

  • Agents are built by different teams, frameworks or companies.
  • You want to reuse an agent without merging codebases.

Watch out for

  • Treat remote agents as untrusted: authenticate, validate outputs, set timeouts.
  • Version the contract (skills and schemas).
Interview angle"A2A vs MCP?" MCP connects an agent to tools and data; A2A connects agents to other agents. Most systems use both.

Agent Ops patterns

The production side: how agents survive crashes, outages, attacks, traffic spikes and risky releases. Each one is also covered with runnable code in the Agent Ops track.

17. Durable execution (crash and resume)

Durable execution: an order charges the card, state is checkpointed, the pod crashes while sending the receipt, a new pod resumes from the checkpoint and only re-runs the receipt step.

How it works

  1. Every step's state is saved to a checkpointer (Postgres).
  2. After a crash, a new process resumes the same thread_id with invoke(None, config).
  3. Finished steps are skipped; only the interrupted step runs again.

Use it when

  • Runs have real side effects (payments, emails, tickets).
  • Runs are long, or wait on humans for hours or days.

Watch out for

  • The interrupted step re-runs: make it idempotent.
  • Use durability="sync" for critical flows.
Interview angle"A pod dies after charging the customer. What happens?" Checkpoint after each step, resume the thread, idempotency keys on side effects. Agent Ops: durable execution code.

18. Retries, circuit breaker, fallback

Retries and fallback: the LLM client calls the primary model, a 429 error is counted by a circuit breaker and retried with backoff, after repeated failures the circuit opens and calls go to a fallback model.

How it works

  1. Retry transient errors (429, 5xx, timeouts) with exponential backoff and jitter.
  2. A circuit breaker counts failures and "opens" after too many.
  3. While open, traffic goes to a fallback model or region; later it tests the primary again.

Use it when

  • Any production LLM call: providers rate-limit and have outages.
  • You have a second provider or region available.

Watch out for

  • Never retry validation errors (400s).
  • Retries from many replicas can amplify an outage: cap them.
Interview angle"How do you handle provider outages?" Backoff with jitter, a client-side rate limiter, a circuit breaker, and a fallback model, plus a degraded mode (ticket instead of answer). Agent Ops: retries vs fallbacks.

19. Saga (compensating actions)

Saga: reserve stock, charge card and book courier run in order; the courier step fails, so the system refunds the card and releases the stock in reverse order and cancels the order.

How it works

  1. Pair every side-effecting action with an undo.
  2. Run the actions in order.
  3. On failure, run the undos in reverse order, then report clearly.

Use it when

  • One agent run changes several external systems.
  • There is no single transaction across those systems.

Watch out for

  • Undos can fail too: retry them and alert.
  • Combine with idempotency keys so retries don't double-apply.
Interview angle"The agent booked a flight but the hotel failed. Now what?" Saga with compensations, idempotency, and a human escalation path if an undo fails. Agent Ops: saga code.

20. Guardrail pipeline

Guardrail pipeline: an input guard blocks an injection attempt, the agent's tool calls go through a policy that allows a read-only lookup and sends a large refund to a human approver, and an output check verifies the reply before the user sees it.

How it works

  1. Input guard: size limits, PII redaction, injection checks.
  2. Tool policy: allow, require approval, or deny each tool call.
  3. Output check: grounding, PII and forbidden promises before replying.

Use it when

  • Always, for anything customer-facing.
  • Agents with tools that change data or spend money.

Watch out for

  • Prompts aren't a security boundary: enforce permissions in code.
  • Measure false blocks as well as attacks caught.
Interview angle"Which guardrails would you put on a refund agent?" Walk this pipeline layer by layer and add audit logging. Agent Ops: guardrails.

21. Observability loop

Observability loop: agent runs emit traces and metrics; traces feed evals, metrics feed dashboards and alerts; both notify an engineer, whose fix passes a release gate before being deployed back to production.

How it works

  1. Every run emits traces (each LLM and tool call) and metrics.
  2. Evals score sampled traces; dashboards and alerts watch metrics.
  3. Fixes go through an eval gate before deployment.

Use it when

  • From the first production user.
  • Before changing prompts, models or tools.

Watch out for

  • Tag everything with thread, tenant, prompt and model version.
  • Redact PII in traces.
Interview angle"How do you monitor an agent?" Outcome, latency, cost, behaviour, safety and health metrics, plus traces and evals in one loop. Agent Ops: what to monitor.

22. Scale-out architecture

Scale-out: users reach a load balancer, three stateless agent replicas share the load, LLM calls pass through a rate limiter to the LLM API, and conversation state lives in Postgres so any replica can resume any thread.

How it works

  1. A load balancer spreads traffic over stateless replicas.
  2. State lives in Postgres (pooled connections), so any replica serves any thread.
  3. A rate limiter keeps LLM calls under the provider quota.

Use it when

  • More than one replica, or any autoscaling.
  • Traffic spikes near your provider quota.

Watch out for

  • Scale on concurrency or queue depth, not CPU.
  • Raise load-balancer timeouts for streaming responses.
Interview angle"Scale this to 100 conversations a minute." Do the capacity maths: quota and cost bind long before CPU does. Agent Ops: capacity maths.

23. Safe releases (eval gate + canary)

Safe releases: a prompt or model change runs unit tests with a fake LLM, then an eval gate that blocks it if below baseline; after a fix it passes, deploys as a canary, metrics are compared, and it rolls out to everyone or rolls back.

How it works

  1. Unit tests with a fake LLM, then offline evals against a baseline.
  2. Ship to a small canary share of traffic.
  3. Compare success, cost and latency; roll out or roll back.

Use it when

  • Every prompt, model, tool or retrieval change.
  • Model provider upgrades.

Watch out for

  • Pin model versions; floating aliases change under you.
  • Keep rollback to a single config change.
Interview angle"How do you ship a new prompt safely?" Version it, gate it on evals in CI, canary it, compare metrics, and keep instant rollback. Agent Ops: incident playbook.

Compare the patterns

PatternWho controls the flowCost / latencyBest for
Prompt chainingCodeLow, predictableKnown, fixed steps
RoutingLLM once, then codeLowDistinct request types
ParallelizationCodeFaster wall-clock, more tokensMany independent sub-tasks
ReAct loopLLM, every stepMedium, variableOpen-ended tool use
Plan-and-executeLLM plan, code loopMediumLong multi-step tasks
ReflectionCode loop, LLM judgeMedium to highQuality-critical output
SupervisorCoordinator LLMHighSeveral specialists on one output
HandoffsEach agentMediumConversations that change topic
Human-in-the-loopHuman at checkpointsAdds human wait timeRisky or irreversible actions
Agentic RAGLLM decides retrievalMediumHard questions over documents
Orchestrator-workersOrchestrator LLMMedium to highSubtasks that depend on the input
Hierarchical teamsSupervisors at each levelHighLarge tasks with many specialists
Event-drivenQueue + workersAsync; scales wellLong or high-volume background work
BlackboardController + shared stateMediumOpen-ended collaboration, auditable steps
Debate / votingJudge or majority voteHigh (N agents)Reliability on hard questions
A2A + MCPEach agent, via contractsNetwork hopsAgents across teams or vendors

Drawing patterns in an interview

  1. Start from the simplest pattern that could work, and say why.
  2. Draw boxes for LLM calls, tools, checks and humans, just like the diagrams above.
  3. Mark the stop condition and limits on every loop.
  4. Point to where state is saved and where guardrails sit.
  5. Name the trade-off you accepted: cost, latency, reliability or control.

Most real systems combine patterns, for example a router in front of a ReAct agent with human approval for refunds, as in the SupportPilot project. Practise explaining one aloud in the mock interview.