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
- 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 and cycles
- One full run, step by step
- Parallel branches: doing many things at the same time
- Checkpoints, human in the loop and errors
- Graph engineering vs loop engineering
- Worked example, step by step
- Practice: try it yourself
- 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 →