Safeguard
AI Security•

How many tool calls should an AI agent be allowed per task?

There is no universal number, but every agent needs a cap on calls and loop turns. How to set limits, what the MCP spec says and what to do at the cap.

Safeguard Security Team
3 min read

There is no universal number, but every agent needs hard caps on tool calls per task, turns per loop and calls per minute. The MCP spec says servers must rate limit tool calls and that both sides should set iteration limits for tool loops. Set limits from observed normal use, with headroom, and alert when they trip.

Why limits are a security control

A loop with no cap is a path to runaway cost, a flood of requests against a downstream system and a way for an injected instruction to repeat an action many times. OWASP lists rate limiting among measures that limit the damage of excessive agency, though it does not remove the cause.

The MCP tools page says servers must rate limit tool invocations. The sampling page says both parties should implement iteration limits for tool loops, and the example flow notes a server might cap iterations and force a final answer on the last one.

Three kinds of limit

LimitProtects againstHow to set it
Calls per taskRunaway loopsCap at a multiple of the 95th percentile
Calls per minuteFloods and abusePer identity, per tool
Spend or tokens per taskCost spikesBudget with alert and hard stop

Add a separate lower limit for high impact tools such as deletes, payments or deployments.

How to pick numbers

  1. Run the agent on real tasks for a week with no cap but full logging.
  2. Record the number of tool calls per completed task.
  3. Set the soft limit above the normal maximum and the hard limit above that.
  4. Set stricter caps on write and destructive tools.
  5. Review after each model or prompt change, because behaviour shifts.

What happens at the limit

Decide in advance. Options are to stop and ask the user, to stop and report partial work, or to downgrade to read only tools. Do not let the model quietly retry through a different tool, which defeats the cap. Return a clear execution error so the agent can explain.

Enforce outside the model

A prompt that says do not call more than ten tools is a suggestion. Enforce counts in the client, a proxy or the server, and key them to the agent identity so one noisy agent cannot use another's budget.

Safeguard includes policies, gates and guardrails and agent identity, which let you apply per agent rules. A free scan is at https://gold.safeguard.sh/scan.

Quick check

Should limits differ per tool?

Yes. Reads can have a generous cap. Writes, deletes and anything that spends money should have much lower limits and often an approval step.

Is a token budget the same as a call limit?

No. A token budget limits model cost, while call limits protect downstream systems. Use both.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.