Tool Call Limit
Limit the number of tool calls an agent can make.
Before running the examples:
pip install agno openai yfinance
export OPENAI_API_KEY="your-api-key"Limiting the number of tool calls an Agent can make is useful to prevent loops and have better control over costs and performance.
Doing this is very simple with Agno. You just need to pass the tool_call_limit parameter when initializing your Agent or Team.
For example:
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.yfinance import YFinanceTools
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[YFinanceTools(enable_company_news=True, cache_results=True)],
tool_call_limit=1, # The Agent will not perform more than one tool call.
)
# The first tool call will be performed. The second one will fail gracefully.
agent.print_response(
"Find me the current price of TSLA, then after that find me the latest news about Tesla.",
stream=True,
)
Important to consider:
- If the Agent tries to run a number of tool calls that exceeds the limit all at once, the limit will remain effective. Only as many tool calls as allowed will be performed.
- The counter spans successive model requests in one response loop. A human-in-the-loop continuation starts a fresh model loop, so this setting is not a cumulative budget across pauses and continuations.
- A Team limit applies to the leader's tool calls. Configure member limits separately. Internal
read_resultandsearch_resultcalls used for offloaded results do not count against the limit.