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.
Core agent patterns
How a single agent or workflow is shaped. Most interview questions start here.
1. Prompt chaining
How it works
- Break the task into fixed steps, each a focused LLM call.
- Add plain-code gates between steps to validate output.
- 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.
2. Routing
How it works
- A small, fast model classifies the request with structured output.
- Code dispatches it to a specialised prompt or agent.
- 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.
3. Parallelization (fan-out / fan-in)
How it works
- Split work into independent pieces (in LangGraph:
Send). - Workers run at the same time.
- 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.
4. ReAct tool loop
How it works
- Reason: the model decides what it needs.
- Act: it requests a tool call; your code runs it.
- 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.
5. Plan-and-execute
How it works
- A strong model writes a step-by-step plan once.
- An executor (often cheaper) runs each step with tools.
- 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.
6. Reflection / evaluator-optimizer
How it works
- A generator writes a draft.
- An evaluator scores it against explicit criteria.
- 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.
7. Supervisor (multi-agent)
How it works
- A supervisor decides which specialist acts next.
- Each specialist has its own prompt, tools and context.
- 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.
8. Handoffs (swarm / network)
How it works
- Each agent can transfer control to another agent.
- The receiving agent now owns the conversation.
- 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.
9. Human-in-the-loop approval
How it works
- The agent proposes a risky action.
interrupt()pauses the graph; state is checkpointed.- 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.
interrupt(), identity from auth, idempotency keys and an audit log. See it in the project.10. Agentic RAG
How it works
- The agent decides whether it needs documents.
- It retrieves, then grades the results for relevance.
- 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).
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
How it works
- An orchestrator LLM reads the task and decides the subtasks.
- Workers run them, often in parallel (LangGraph: a list of
Send). - 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.
12. Hierarchical teams
How it works
- A top supervisor delegates to team leads.
- Each lead is itself a supervisor over its own specialists (a LangGraph subgraph).
- 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.
13. Event-driven background agents
How it works
- Events (new ticket, PR opened, nightly schedule) go to a queue.
- Workers pull jobs and run the agent graph;
thread_id= job id, so crashes resume. - 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.
14. Blackboard (shared state)
How it works
- A shared workspace holds the goal, facts, plans and drafts.
- Agents read it and contribute when they can help; they don't message each other.
- 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.
15. Debate / voting (consensus)
How it works
- Several agents (or models) answer independently.
- A judge, or a simple majority vote, compares the answers.
- 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.
16. Cross-vendor agents: A2A + MCP
How it works
- Your agent discovers a remote agent from its agent card (skills, endpoint, auth).
- It sends a task over A2A and receives streamed status and artifacts.
- 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).
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)
How it works
- Every step's state is saved to a checkpointer (Postgres).
- After a crash, a new process resumes the same
thread_idwithinvoke(None, config). - 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.
18. Retries, circuit breaker, fallback
How it works
- Retry transient errors (429, 5xx, timeouts) with exponential backoff and jitter.
- A circuit breaker counts failures and "opens" after too many.
- 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.
19. Saga (compensating actions)
How it works
- Pair every side-effecting action with an undo.
- Run the actions in order.
- 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.
20. Guardrail pipeline
How it works
- Input guard: size limits, PII redaction, injection checks.
- Tool policy: allow, require approval, or deny each tool call.
- 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.
21. Observability loop
How it works
- Every run emits traces (each LLM and tool call) and metrics.
- Evals score sampled traces; dashboards and alerts watch metrics.
- 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.
22. Scale-out architecture
How it works
- A load balancer spreads traffic over stateless replicas.
- State lives in Postgres (pooled connections), so any replica serves any thread.
- 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.
23. Safe releases (eval gate + canary)
How it works
- Unit tests with a fake LLM, then offline evals against a baseline.
- Ship to a small canary share of traffic.
- 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.
Compare the patterns
| Pattern | Who controls the flow | Cost / latency | Best for |
|---|---|---|---|
| Prompt chaining | Code | Low, predictable | Known, fixed steps |
| Routing | LLM once, then code | Low | Distinct request types |
| Parallelization | Code | Faster wall-clock, more tokens | Many independent sub-tasks |
| ReAct loop | LLM, every step | Medium, variable | Open-ended tool use |
| Plan-and-execute | LLM plan, code loop | Medium | Long multi-step tasks |
| Reflection | Code loop, LLM judge | Medium to high | Quality-critical output |
| Supervisor | Coordinator LLM | High | Several specialists on one output |
| Handoffs | Each agent | Medium | Conversations that change topic |
| Human-in-the-loop | Human at checkpoints | Adds human wait time | Risky or irreversible actions |
| Agentic RAG | LLM decides retrieval | Medium | Hard questions over documents |
| Orchestrator-workers | Orchestrator LLM | Medium to high | Subtasks that depend on the input |
| Hierarchical teams | Supervisors at each level | High | Large tasks with many specialists |
| Event-driven | Queue + workers | Async; scales well | Long or high-volume background work |
| Blackboard | Controller + shared state | Medium | Open-ended collaboration, auditable steps |
| Debate / voting | Judge or majority vote | High (N agents) | Reliability on hard questions |
| A2A + MCP | Each agent, via contracts | Network hops | Agents across teams or vendors |
Drawing patterns in an interview
- Start from the simplest pattern that could work, and say why.
- Draw boxes for LLM calls, tools, checks and humans, just like the diagrams above.
- Mark the stop condition and limits on every loop.
- Point to where state is saved and where guardrails sit.
- 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.