← Table of Contents · Page 117 of 868

CONTROL STRUCTURES AND DECISION ROUTING

Part 1 of 9

LEARNING GOALS By the end of this chapter you will be able to explain conditional branching, graph models of agent logic, guarded repetition, and the tradeoff between deterministic and model-driven control. CONDITIONAL BRANCHING A conditional is an instruction of the form "if this is true, do that; otherwise, do something else." Every programmer uses conditionals constantly, and they are just as useful inside an agent loop. Branching means the path of the program splits depending on a condition, like a fork in a hiking trail. Inside an agent, branching decisions arise everywhere: if the tool call failed, retry; if the user's request is about billing, send it to the billing helper; if the document is longer than ten pages, summarize it in sections first. Conditions can be checked in two ways. A plain program rule checks something exactly, such as "the score is below negative 0.5." Or the model can be asked to judge something fuzzy, such as "does this resume match this job posting?" The first is predictable. The second is flexible but can vary from run to run. Keep this difference in mind, because the last section of this chapter turns it into a design principle.
Advertisement
Read Aloud:
0:00 / 0:00