Edges, Graphs, and Super-steps

Nodes describe the work. Edges decide what runs next.

Fixed and conditional edges

Fixed edge

A fixed edge is always followed.

flowchart LR T[tool_node] --> L[llm_call]

After tools return their observations, the model always reads them.

Conditional edge

A conditional edge reads state and chooses a route.

flowchart TB C[check_policy] --> R{route_after_check} R -->|pass| D[draft_itinerary] R -->|fixable failure| L[llm_call
replan] R -->|cannot resolve| H[escalate_to_human]

The routing function does not need to solve the trip. It only needs to turn the latest verdict into a route name.

def route_after_check(state: TripState) -> str:
    if state["verdict"]["compliant"]:
        return "draft"
    if state["attempts"] < 3:
        return "replan"
    return "escalate"

The travel agent as a graph

flowchart TB START([START]) --> P[retrieve_policy] P --> L[llm_call] L --> Q{Tool calls?} Q -->|yes| T[tool_node
search flights and hotels] T --> L Q -->|no| C[check_policy] C --> V{Verdict} V -->|pass| D[draft_itinerary] V -->|fixable| L V -->|cannot resolve| E[escalate] D --> END([END]) E --> END

Read it in order:

  1. Fixed start — every run retrieves policy, then calls the model.
  2. Tool loop — model → tools → model while the model requests tools.
  3. Conditional exit — no more tool calls sends control to the policy check.
  4. Verdict routing — draft, replan, or escalate.
  5. End — a completed draft or honest escalation stops the run.

compile() turns the declared shape into an agent that can run, be drawn, and be inspected.

from langgraph.graph import END, START, StateGraph

builder = StateGraph(TripState)
builder.add_node("retrieve_policy", retrieve_policy)
builder.add_node("llm_call", llm_call)
builder.add_node("check_policy", check_policy)

builder.add_edge(START, "retrieve_policy")
builder.add_edge("retrieve_policy", "llm_call")
builder.add_conditional_edges("check_policy", route_after_check)

graph = builder.compile()

The full graph would also register the tool, draft, and escalation nodes. The short example only shows how nodes and edges fit together.

How a graph runs: super-steps

A super-step is one round of graph execution.

flowchart LR A[1. Run active nodes
parallel if independent] --> M[2. Merge updates
with reducers] --> S[3. Save checkpoint
state after this step] --> F[4. Follow edges
choose next nodes] --> A

Independent active nodes can run at the same time. Their updates are then merged before the graph moves forward.

The Paris run, step by step

Super-step Active work
1 retrieve_policy
2 llm_call
3 tool_node: flights and hotels together
4 llm_call reads both results
5 check_policy returns fail and routes to replan
6 llm_call plans another attempt

Each super-step ends with a saved checkpoint.

The run stops when:

The recursion limit is a safety ceiling, not a target.

What goes wrong

One-line summary

Edges turn small nodes into a visible workflow, while super-steps make parallel work, merging, checkpoints, routing, and stopping explicit.

Key terms