Including and excluding tools
Include and exclude specific tools from a Toolkit.
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 get_latest_emails tool in the GmailTools toolkit:
1agent = Agent(2 tools=[GmailTools(include_tools=["get_latest_emails"])],3)Similarly, here's how to exclude the create_draft_email tool from the GmailTools toolkit:
1agent = Agent(2 tools=[GmailTools(exclude_tools=["create_draft_email"])],3)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:
1from kern.agent import Agent2from kern.models.openai import OpenAIResponses3from kern.tools.calculator import CalculatorTools4from kern.tools.yfinance import YFinanceTools56agent = Agent(7 model=OpenAIResponses(id="gpt-5.2"),8 tools=[9 CalculatorTools(10 exclude_tools=["exponentiate", "factorial", "is_prime", "square_root"],11 ),12 YFinanceTools(include_tools=["get_stock_price"]),13 ],14 markdown=True,15)1617agent.print_response(18 "Get the stock price of AAPL and NVDA, then calculate the sum of both prices.",19)