tools.py

This file needs to contain anything related to creating the tools for your agent. That includes each tool’s definition, and the TOOLS dictionary.

from langchain.tools import tool

@tool
def cancel_order(order_id: str) -> str:
    """Cancel an order that has not shipped."""
    return f"Cancel order {order_id}."

TOOLS = {
    "cancel_order": cancel_order
}

Any tools you define for the model should also be added to the TOOLS lookup dictionary. This way, we don’t have to pass each tool’s definition into the agent’s context window each time we need to use it.