Matching control flow to the task

Lesson 5 of 5 in State Machines vs LLM Loops: Who Owns Control Flow?.

Time to make the spectrum operational. The deciding questions are always the same three: can you enumerate the steps in advance?what does a wrong action cost?who has to be able to inspect the run afterwards? High enumerability pushes toward code; high wrong-action cost pushes decisions behind coded gates; audit obligations push state into the open. Here are five recurring task shapes and where they land.

Five task shapes → who should own control flow
Task shapeControl-flow styleWhyWatch out for

Regulated claim / KYC processing

Fully-coded state machine, model filling slots inside states

Steps are legally fixed; replay and audit trails are non-negotiable; every transition may need a named approver

Rigidity meets creative reality — build an explicit exception state or watch edge cases get misfiled

Customer support triage & resolution

Hybrid — coded skeleton, model judgment in the nodes

Escalation paths and refund limits must be guaranteed; diagnosing what the customer means takes reading

Model verdicts must cross a schema; low confidence routes to a human, never to a guess

Open-ended research & synthesis

Free-running LLM loop

The useful next step depends on what the last source revealed — the step space cannot be enumerated up front

Cost and latency runaway: budget caps, step limits, and a kill switch come from the runtime, not the prompt

Nightly document-extraction pipeline

State machine / plain workflow — possibly no agent at all

Same steps every night on predictable inputs; a model may do the extraction inside one step, but nothing needs to decide anything

Autonomy nobody asked for — adding a loop here buys failure modes, not capability (see the when-not-to-build-an-agent crosswalk)

Coding & debugging tasks

LLM loop with a verification harness

Compilers and test suites give the loop cheap, honest grounding every iteration — the rare setting where free-running autonomy is well-policed by the environment

The environment checks correctness, not safety: sandboxing and explicit stopping conditions still come from you

Interactive sorting exercise: Sort each task into the control-flow style you would reach for first.

Tool: Architecture Advisor — Take the spectrum for a spin: describe a task and defend a control-flow choice against the advisor’s follow-up constraints.