Including and excluding tools
Include and exclude specific tools from a Toolkit.
Before running the examples:
pip install agno openai yfinance
export OPENAI_API_KEY="your-api-key"You can specify which tools to include or exclude from a Toolkit by using the include_tools and exclude_tools parameters. This can be very useful to limit the number of tools that are available to an Agent.
For example, here's how to include only the add tool in the CalculatorTools toolkit:
from agno.agent import Agent
from agno.tools.calculator import CalculatorTools
agent = Agent(
tools=[CalculatorTools(include_tools=["add"])],
)Similarly, here's how to exclude the divide tool from the CalculatorTools toolkit:
agent = Agent(
tools=[CalculatorTools(exclude_tools=["divide"])],
)The second fragment reuses the imports above. Exclusions take precedence when a name is present in both lists; unknown tool names raise ValueError.
Example
Here's an example of how to use the include_tools and exclude_tools parameters to limit the number of tools that are available to an Agent:
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.calculator import CalculatorTools
from agno.tools.yfinance import YFinanceTools
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[
CalculatorTools(
exclude_tools=["exponentiate", "factorial", "is_prime", "square_root"],
),
YFinanceTools(include_tools=["get_current_stock_price"]),
],
markdown=True,
)
agent.print_response(
"Get the stock price of AAPL and NVDA, then calculate the sum of both prices.",
)