Example: Adding a Calculator to Our Agent › The Problem We're Solving

Michael BrenndoerferJune 29, 20251 min read
AI Agent HandbookAll chapters
Part 5 of 15Tool Use - Extending the Agent's Abilities
Chapter 14Example: Adding a Calculator to Our Agent › The Problem We're Solving
Reading section 2 of 16 · The Problem We're Solving · 1 minSection 2 of 16 · 1 min

Book contents

Section 2 of 16 · 1 min read

Example: Adding a Calculator to Our Agent › The Problem We're SolvingOne section · Sections in this chapter2 / 16 ↓

Remember this scenario from earlier? You ask your agent: "What's 1,234×5,6781,234 \times 5,678?"

Without tools, the agent approximates:

Let me work through this:
1,234 × 5,678 = approximately 7,010,000

So the answer is about 7,010,000.

The agent is guessing. The actual answer is 7,006,6527,006,652. That's an error of over 3,0003,000. Not acceptable if you're calculating costs, revenues, or anything that matters.

With a calculator tool, the agent will:

  1. Recognize this is a math problem
  2. Call the calculator with the expression
  3. Return the exact answer: 7,006,6527,006,652

Let's build it.