Interview questions with answers
LangGraph interview questions and answers
Stateful graphs, checkpointers, interrupts and multi-agent systems. Open any question to read its model answer; the multiple-choice set marks the right option and explains it.
- Subjective
- 30
- Objective
- 30
Subjective questions 30
1What is LangGraph and when would you use it?Asked almost every time
LangGraph is a low-level framework for building stateful, long-running agents and workflows as graphs: nodes are steps, edges decide what runs next, and a shared state flows through. Use it when you need loops, branches, human approval, durable execution that survives restarts, or multiple agents, with explicit control instead of a black-box agent.
2Explain state, nodes and edges in a StateGraph.Asked almost every time
State is a typed object (TypedDict or Pydantic) shared by the graph. Nodes are functions that read the state and return updates. Edges connect nodes: normal edges always go to the next node, conditional edges call a function on the state to pick the next node. The graph is compiled, then invoked with an input state.
3How does human-in-the-loop work?Asked almost every time
A node calls interrupt(payload). With a checkpointer configured, the graph saves its state and returns the interrupt to the caller. To continue, invoke the graph again with the same thread_id and Command(resume=value); the node re-runs and interrupt returns the value, such as an approval or an edited argument.
4What is a checkpointer and why does it matter?Asked almost every time
A checkpointer saves the graph state after every step, keyed by thread_id. It enables conversation memory, pausing for humans, recovering from failures, and time travel to replay or fork from an earlier checkpoint. Use an in-memory saver in development and a database-backed one (Postgres, SQLite, Redis) in production.
5How would you design a customer-support agent with LangGraph?Asked almost every time
Model it as a graph: classify the request, route to specialist nodes (billing, orders, technical) that call tools, add an interrupt before risky actions such as refunds, and loop back for follow-ups. Use a checkpointer keyed by conversation thread_id, cap iterations, and trace everything in LangSmith.
6Why use LangGraph instead of a simple agent loop?Asked almost every time
A plain loop hides control flow inside the model. LangGraph makes steps explicit, so you can add deterministic branches, parallel work, retries, human approval and persistence, resume after failures, and test nodes individually. That control matters once an agent does real work in production.
7How does persistence enable fault tolerance?Asked almost every time
After every super-step the checkpointer saves state. If a node fails or the process crashes, you can resume the same thread from the last checkpoint instead of restarting, and successful writes from nodes in the same step are kept so they do not rerun.
8What are reducers in LangGraph state?Very often asked
A reducer defines how a node's update is merged into a state key. By default an update replaces the value; with a reducer such as operator.add or add_messages, updates are appended or merged. add_messages appends new messages and updates existing ones by ID, which is what chat state needs. Reducers also make parallel branches safe to merge.
9How do you run steps in parallel?Very often asked
Add edges from one node to several nodes; they run in the same super-step, and their updates are merged with reducers. For a variable number of tasks, a conditional edge can return a list of Send objects, one per item (map-reduce), and a later node gathers the results.
10Compare the supervisor and swarm multi-agent patterns.Very often asked
Supervisor: a central agent receives the task, hands work to specialist agents and decides when the job is done; predictable and easy to trace. Swarm: agents hand off directly to each other based on what is needed next; fewer hops and more flexible, but harder to control. Both are built from nodes, shared state and handoff tools or Command.
11What does Command do?Very often asked
A node can return Command(update=..., goto=...) to update the state and choose the next node in one step, which is how dynamic routing and agent handoffs are written. Command(resume=...) is also how a paused graph continues after an interrupt.
12How do you define graph state in Python?Very often asked
Usually a TypedDict (or Pydantic model or dataclass) listing each key, with Annotated[list, add_messages] or another reducer where updates should merge rather than overwrite. MessagesState is a ready-made state with a messages key.
13What is the Store and how is it different from a checkpointer?Very often asked
A checkpointer saves one thread's state history (short-term memory). The Store is a key-value store shared across threads, organised by namespaces such as (user_id, 'memories'), for long-term memory like user preferences, and can support semantic search.
14How do you add a tool-calling agent node?Very often asked
Bind tools to the model in one node, then add a ToolNode that runs the requested tools and a conditional edge (tools_condition) that goes to the tool node when the last message has tool calls and to END otherwise, with an edge back from tools to the model.
15How do you handle errors inside nodes?Very often asked
Catch expected errors and write them into state so a later node or the model can react; use node-level retry policies for transient failures; route to a fallback node on repeated failure; and rely on checkpoints so a crashed run can resume.
16What is a super-step?Very often asked
One round of execution in which all nodes scheduled for that step run (possibly in parallel), and their updates are applied to the state together through the reducers. A checkpoint is saved after each super-step.
17How do you edit state during a human review?Very often asked
While the graph is paused, call graph.update_state(config, values) (optionally as a specific node) to correct the state, then resume. The change is recorded as a new checkpoint, so the history shows what the person changed.
18What are subgraphs and why use them?Often asked
A compiled graph can be used as a node in another graph. Subgraphs keep a team's logic or an agent's private state encapsulated, can be reused, and can be tested on their own. They share keys with the parent state or map between different schemas.
19How do you stream progress from a graph?Often asked
Use graph.stream(...) with a stream_mode: values for the full state after each step, updates for each node's changes, messages for model tokens, and custom for your own events. This lets a UI show progress and partial answers while a long run continues.
20What is time travel?Often asked
Because each step is checkpointed, you can list a thread's history, inspect the state at any step, and resume from an earlier checkpoint, optionally after editing the state. It is useful for debugging and for letting users try a different branch.
21How do you avoid infinite loops in a graph?Often asked
Set a recursion limit in the run config, count iterations in state and route to END after a maximum, and make conditional edges check for a done condition. Trace runs to see where loops happen.
22How do you test LangGraph applications?Often asked
Unit-test node functions with plain state dictionaries, test routing functions separately, run the compiled graph with a fake or recorded model for deterministic integration tests, and use LangSmith datasets for end-to-end quality evaluation.
23What is the functional API?Often asked
An alternative to building graphs explicitly: @entrypoint marks a workflow function and @task marks units of work. You write normal Python control flow while still getting persistence, interrupts and streaming.
24How do you limit cost in a multi-agent graph?Often asked
Cap the recursion limit, keep agent prompts and shared state small, pass summaries instead of whole histories between agents, route simple requests to cheaper models, and stop early when a quality check passes.
25How do you stream tokens from the model inside a node?Often asked
Use stream_mode='messages', which yields LLM tokens with metadata about the node that produced them, so the UI can show text as it is generated even inside a larger graph.
26What are the stream modes and when do you use each?Often asked
values streams the full state after each step, updates only the changes, messages model tokens, custom your own events emitted inside nodes, and debug detailed execution events. Several modes can be combined.
27What is the difference between short-term and long-term memory in LangGraph?Sometimes asked
Short-term memory is the thread's state (such as its messages), saved by the checkpointer for that conversation. Long-term memory is a Store shared across threads, with namespaces, for facts like user preferences that should persist between conversations.
28How is a LangGraph app deployed?Sometimes asked
It can run inside your own service (it is a library), or on LangGraph Platform / LangSmith Deployment, which adds a server with persistence, task queues, streaming, cron jobs and the LangGraph Studio debugger. The graph is declared in a langgraph.json config.
29How do you visualise a graph?Sometimes asked
Compiled graphs can draw themselves as Mermaid (get_graph().draw_mermaid()) or a PNG, and LangGraph Studio shows the graph, state and runs interactively for debugging.
30What does a node's configuration (RunnableConfig) carry?Sometimes asked
Run-specific settings such as thread_id, user id, model choice or other values under configurable, plus callbacks and tags. Nodes can read it to behave differently per run without putting those values in state.
Objective questions 30
1Which class defines a graph whose nodes share a typed state?Asked almost every time
Why: StateGraph(State) is the main builder in LangGraph.
2What identifies a conversation's saved state?Asked almost every time
Why: The checkpointer stores state per thread_id.
3Which function pauses a graph for human input?Asked almost every time
Why: interrupt() saves state and returns control to the caller until resumed.
4Which prebuilt node runs the tools a model requested?Asked almost every time
Why: Pair it with tools_condition.
5When is a checkpoint saved?Asked almost every time
Why: That is what enables resume and time travel.
6What stores long-term memory across threads?Asked almost every time
Why: It is namespaced key-value storage.
7Which reducer appends chat messages to the state?Very often asked
Why: add_messages appends new messages and updates ones with the same ID.
8How do you resume after an interrupt?Very often asked
Why: Command(resume=...) passes the answer back into the paused node.
9What decides the next node at runtime based on state?Very often asked
Why: A conditional edge's routing function returns the next node name.
10Which object fans out one task per item for map-reduce?Very often asked
Why: Returning a list of Send(node, payload) runs the node once per payload in parallel.
11Which ready-made state has a messages key?Very often asked
Why: It uses the add_messages reducer.
12Which function routes to tools or END based on the last message?Very often asked
Why: It checks for tool calls.
13Which call changes a paused thread's state?Very often asked
Why: It records a new checkpoint.
14In LangGraph execution, a super-step is…Very often asked
Why: Parallel nodes share a super-step.
15What happens when two parallel nodes update a key without a reducer?Very often asked
Why: Use a reducer to merge them.
16Which special nodes mark the start and end of a graph?Often asked
Why: START and END are imported constants used in edges.
17Which saver is suitable only for development?Often asked
Why: In-memory state is lost when the process restarts.
18What happens to code before interrupt() in a node when it resumes?Often asked
Why: The node restarts from the top on resume, so side effects should come after the interrupt or be idempotent.
19Which stream mode yields only each node's changes?Often asked
Why: updates streams the update each node returned.
20Which decorators define a workflow in the functional API?Often asked
Why: Normal Python with persistence.
21Which stream mode emits your own events from inside nodes?Often asked
Why: Use a stream writer.
22Where do per-run settings like user id belong?Often asked
Why: Nodes read them from config.
23Which stream mode yields the full state after each step?Often asked
Why: updates yields only changes.
24What exception signals the recursion limit was hit?Often asked
Why: Raise the limit or fix the loop.
25What stops a runaway loop automatically?Sometimes asked
Why: Exceeding the recursion limit raises an error and ends the run.
26What does a node function return?Sometimes asked
Why: Nodes return updates for some state keys, merged by reducers.
27Which tool visualises and debugs graphs interactively?Sometimes asked
Why: Studio shows the graph, each step's state and lets you rerun from a checkpoint.
28How can a compiled graph be drawn?Sometimes asked
Why: get_graph().draw_mermaid().
29Which database is a common production checkpointer?Sometimes asked
Why: PostgresSaver persists checkpoints durably.
30A node can be retried automatically on failure with…Sometimes asked
Why: Retry policies handle transient errors.
Track what you have practised and search every bank in your dashboard.
Start learning