Almost every "build an AI agent" tutorial ends the same way: the model calls a tool, the tool returns data, the model uses the data to respond. It works in the demo.

What the tutorial doesn't show: what happens when the tool times out. Or when the model calls the same tool three times in a row. Or when the model calls a destructive tool without the user intending it. Or when a tool returns an error and the model confabulates a response anyway.

These aren't edge cases — they're the normal operating conditions of a production agent. Here are five patterns I use on every agent I ship to handle them.

Pattern 1: Explicit tool call budgets

By default, most agent frameworks will let the model call tools indefinitely until it decides to stop and respond. This is fine in demos. In production, it means a single misbehaving agent can loop through dozens of API calls and rack up costs before anyone notices.