Conditional edges
An edge that looks at the state and picks the next node, so the model's output can choose the path.
Last updated
Analogy
A switch statement in your router, where the case value came from the LLM.
In an agent
This is how a router node sends a request to the docs agent or the tickets agent.
Practice
Flashcards
- Interview: what does LangGraph add to LangChain?Explicit graphs with state, checkpoints, interrupts and routing, so complex agents are easier to control.
Questions people ask
What is a conditional edge in LangGraph?
A conditional edge runs a function on the current state and returns the name of the next node. That lets the model's output pick the path, for example sending a request to the docs agent or the tickets agent, or deciding whether to call tools again or finish.
How do I build a router with conditional edges?
Make a router node that classifies the request, ideally with structured output, and writes the label into the state. Add a conditional edge after it whose function reads that label and returns the matching specialist node's name. Each specialist node then handles only its own kind of request.