tool_call_limit 参数即可。
示例
注意事项
- 如果 Agent 尝试 一次性 运行超过限制次数的工具调用,限制仍然有效。只会执行允许次数的工具调用。
- 该限制是在 整个运行过程中 有效的,而不是针对 Agent 触发的单个请求。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
了解如何限制代理可进行的工具调用次数。
tool_call_limit 参数即可。
from agno.agent import Agent
from agno.models.openai.chat import OpenAIChat
from agno.tools.yfinance import YFinanceTools
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
tools=[YFinanceTools(company_news=True, cache_results=True)],
tool_call_limit=1, # Agent 不会执行超过一次的工具调用。
)
# 将执行第一次工具调用。第二次调用将优雅地失败。
agent.print_response(
"Find me the current price of TSLA, then after that find me the latest news about Tesla.",
stream=True,
)