Overview
Curated: · Written: · Reviewed:
Multi-Agent Systems & Orchestration
In one line
Several model-driven roles coordinated through an explicit graph, with typed contracts, budgets and server-side authority. Reach for it only when context, capability, trust domain, independent evidence or parallelism separates the work, and the composed result beats a measured single-agent or deterministic baseline.
Key definitions
- Dependency graph: tasks as nodes, data or control dependencies as edges; a node starts when all its inbound edges have finished.
- Critical path: the longest dependency chain by duration; it sets the minimum wall-clock time, however many workers run.
- Task contract: objective, non-goals, input artifact IDs, output schema, allowed tools, side-effect policy, budget, deadline, idempotency key.
- Ambiguous commit: a side-effecting call whose outcome is unknown because the response was lost or timed out.
- Saga: a record of completed external effects plus explicit compensations, each a new authorized action that can itself fail.
- Livelock: agents keep handing work back and forth with no state change and no terminal decision.
Formulas and complexity
Hypothetical worked example: at a 0.6 threshold, 2,000 × $2.50 + 8,000 × 0.04 × $30 = $14,600 per day. At 0.4, 800 × $2.50 + 9,200 × 0.11 × $30 = $32,360 per day. Quote the total cost per threshold, not the threshold that sounds safer.
How it works
- The orchestrator validates the graph first: every node has an owner, deadline, retry rule, completion criterion and budget.
- A node starts when its dependencies finish. Independent nodes run concurrently up to the concurrency limit.
- Workers return typed statuses: complete, fail, decline, clarify or partial. A validator and a postcondition decide completion, not the agent's stated confidence.
- Each tool call is checked by the gateway against the token presented on that call, scoped to the user's resources.
- Budgets and cycle caps are enforced by the orchestrator. Exhaustion is a typed terminal state, not a hang.
When to use and when not to
| Situation | Choose | Why |
|---|---|---|
| Fixed steps with testable inputs | Deterministic workflow | No model call per step, replayable |
| One context fits and tools suffice | Single agent with better tools | One prompt, one failure mode |
| Disjoint large contexts or trust domains | Multi-agent | Isolation limits blast radius |
| Critics that need independent evidence | Multi-agent with distinct criteria | Errors do not correlate |
| Voting over a shared model, prompt and context | Not multi-agent | Errors correlate; the measured gain may be near zero |
| Consequential writes without idempotency | Not yet | Retries duplicate effects |
Traps interviewers probe
- Counting schema-valid output as complete. Fix: derive success from a postcondition, such as rows written or a non-empty result checked against the source. Empty results from a 429 or a bad page become typed failures.
- Caching a delegated token by role. Fix: key the cache by user and resource scope, or exchange per request. The gateway authorizes whatever token arrives on each call.
- Retrying an ambiguous write with a fresh key. Fix: persist the idempotency key in workflow state before the call, check authoritative state after a timeout, and retry with the same key.
- Resetting depth counters in each child agent. Fix: pass remaining depth, fan-out and budget down from the root request so the limit covers the whole tree.
- Read-modify-write on shared JSON. Fix: append atomically in the database, or use a version check on the update. Lost updates raise no error.
Interview tips
Open with the baseline: "I start with one agent and better tools, and add an agent only where context, trust, evidence or parallelism separates the work."
Expect these follow-ups:
- Why not one agent with better tools?
- Walk me through your handoff format.
- Two agents keep passing work back. What happens?
- A refund call times out. Now what?
- The final answer is wrong. Which agent failed?
30-second outline: state the baseline and the separation that justifies a second agent. Describe the graph, with typed contracts, budgets and a terminal state for each cycle. Name where authority is enforced: server-side allowlists and per-call token checks. Finish with the measured trade-off: success, p95 latency and cost per successful task against the baseline.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.