Planning & Control Flow

Deterministic Control Flow, Not Prompt

Branching decisions live in deterministic application code while the LLM is invoked at strategic points to produce structured signals that the code branches on.

Problem

LLM-driven control flow is unreliable: the model may take the wrong branch, skip a branch, invent a branch. Tests cannot enumerate the paths. Debugging requires reading prompt traces. Distinct from spec-driven-loop (which specifies what the agent does at each step) by being specifically about keeping if/else logic out of prompts.

Solution

Structure: deterministic application code drives the control flow. At each branching point, call the LLM to produce a structured signal (typed enum, numeric score). Deterministic code reads the signal and branches. The LLM never sees 'choose the team's next branch' as a prompt; it sees 'classify this' or 'score this'. Pair with structured-output, json-only-action-schema, spec-driven-loop, stateless-reducer-agent.

When to use

  • Agent has well-defined branching points.
  • LLM judgment is needed at the branch but the branching itself is deterministic.
  • Testability and debuggability are priorities.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related