Overview
Curated: · Written: · Reviewed:
Agent Frameworks, Orchestration & MCP
In one line
A stateful orchestration framework (LangGraph and peers) persists the state of a multi-step agent run so it survives crashes, branches and human approvals. MCP is the protocol that connects a host to tools, resources and prompts served by separate servers. Reach for a state graph when you need interrupts, parallel joins or durable resume, and for MCP when a tool surface must work across many hosts.
Key definitions
- Checkpoint: persisted typed state written after each node, holding node position, attempt count, recorded effect results and deadlines.
- Interrupt: a state transition that persists state and returns a handle. Resume is a fresh process loading that state.
- Idempotency key: an identifier sent with an external side effect so a repeated call does not repeat the effect.
- Host, client, server: the app the user runs, the per-server connector inside it, and the program exposing capabilities.
- Tools, resources, prompts: model-controlled actions, application-controlled context, and user-invoked templates.
- Capability negotiation: the
initializehandshake in which each side declares what it supports. Neither side guesses.
How it works
- The model is stateless. The conversation is re-sent on every call, so orchestration state is a separate typed record you own.
- After each node the checkpointer persists state. On a crash, a new process loads the last checkpoint.
- Nondeterministic results (model output, clock, RNG, tool effects) are recorded and replayed, never re-executed.
- For a card charge: persist intent, call the payments API with an idempotency key, then persist the result.
- Over MCP, the client sends
initializewith its version and capabilities, the server answers, the client sendsinitialized, and both sides use only the features declared.
When to use and when not to
| Approach | Use when | Avoid when |
|---|---|---|
| Single call + tools | One decision, few tools | Multi-step work that must survive restarts |
| Simple loop | Iterate until a stop condition you own | Branching, parallelism or approvals needed |
| Fixed chain / DAG | Steps known up front | Branching changes often |
| State graph | Conditional edges, parallel joins, interrupts, durable resume | Simple tasks: you then own checkpointing, determinism and migration |
| MCP | Tools consumed by many hosts, or ecosystem servers | You control both ends and have three tools; hand-rolled schemas are simpler |
| Direct decorators or hand-written schemas | Full control, no extra hop | Many tool sources, so every app writes its own adapters |
Traps interviewers probe
- Replaying a side effect after a crash. Fix: persist intent before the effect, pass an idempotency key, and record the result after. Retries from JSON-RPC transport can duplicate requests, so application-level idempotency is still required.
- Treating an interrupt as a paused stack frame. Fix: it serializes state and returns. Approval loads the checkpoint, checks the approver against that task, writes an audit record, then continues.
- Calling MCP a security boundary. Fix: it is an interoperability boundary. The host owns authorization. Server-reported identity such as
serverInfoandclientInfois display metadata, never a principal. - Trusting server output. Fix: tool results, descriptions and resource contents are untrusted input. Treat them as data, restrict the tool set per task, and require confirmation for consequential actions.
- Exposing a whole API as tools. An 84-operation billing API becomes 84 tools, including
payout.create. Fix: allowlist the operations each task may use.
Interview tips
Open by drawing the state machine: nodes, branches, approval gates. Then say that frameworks manage state, protocols define boundaries, and neither makes the workflow correct, authorized or safe.
Follow-ups to expect:
- Why not a while loop with function calling? For simple tasks, do exactly that. Graphs earn their cost with interrupts, parallel branches and durable resume.
- What is in your checkpoint? Typed state, node and attempt, recorded effect results, deadlines. Not a pickled stack frame.
- What breaks on replay? Anything unrecorded: model calls, clocks, RNG, side effects.
- A community MCP server is installed. What can it do? Whatever its OS sandbox allows. Run it as a low-privilege user or in a container, mount only what it needs, block egress by default, and pass credentials per server.
- How do you test it? A framework-free baseline for outcomes, contract tests for the handshake and version negotiation, and fault injection for duplicate delivery and revoked tokens.
30-second answer outline:
- Name the state machine: nodes, branches, approval gates.
- Say where state lives and what the checkpoint holds.
- Name the replay boundary: effects recorded, with an idempotency key on each external call.
- Say MCP is for interoperability, the host authorizes, and tools are limited per task.
- Name one test: kill the worker after the charge and assert exactly one charge.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.