Defining Tools¶
Tools let your agent interact with the world. Define what the tool does—Pauhu handles the rest.
Creating a Tool¶
from pauhu import function_tool
@function_tool
def get_weather(city: str) -> dict:
"""Get current weather for a city."""
return weather_api.get(city)
That's it. The agent can now check weather.
Tool Types¶
Data Tools - Get Information¶
@function_tool
def search_orders(customer_id: str) -> list[dict]:
"""Find orders for a customer."""
return db.orders.find(customer_id)
@function_tool
def read_document(path: str) -> str:
"""Read a document's contents."""
return storage.read(path)
Action Tools - Do Something¶
@function_tool
def send_email(to: str, subject: str, body: str) -> bool:
"""Send an email."""
return email.send(to, subject, body)
@function_tool
def update_record(id: str, data: dict) -> bool:
"""Update a database record."""
return db.update(id, data)
Web Tools - Built-In¶
from pauhu import WebSearchTool
agent = Agent(
tools=[WebSearchTool()], # Ready to use
)
Using Tools in Agents¶
agent = Agent(
name="Research Assistant",
instructions="Search and summarize information for the user.",
tools=[search_web, read_document, summarize],
)
result = await Runner.run(agent, "Find the latest EU AI Act updates")
Tool Guidelines¶
Write clear docstrings—the agent reads them to understand what the tool does.
# Good
@function_tool
def search_orders(customer_id: str, status: str = None) -> list[dict]:
"""
Search for customer orders.
Args:
customer_id: The customer's unique ID
status: Filter by order status (pending, shipped, delivered)
Returns:
List of matching orders with id, date, total, and items
"""