你可以使用 include_toolsexclude_tools 参数来指定要包含或排除的工具。这对于限制 Agent 可用工具的数量非常有用。

例如,以下是如何仅在 GmailTools 工具集中包含 get_latest_emails 工具:

agent = Agent(
    tools=[GmailTools(include_tools=["get_latest_emails"])],
)

类似地,从 GmailTools 工具集中排除 create_draft_email 工具的方法如下:

agent = Agent(
    tools=[GmailTools(exclude_tools=["create_draft_email"])],
)

示例

以下是如何使用 include_toolsexclude_tools 参数来限制 Agent 可用工具数量的示例:

include_exclude_tools.py

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.calculator import CalculatorTools
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[
        CalculatorTools(
            enable_all=True,
            exclude_tools=["exponentiate", "factorial", "is_prime", "square_root"],
        ),
        DuckDuckGoTools(include_tools=["duckduckgo_search"]),
    ],
    show_tool_calls=True,
    markdown=True,
)

agent.print_response(
    "Search the web for a difficult sum that can be done with normal arithmetic and solve it.",
)