LangGraph Conditional Edges

A router function reads state and returns a key; a path map turns the key into the next node

LangGraph Conditional Edges A router function reads state and returns a key; a path map turns the key into the next node 01 / key = retrieve 02 / Graph 03 / key = clarify Source Node · updates state · Graph Source Node updates state Router Fn · state -> key · Graph · conditional Router Fn state -> key conditional Answer · generate reply · Graph Answer generate reply Retrieve · fetch context · key = retrieve Retrieve fetch context Clarify · ask user · key = clarify Clarify ask user answer retrieve clarify Legend User UI Agent logic Policy Tool action Context / trace

The router

  • • A plain function, not an LLM step
  • • It reads the current graph state
  • • It returns a routing key as a string

The path map

  • • A dict maps each key to a target node
  • • Exactly one branch is taken per invocation
  • • Unmatched keys can route to END or raise

After the branch

  • • The selected node becomes the next step
  • • More keys simply add more mapped nodes
  • • Paths later converge at a superstep boundary