Once an agent is reliable enough to trust, a different constraint tends to show up: it's slow, or it's expensive, or both - and multi-step agents are particularly exposed to this, because every loop iteration is another full model call, and a task that takes ten steps costs roughly ten times what a single call would.
Where the cost actually comes from
Every planning step re-sends the accumulated context - the original instructions, the conversation, every prior tool call and result - so cost doesn't grow linearly with the number of steps, it grows worse than that, because each new step pays for all the previous ones' context too. An agent that takes twelve steps on a task that could have taken four isn't just three times slower - depending on how much context has accumulated, it can be considerably more than three times the cost.
Each step pays for all the context that came before it - cost compounds as a loop runs longer.
Model routing: not every step needs your strongest model
A common and effective optimization is using different models for different steps based on how much reasoning they actually require - a fast, cheap model for simple classification or straightforward tool selection, and a stronger, more expensive model reserved for the step that actually needs deep reasoning. This is a natural fit for the multi-agent supervisor pattern from earlier in this series: the supervisor and simple sub-agents can run on a cheaper model, with the specialized reasoning-heavy sub-agent using the strongest one available.
Caching repeated work
Agents frequently make the same or very similar tool calls repeatedly within a run, or across runs from different users asking similar questions - caching tool results (especially for calls that are expensive or slow, like a web search or a large database query) avoids paying that cost twice. Beyond tool-level caching, many model providers also offer prompt/context caching, which reduces the cost of re-sending the same unchanging portion of context (like a long system prompt or tool definitions) across multiple calls in the same run.
Trimming context deliberately
Since cost compounds with context size, actively managing what stays in context - summarizing older steps rather than carrying the full raw history forward, dropping tool results that are no longer relevant to the current step - directly controls cost, not just quality. This is the same context-management discipline covered in the memory guide, applied here specifically as a cost lever rather than a correctness one.
Setting a real budget, not just an iteration ceiling
The iteration ceiling from the agent loop guide caps how many steps a run can take, but a step count alone doesn't map cleanly to cost, since steps vary a lot in how much context they carry. Production systems often track and cap actual token spend per run, not just step count, which catches the case where a run stays under the iteration ceiling but still burns far more than the task was worth because each step's context kept growing.