Include Exclude Tools Custom Toolkit

Restrict a custom customer database Toolkit to read-only functions with include_tools.

include_exclude_tools_custom_toolkit.py
"""
Include Exclude Tools Custom Toolkit
=============================

Demonstrates include exclude tools custom toolkit.
"""

import asyncio
import json

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools import Toolkit
from agno.utils.log import logger

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


class CustomerDBTools(Toolkit):
    def __init__(self, *args, **kwargs):
        super().__init__(
            name="customer_db",
            tools=[self.retrieve_customer_profile, self.delete_customer_profile],
            *args,
            **kwargs,
        )

    async def retrieve_customer_profile(self, customer_id: str):
        """
        Retrieves a customer profile from the database.

        Args:
            customer_id: The ID of the customer to retrieve.

        Returns:
            A string containing the customer profile.
        """
        logger.info(f"Looking up customer profile for {customer_id}")
        return json.dumps(
            {
                "customer_id": customer_id,
                "name": "John Doe",
                "email": "john.doe@example.com",
            }
        )

    def delete_customer_profile(self, customer_id: str):
        """
        Deletes a customer profile from the database.

        Args:
            customer_id: The ID of the customer to delete.
        """
        logger.info(f"Deleting customer profile for {customer_id}")
        return f"Customer profile for {customer_id}"


agent = Agent(
    model=OpenAIChat(id="gpt-5.2"),
    tools=[CustomerDBTools(include_tools=["retrieve_customer_profile"])],
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    asyncio.run(
        agent.aprint_response(
            "Retrieve the customer profile for customer ID 123 and delete it.",  # The agent shouldn't be able to delete the profile
            markdown=True,
        )
    )

The retrieval method returns a fixed demonstration profile and does not query a database. Its async function is available to aprint_response; the excluded delete method is not exposed to the model.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the code above as include_exclude_tools_custom_toolkit.py, then run:

python include_exclude_tools_custom_toolkit.py

Full source: cookbook/91_tools/other/include_exclude_tools_custom_toolkit.py