Modern AI Engineering

Lesson 12.3 · 27 min · video lesson

Graph Engineering: Stateful Workflows for Agents

What if, instead of hoping one giant prompt or one endless loop does the right thing, we drew the whole job as a map of small steps and arrows that we can see, test and pause?

In short: Graph engineering builds an AI system as a graph: nodes are small steps (an LLM call, a tool, a check), edges are the paths between them, and a shared state object carries data from step to step. Conditional edges let the graph make decisions, cycles let it redo work, parallel branches save time, and checkpoints let it pause for a human or resume after a crash. It trades some of a free loop's flexibility for control, visibility and reliability.

What you will learn

  • What is Graph Engineering?
  • Graph = Nodes + Edges
  • Why do we need Graph Engineering?
  • The three building blocks: Node, Edge, and State
  • Let's build our first graph
  • Conditional edges: taking decisions inside the graph
  • Cycles: doing the work again when needed
  • One full run, step by step
  • Parallel branches: doing many things at the same time
  • Checkpoints: pause and resume the graph
  • Human in the loop
  • Handling errors inside a graph
  • Graph Engineering vs Loop Engineering
  • Where Graph Engineering works well
  • Where Graph Engineering fails
  • Best practices in Graph Engineering
  • Conclusion

In this lesson

  1. What is graph engineering? Graph = nodes + edges
  2. Why do we need graph engineering?
  3. The three building blocks: node, edge and state
  4. Let's build our first graph
  5. Conditional edges and cycles
  6. One full run, step by step
  7. Parallel branches: doing many things at the same time
  8. Checkpoints, human in the loop and errors
  9. Graph engineering vs loop engineering
  10. Worked example, step by step
  11. Practice: try it yourself
  12. Where it works, where it fails, and best practices

Key terms in this lesson

Node
One step in the graph: a function that reads the state and returns an update.
Edge
An arrow from one node to the next; a conditional edge picks the next node at run time.
State
The shared data record that flows through the graph and is updated by nodes.
Cycle
A path that returns to an earlier node, used to repeat work such as redrafting.
Reducer
A rule for merging state updates, especially from parallel branches (for example, append to a list).
Checkpoint
A saved copy of the state and position after a node, used to pause, resume or debug a run.

This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).

← 12.2 Loop Engineering: Designing Reliable Agentic Loops · 12.4 Defining Done: Why Exit Criteria Shape Agent Quality →