Unit 01.00: The point where a chain stops being enough
Most LLM applications start as a chain: do this, then that, then the other thing. Chains are easy to read, easy to test and easy to reason about, and you should keep using one for as long as it works.
Four requirements, and where the list breaks
A chain is a list of steps. Every step runs, in order, exactly once. That is not a limitation to work around - it is what makes a chain predictable.
The code implements one, then lists four requirements and asks which the list can express.
# A chain is a list. Every step runs, in order, exactly once.
def chain(text):
steps = [str.strip, str.lower, lambda s: s.replace(" ", " ")]
for step in steps:
text = step(text)
return text
print(chain(" Draft The Report "))
# Now add one requirement: if the draft fails review, revise and check again.
# There is no way to express that as a list -- the list has no notion of
# "go back to step 2" or "run step 3 only if step 2 said so".
print("\nA chain cannot express: retry, branch, or stop early.")
for requirement, expressible in [
("run these three steps in order", True),
("skip step 3 when step 2 finds nothing", False),
("go back to step 2 and try again", False),
("pause here until a person approves", False),
]:
print(f" {requirement:44} {'chain' if expressible else 'needs a graph'}")
Only the first is expressible. "Skip step 3 when step 2 finds nothing" needs a decision made at run time. "Go back to step 2" needs a cycle. "Pause until a person approves" needs the run to survive being put down.
Those three are the entire reason graph orchestration exists. Not because graphs are more powerful in the abstract, but because a list has no way to say *sometimes*, *again*, or *later*.
The mistake this prevents
The mistake is reaching for a graph because a workflow involves a language model. Model calls are just function calls; they do not require any particular control flow. What requires a graph is a control flow decision that depends on something computed during the run.
Takeaway
A chain runs every step, in order, once. When you need branching, cycles or pausing, that shape stops fitting - and until you do, a chain is the cheaper thing to debug.
