ALLMAcademy

S5

From Loops to Explicit Graphs

13 min2 optional deep dives

Learn when a loop is enough and when branches, joins, and visible dependencies require a graph.

  1. 01Distinguish a loop, workflow, DAG, and cyclic state graph
  2. 02Identify work that can run in parallel and where joins are required
  3. 03Keep the graph topology deterministic unless model-directed routing is justified

A graph makes dependencies visible

mental model
  • A node does one unit of work.
  • An edge says what can run next.
  • A branch chooses among paths.
  • A join waits for required upstream work.
  • A cycle repeats until an explicit exit condition is met.
Parallel branches and a joinInteractive · 2D

Plan runs first. Research and Draft run in parallel. Review waits for both, then Publish runs.

Loading diagram…
Text description

Plan runs first. Research and Draft run in parallel. Review waits for both, then Publish runs.

The same task as a loop

A loop can say:

  1. research,
  2. draft,
  3. review,
  4. publish.

That is easy to write, but it hides that research and drafting could overlap. It also makes failure recovery coarse: if review fails, do you restart everything?

The graph exposes the structure. Research and Draft can run together. Review waits. A failed Draft node can retry without repeating Research.

Common MisconceptionA graph is a picture of code after the system is built.

CorrectionThe graph should be the control model the runtime executes, not a diagram that drifts away from implementation.

Deep dive: DAGs vs. cycles

A directed acyclic graph cannot revisit an earlier node. That is useful for fixed pipelines. Agent systems often need cycles for repair or evaluation, so they use a state machine or cyclic graph with a hard termination condition.

Every cycle still needs a maximum step, time, token, or cost budget.

References & deeper reading (2)

Retrieval Practice

Check one idea at a time

Question 1 of 3

Research and drafting can run independently, but review needs both results. What structure expresses this most clearly?