Topic 5
Control flow
The plans so far run one step after another. AI Engineering (Ch. 6, "Complex plans") calls the order in which actions run the control flow, and lists four kinds: sequential, parallel, if, and for loop.
Predict first
Scroll sideways to see the whole diagram
Sequential: the default. Each action waits for the one before.
Text version
- Sequential: the default. Each action waits for the one before.
- Parallel: independent actions at the same time. AI Engineering notes this can cut the latency users see considerably.
- If: the next action depends on a result. In ordinary software the condition is exact; in an agent, a model decides it.
- Loop: repeat until a condition holds. When a model judges the condition, the harness needs its own limit on how many times it can go round.
The difference from ordinary software, the book says, is who evaluates the conditions. In traditional code, a condition is exact: if balance < 0. In an agent, a model decides which branch to take and when a loop is finished. Plans with non-sequential control flows are harder both to generate and to translate into executable commands.
That has a direct consequence for the harness. A loop whose exit condition is judged by a model can, in principle, go round for ever. Every loop needs a limit that code enforces: a maximum number of iterations, time or spend. Lesson 6 comes back to this.
The book also describes planning granularity. A detailed plan, naming exact functions, is harder to generate but easier to execute; a high-level plan in plain language is easier to generate but needs translating into calls. One way through is hierarchical planning: a high-level plan first, then a detailed plan for each part.
Quick check