Run AI / builder guide / 14 progressive labs

Graph Engineering

When one loop grows branches, retries, parallel workers and approvals, stop hiding the workflow inside prompts. Draw the system and engineer every transition.

Run AIGraph EngineeringBuilder guide
Hands-on engineering track
What you'll learn

Model complex agentic work as explicit nodes, edges, state, routes, guards, joins, recovery paths and human authority gates.

Bring / required

A working maker-checker loop or any multi-step AI workflow. Complete Harness Engineering first if your workflow still lacks durable state or verification.

What you'll do

Draw your existing loop, define contracts and shared state, then add routing, parallelism, recovery and authority deliberately.

Take away

A graph definition, state schema, node contracts, routing table, failure policy, run trace and a capstone workflow you can reason about.

Use the shared Field Guide Lab Method. Compare graph complexity against the simpler loop/workflow baseline before deciding the graph earned its cost.

Do not start by drawing boxes

You may be thinking: “My workflow is getting complex, so I should put every step into a graph.” A graph is useful only when it makes responsibility, state, routing and authority clearer. Drawing boxes around an unclear workflow gives you a more impressive picture of the same ambiguity.

Aha

Graph Engineering is not about adding agents. It is about making system decisions explicit. The important questions are: who owns this state, why did this route happen, who may veto it, what evidence allows the next transition, and what happens when two locally correct loops conflict?

Try this before adding a framework

  1. Take one working delegated loop from Give AI Work.
  2. Write every responsibility and every possible next state on paper.
  3. Circle any transition whose reason is “the agent decides.”
  4. Mark every irreversible action and every place where two responsibilities can modify the same real-world state.
  5. Those circles and overlaps are the first places where Graph Engineering earns its keep.

Common traps

  • Agent multiplication: creating planner, researcher, writer and reviewer agents because more agents feels more advanced.
  • Hidden routing: the graph looks explicit, but the most important next-step decision still lives inside an LLM prompt.
  • Retry theatre: failed nodes loop back without changing evidence, state, strategy or retry budget.
  • Fan-out without fan-in: several workers produce answers, then another model is simply told to “combine them.”
  • Rubber-stamp approval: a human gate exists, but the person receives too little evidence to make a meaningful decision.
  • Metric capture: every node succeeds while the real business outcome quietly gets worse.

Look out for

  • You cannot explain why a particular edge was chosen using visible state.
  • Two nodes use the same field but mean different things by it.
  • Parallel workers touch the same files, customer record or external resource.
  • The number of retries increases but the failure evidence does not change.
  • Human approval appears on almost every path and becomes automatic clicking.
  • The graph has good local metrics but nobody owns the global outcome.
  • More orchestration cost is being added without measurable reliability or business-value gain.

Prove the first lesson

Inject one missing-information case and one conflicting-output case. You should be able to explain, from recorded state and explicit rules, why the graph took each route, who had authority at each transition and what evidence allowed or blocked progress.

A graph is an explicit workflow contract

PartMeaning
NodeOne bounded responsibility with known inputs and outputs.
EdgeAn allowed transition from one node to another.
StateThe shared information that survives between nodes.
RouterThe rule that decides which edge is taken next.
GuardA condition that blocks or redirects unsafe or invalid progress.
JoinThe rule for reconciling parallel results.
Human gateA deliberate return of authority to a person.
AnchorExternal ground truth that prevents the graph from redefining success for itself.

Graph Engineering starts when relationships between responsibilities become the thing you need to engineer. You can implement the graph in ordinary code first; the architectural discipline matters more than the orchestration framework.

First: should this even be a graph?

SignalGraph may helpProbably keep it simpler
Flow shapeBranches, backtracks, approvals, conflicting pathsMostly linear sequence
StateIntermediate state must be persisted/recoveredInput → deterministic output
Work unitsSeveral independently useful responsibilitiesOne bounded responsibility
VerificationDifferent nodes can be accepted independentlyOnly final outcome matters
EconomicsCoordination benefit exceeds review/complexity costOrchestration costs more than it saves
Aha

A 20-step line can be a script. A 5-node system with branches, vetoes and recovery may need a graph. Complexity is not step count.

Graph vs. workflow

WorkflowGraph
Mostly predefined pathStateful conditional routing
Known sequence of stepsBranches, loops and backtracking
Routing is mostly deterministicSeveral independently useful responsibilities
Final output is the main acceptance pointNodes can be verified and recovered independently
Ordinary code/workflow engine may be clearerDynamic joins, recovery and authority edges justify explicit graph structure
Aha

Drawing nodes does not make something Graph Engineering. The graph earns its complexity when state, routing, recovery and coordination become first-class problems.

Progressive labs

MAKE EVERY IMPORTANT DECISION EXPLAINABLE.

The labs move from “do we need a graph?” to contracts, coordination, governance, global outcomes and operating cost.

G01DECIDE

Earn the graph

Aha: use a graph for coordination complexity, not because graphs look advanced.

