Loop Cap
Stop an AI agent that keeps calling tools in a loop. Loop Cap denies the next tool call once a run reaches the maximum you set.
Real-Time(Preventive)Checked before the call runs, so it can stop it
An agent that can call tools will sometimes keep calling them. Loop Cap sets the most tool calls allowed in one run. The next call after that is denied.
Runs On
The SDK only
You Set
The maximum number of tool calls in one run.
Your Agent Sends
Nothing extra
What Happens
| Tool calls in this run | Maximum of 2, with Block on |
|---|---|
| The 1st and 2nd call | The tool runs. |
| The 3rd call | That call is denied. The earlier calls already happened. |
Set It Up
- In the app, open Policies and click Create Policy.
- Choose Loop Cap.
- Set Max Tool Calls Per Run.
- Set the mode to Block, then click Activate Policy.
Wrap your agent with govern(). Tool-typed observe wrappers inside it are counted.
Good To Know
- Loop Cap does not apply on the Gateway. A Gateway completion is one model call, not a loop of tools.
- The After Run Tool Call Count policy records a violation after a run. Loop Cap is the one that stops the run.
Next Steps
© 2026 Traccia.