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 runMaximum of 2, with Block on
The 1st and 2nd callThe tool runs.
The 3rd callThat call is denied. The earlier calls already happened.

Set It Up

  1. In the app, open Policies and click Create Policy.
  2. Choose Loop Cap.
  3. Set Max Tool Calls Per Run.
  4. 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.