How conditional edges encode the routing decision in a LangGraph supervisor
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A routing function reads the state and returns a node name (or END); LangGraph dispatches the edge to the named node. The LLM writes the decision into state; plain Python dispatches it.
Imagine a hotel concierge with a clipboard. A guest walks up, the concierge writes the next thing the guest should do (room, restaurant, gym) on the clipboard, and then a separate doorman reads the clipboard and points the guest the right way. The concierge can be moody and inconsistent (that is the language model), but the doorman is robotic and predictable: he reads exactly what is on the paper and never invents a destination. Splitting the decision (concierge) from the dispatch (doorman) means you can audit and unit-test the doorman even though the concierge is a black box. That split is what LangGraph's conditional edges encode.
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.
5 to 7 min: the routing-function signature + how add_conditional_edges binds it + the supervisor / router split + END sentinel + parallel fan-out via list returns + why determinism enables crash-resume.
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.
Letting the LLM directly determine control flow inside the routing function. The routing function should be pure Python over state; the LLM call belongs in the supervisor node that writes its decision into the state for the router to read.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.