Trap: wrapping a linear workflow in nodes.

Keep: graph/no-graph decision record

G02CONTRACT

Define node contracts

Responsibility, private context, tools, side effects, output and failure state.

Trap: nodes share assumptions nobody wrote down.

Keep: node contract table

G03STATE

Separate shared state from private context

Aha: shared transcript is not shared state.

Trap: two nodes use the same field differently.

Keep: state.schema.json

G04ROUTE

Make routes and guards explicit

Aha: “the agent decides” can hide the most important edge.

Prove: explain each conditional route from visible state.

Keep: routing / guard table

G05FAN OUT

Parallelize only independent work

Trap: workers share writes or depend on each other’s unfinished output.

Prove: isolated responsibilities with explicit outputs.

Keep: fan-out plan

G06FAN IN

Engineer the join

Aha: fan-out is easy; reconciliation is the engineering.

Trap: “combine these answers.”

Keep: join / conflict policy

G07RECOVER

Retry, rollback or compensate deliberately

Trap: every failure becomes retry.

Prove: injected failure reaches a controlled next state.

Keep: failure-routing matrix

G08AUTHORITY

Build meaningful human gates

Aha: approval is useful only when the human has evidence and real choices.

Trap: rubber-stamp approval.

Keep: approval contract

G09ROLES

Specialize only when it pays

Aha: agent count is not maturity.

Trap: role-play agents with overlapping responsibility.

Keep: role registry

G10ANCHOR

Tie the graph to reality

Aha: node success is not system success.

Trap: every metric comes from the graph itself.

Keep: anchor / global-objective map

G11CONFLICT

Test competing objectives — and blindness upward

Make one loop improve its local metric while harming another outcome, then test whether the system can question a goal that is no longer correct.

Look out: proxy capture, nobody owning the global goal, or a loop that optimizes forever without permission to question the target.

Keep: conflict / Goodhart / goal-review cases

G12COST

Measure the orchestration tax

Aha: generation parallelizes faster than judgment.

Look out: review, merge and coordination become the bottleneck.

Keep: orchestration-cost record

G13TRACE

Trace and replay the system

Record state, route reason, authority, side effects, retries and evidence.

Prove: reconstruct a disputed outcome.

Keep: graph run trace

G14CAPSTONE

Operate the graph, not just execute it

Inject missing info, verification failure, conflicting outputs, node failure and a global-objective conflict.

Prove: every route and stop has an owner and reason.

Keep: operating graph pack

Your first explicit graph

START
  ↓
PLAN
  ↓
MAKE
  ↓
VERIFY ── fail ──→ REPAIR ──→ VERIFY
  │
 pass
  ↓
HUMAN GATE ── reject ──→ REPAIR
  │
 approve
  ↓
DONE

The diagram is not the implementation. Its job is to force hidden behavior into named responsibilities and explicit routes before framework code obscures the design.

Write each node like a contract

Node: VERIFY
Input:
  - proposed_change
  - acceptance_criteria
  - repository_state

May:
  - run tests
  - inspect changed files
  - read logs

May not:
  - silently rewrite requirements
  - approve on confidence alone

Output:
  - status: pass | fail | blocked
  - evidence[]
  - reasons[]
  - recommended_next_route

Fan-out is easy. Fan-in is the engineering.

Parallel agents often look impressive because several workers return quickly. The difficult part is deciding how conflicting outputs become one next state.

Join ruleUse whenRisk
All requiredEvery check must pass.One weak worker can block progress.
QuorumIndependent judgments can be aggregated.Majority can still be confidently wrong.
First validAny solution satisfying a hard verifier is acceptable.May prefer speed over quality.
Rank then selectSeveral valid options need comparison.Ranking criteria become critical.
Conflict escalationDisagreement itself is important evidence.Requires a deliberate human/reviewer path.
Design rule

If you cannot explain why the graph took an edge using visible state and an explicit rule, that decision is still hiding inside an agent.

The graph can be correct and the business can still lose

This is where Graph Engineering becomes Run AI. A graph may execute every node successfully and still optimize the wrong thing. Booking agents can maximize appointments while show-up quality falls. Content agents can maximize output while brand trust falls. Support agents can minimize handling time while repeat contacts rise.

Aha

Node success is not system success. Run AI needs anchors outside the graph: actual sales, customer outcomes, error rates, human review, operational incidents or another source of ground truth that the graph cannot redefine for itself.

Look out for when the graph reaches production

  • Blindness upward: every node follows its goal correctly but nobody is allowed to ask whether the goal itself should change.
  • One loop improves its own metric by pushing work or risk into another loop.
  • The proxy metric becomes easier to optimize than the actual outcome.
  • No node has permission to question whether the target itself is still correct.
  • The graph becomes so complicated that human review becomes the slowest and most expensive node.
  • Nobody can reconstruct what happened after a customer, operator or auditor asks “why?”

Continue in Run AI: trust, ownership, recovery, trace, measure and release →