INNER CODE UNIT · Python
sum
panaversity/learn-agentic-ai · 01_ai_agents_first/06_basic_tools/main.py:44
def sum(a: int, b: int) -> int:
"""➕ Exact addition (use this instead of guessing math)."""
return a + b
# 🤖 4) Create agent and register tools
agent: Agent = Agent(
name="Assistant", # 🧑🏫 Agent's identity
instructions=(
"You are a helpful assistant. "
"Always use tools for math questions. Always follow DMAS rule (division, multiplication, addition, subtraction). "
"Explain answers clearly and briefly for beginners."
),
model=model,
tools=[multiply, sum], # 🛠️ Register tools here
)
# 🧪 5) Run the agent with a prompt (tool calling expected)
prompt = "what is 19 + 23 * 2?"