08 · Control flow
Graphs
A while-loop is one shape. Real systems branch, fan out, pause for a human, and resume days later. That is a graph with checkpointed state.
In English
A straight loop is not enough when work branches, waits for a human, or must resume tomorrow. That is a graph: named steps, edges, and saved state so you can pause without losing the plot.
- Try this
- Run the graph. Take the branch that needs a human. See the checkpoint: you can come back.
- Keep this
- Graphs are loops with names, branches, and a save file.
Lab · a support agent as a graph
Straight path. Classify → tool → draft → send.
start · Start
User ticket arrives. State is empty except the message.
Graph engineering is control-flow engineering. Nodes are functions (LLM calls, tools, routers, human gates). Edges are conditions. State is a typed bag that reducers update. Checkpoints make the run durable — interrupt, wait, resume.
Use a loop until it hurts. Switch to a graph when you need branching paths, fan-out, a critic that can send work back, or a person in the middle of the trajectory.