Skip to main content

Tools

A model cannot safely read your customer database, order system, or private business state by itself. Tools solve this boundary: the Agent can request an application-owned function while your service keeps data access, authorization, and side effects under its control.

from agents import function_tool, Runner
from iztro_agents import ChatSession, iztro_ziwei_agent

@function_tool
def lookup_customer(customer_id: str) -> str:
return "Customer is on the annual plan."

agent = iztro_ziwei_agent(tools=[lookup_customer])
session = ChatSession(external_user_id="user_42")
result = await Runner.run(agent, "Use my customer profile when answering.", session=session)

Real example: 07_multi_step_booking.py

This example uses two local tools in sequence: check calendar availability, then book only if the selected date is free. The Chinese and English recorded outputs are shown inline below.

Source: examples/07_multi_step_booking.py.

Prompt used for this run

I was born on 1990-12-21 at 13:00, female. Find one auspicious weekday next week for an important meeting, check my calendar first, and book it if it is free.

Complete recorded output

Loading recorded output…