How does LangGraph's StateGraph enable agent loops that a standard DAG pipeline cannot express?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain the structural difference between a LangGraph StateGraph and a standard DAG-based LLM pipeline. What specific graph feature enables the agent's 'retry until done' pattern?
A DAG forbids cycles, so it cannot loop back; StateGraph allows directed cycles, and a conditional edge routes on state to repeat the reason step or terminate.
Think of a board game with a track of squares. A normal pipeline is a track where you only move forward, one square at a time, until you reach the end. You can never go back. That is fine for a recipe you follow once, but an agent does not know in advance how many tries it needs. LangGraph lets you draw an arrow from a later square back to an earlier one, so the player can loop around again. At the end of each loop there is a decision square. Look at the current situation, and if the job is done, walk off the board, otherwise take the arrow back and try again. The decision is written on the board itself, not hidden in someone's head, so anyone watching can see the whole game and where the player keeps getting stuck.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Start from the acyclic definition and why topological order cannot loop, then introduce StateGraph cycles, the conditional edge as the state-driven router, typed state with reducers, and checkpointing for resume and human in the loop. Close on when the explicit graph beats an implicit ReAct loop and the rigidity cost you pay.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Saying StateGraph is just a nicer wrapper around a while loop. The real difference is that the loop becomes a typed graph object you can inspect, checkpoint, resume, and interrupt.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.