Zenaique

What LangGraph feature allows the agent loop to cycle back to an earlier node rather than terminating?

MCQ·Medium·4.0 · 0·~1 min·Asked atLangChainPwcTuring·Relevant atAdobeAi21AndurilAnthropic
Attempt it
TL;DR

Conditional edges. They read the current state and choose the next node, and that target can be an earlier node, which is exactly how a cycle becomes a loop in the graph.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a board game where each square tells you where to move next. Most squares just say 'go forward one space.' But one special square reads what you are holding and decides: if you still have a quest item, go all the way back to the start square and try again; if your bag is empty, walk to the finish. That special, decision-making square is the conditional edge. Plain squares always send you to the same next square, so a board made only of plain squares marches straight to the end and stops. The decision square is what lets the path bend backward and form a loop. LangGraph works the same way. A normal edge always points to one fixed next node. A conditional edge looks at the shared game state and picks the next node, and it is allowed to pick a node you already visited.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

LangGraph models an agent not as an imperative loop but as a StateGraph: a directed graph where nodes do work, a typed state object flows between them, and edges decide what runs next. The question asks which feature lets the loop bend backward to an earlier node instead of marching to an exit. The answer is the conditional edge, and understanding why requires separating the two distinct edge types from the features that merely store state.

A node is a function. It receives the current state and returns a partial update that LangGraph merges back in. An edge carries no logic about work, only about control: given that a node just finished, which node runs next? That separation of concerns, work in nodes and routing in edges, is what makes the cycle a property of the graph's shape rather than something buried inside a function body.

The distinction matters because every distractor in the question names a feature that touches state or control somewhere, yet only one of them actually selects the next node. The whole skill being tested is whether you can tell routing apart from storage. Keep that frame in mind: a cycle is a control-flow phenomenon, so the feature that creates it must be the one that chooses where control goes.

Static edges versus conditional edges

LangGraph offers two ways to connect nodes. A static edge, added with add_edge("a", "b"), is unconditional. Once node A finishes, control always passes to node B. There is no decision, no inspection of state, just a fixed wire. You use static edges for the parts of a workflow whose order never changes.

A conditional edge, added with add_conditional_edges, is different. You give it a source node and a router function. After the source node runs, the router receives the full current state and returns a string, the name of the next node to run. Because the return value is just a node name chosen at runtime, the router is free to return the name of a node that already executed. The router is plain code: it can read any field of the state, count steps, check a budget, or inspect the last message.

This is the entire basis of the cycle. A graph built only of static edges is a directed acyclic graph: it runs each node at most once and terminates. The moment a conditional edge can return an earlier node's name, the graph gains a back-edge and becomes cyclic. The loop is not hidden in any node's code. It is visible in the graph topology as an edge that points backward.

It helps to think about what each edge type can and cannot express. A static edge encodes a fact known at build time: B always follows A. A conditional edge encodes a decision deferred to run time: the next node depends on what actually happened. Loops are inherently run-time decisions, because whether you go around again depends on the result of the last lap. That is why no static edge, however cleverly arranged, can produce a true data-dependent loop, and why the conditional edge is the unique source of cycles.

Wiring the canonical agent loop
Why the three distractors are wrong
Senior concerns: limits, reducers, and the prebuilt shortcut
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • LangGraph's prebuilt create_react_agent wires a model node to a conditional edge whose router checks for a tool call, routing to the tool node and back, or to the end.
  • LangSmith renders the StateGraph visually, so you can see the conditional edge that loops the reasoner back to itself and trace exactly which branch each run took.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does the conditional edge cooperate with a checkpointer to support human in the loop approval mid-loop?
A

The checkpointer snapshots state at each super-step, so you set an interrupt before the tool node, let a human inspect or edit state, then resume. The conditional edge re-evaluates the edited state on resume and routes accordingly.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Picking checkpointing. Checkpoints persist and resume state, but they do not route control flow. Only conditional edges read state and choose which node runs next, including an earlier one.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • State that conditional edges, not static edges, choose the next node from state.

  • Explain why a graph of only static edges cannot form a cycle.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the Model Context Protocol (MCP) and what problem does it solve?
MCQ·Easy