← Back to concept explainers

Concept Fable

State diagram

State Graph · Agent orchestration pattern

Read the story first. There is no rush to give a definition here; let the question grow on its own first.

Fable

Every square in Chessboard Town must update the same ledger

The post station in Chessboard Town was like a grid of squares. Letters came in through the south gate and might go to the accounting office, the warehouse, the county school, or the dock. In the past there were few letters, and the couriers relayed them by experience; if they went the wrong way, they could quickly find their way back.

Later, the letters became more complex. Some letters had to verify identity before entering the accounting office, some had to get a warehouse receipt before going to the dock, and some needed annotations from the county school before returning to their origin. Each letter carried different materials, and routes could be changed by intermediate results.

The postmaster first drew a single main route: south gate, accounting office, warehouse, dock. But many letters should never have followed this route. Letters needing county school annotations were sent to the dock, and the dock returned them; letters lacking identification entered the accounting office, and the accounting office did not dare act.

So the postmaster wrote different routes for each type of letter. Soon the wall was covered in notes, and the notes contradicted each other: should a letter returned by the warehouse go back to the accounting office or to the south gate? After the county school added its annotations, did the identity still need re-verification?

A road builder proposed starting not from a single route, but drawing every place as a node and the materials carried by letters as the same ledger. Each node could only read the ledger's contents, add its own results, and decide the next edge based on the ledger's new state.

The south gate node handled identity, the accounts node handled amounts, the warehouse node handled inventory, the county school node handled annotations, and the dock node handled shipping. The conditions were written on the edges: only after identity passed did one enter accounts; if inventory was insufficient, it returned to procurement; if annotations were missing, it went to the county school; only when everything was complete did it reach the dock.

After the new graph was running, the courier no longer memorized the entire complex route. He only looked at the current node, the same ledger, and the next edge that met the conditions. When a letter was returned, the reason for return was also written into the ledger, so next time it would not be treated as a new letter and wander from the start. The station also set up checkpoint saves at key nodes. Save once before reaching the warehouse, save once before dispatch. If something went wrong on the road, it could recover from the most recent state instead of replaying all the steps. The road builder also stipulated that nodes could not hide notes privately. All newly added material had to be written back to the same ledger, otherwise the next station could not see the previous station's judgment. Shared state gave route changes a basis and allowed reviews to retrace the path taken at the time.

The town of Qipan later discovered that the most important thing about this diagram was not its beauty, but that every step revolved around updating a shared state. Complex work was no longer a crowd of people passing messages to one another, but an execution graph that could decide the next step based on state.

Reveal

This story is about: state graphs

A state graph models an Agent workflow as a set of nodes and edges: nodes read and update shared state, and edges determine the next execution step based on that state. It is suited to expressing Agent processes that branch, loop, wait, retry and recover. When enterprise systems use state graphs, the key is to define the shared state structure, node responsibilities, edge conditions, checkpoints and recovery strategies, avoiding turning complex processes into hard-to-maintain prompt chains or one-off scripts.

What matters is that it is not just a term, but a structural problem that repeatedly appears in real AI / Agent systems. Understanding it lets you judge when to add a model, when to change a process, and when to add governance.

Metaphor mapping

  • Qipan Town Relay Station: a multi-step, multi-branch Agent execution environment
  • Materials carried in the letter: task status, context, tool results, and intermediate artifacts
  • One master route: linear chain processes struggle with dynamic branches
  • The wall is covered with sticky notes: branching logic scattered everywhere makes maintenance difficult
  • Node: an execution step or Agent/tool unit that reads and updates state
  • Edge: a routing condition that selects the next step based on state
  • One shared ledger: shared state in a State Graph
  • Save point: checkpoint, allowing tasks to recover and resume from breakpoints

Andy Ren Xu's judgment

The practical value of this concept is that it helps you break "AI features that look smart" into deliverable, verifiable, and governable units of work.

LangGraphstate machineDAGcheckpointorchestration
京ICP备2026014272号