Skip to content
47% off: the complete course for $79 (reg. $149)Order now →
AI Builder
Module 4Full course11 min read

Multi-Step Tool Flows (and When You Need an Agent)

Chain a few tool calls into a reliable feature, cap the steps, and recognize the point where you've crossed into agent territory.

Real features rarely finish in one tool call. Resolving a Deskmate refund request means finding out what the customer wants, looking up the order, checking the refund policy, deciding, and drafting a reply. Diagnosing why a customer's integration stopped syncing means checking its status, then its error log, then maybe its credentials, depending on what each check reveals. Each of those is a multi-step tool flow: several model calls and tool calls chained into one feature.

The design question is who decides the order of the steps. Your code can decide, the model can decide, or you can split the work between them. That choice determines how predictable, debuggable, and expensive the feature is. In this lesson you'll build both kinds, put real budgets on the model-driven one, and learn to recognize the point where a "flow" has become an agent and needs a different kind of engineering.

Who decides the next step?

There are three ways to chain steps, and they sit on a spectrum from most predictable to most flexible:

PatternWho picks the next stepBest forWatch out for
Code-orchestrated pipelineYour code, in a fixed orderProcesses you can draw as a flowchartRigid when cases vary a lot
Model-driven loopThe model, by calling toolsPaths that depend on what earlier steps revealVariable cost, harder to test
HybridCode fixes the stages; the model loops inside a stageMost real featuresMore moving parts

The default should be the first. If you can write down the steps before the request arrives, put them in code. Your code never forgets a step, never calls the same tool five times, and produces the same sequence every time, which makes it testable with ordinary tests. Reach for model-driven control only for the part of the flow where the path genuinely can't be known in advance.

A useful exercise before building: try to draw the flow as a flowchart. If every box and arrow is clear, it's a pipeline. If one box says "investigate until you know," that box is where the model drives.