AI Hints
Home›Agentic AI Tutorial›Parallel Tools and Limits
Agentic AI · Lesson 18 of 100

Tools That Make Models Smarter

Never let a model do maths.

⏱ 2 min read▶ Video at 33:06🎓 Free
Watch this lesson in the Agentic AI courseWatch on YouTube ↗Full Agentic AI course

Models are brilliant with language, and unreliable with arithmetic. They can write a poem about prime numbers, then get a long multiplication wrong. The fix isn't a bigger model. It's a tool. Give them a calculator, and let code do what code does best.

Tools That Make Models Smarter
From the video: Tools That Make Models Smarter
  • Brilliant at language
  • Unreliable at arithmetic
  • Give them a calculator

Let code do the numbers

This tool works out an order total. Notice the description. It says, always use this for prices. We ask a question with awkward numbers. And we work out the true answer in Python, to compare. Run it. The answer matches to the cent, because the model never did the arithmetic. It just picked out the three numbers, and our code did the rest. That's a key principle of agent design. Models decide, and code calculates.

total.pypython
from google import genai
from google.genai import types

def order_total(unit_price: float, quantity: int, discount_percent: float) -> dict:
    """Work out an order's total. Always use this for prices."""
    return {"total": round(unit_price * quantity * (1 - discount_percent / 100), 2)}

client = genai.Client()
r = client.models.generate_content(
    model="gemini-flash-latest",
    config=types.GenerateContentConfig(tools=[order_total]),
    contents="Seventeen chains at 28.49 each, with 12.5 percent off. What's the total?")
print(r.text)
print("Correct answer:", round(28.49 * 17 * 0.875, 2))
Output
The total for seventeen chains at $28.49 each, with a 12.5% discount, is **$423.79**.
Correct answer: 423.79

What should be a tool?

Use this rule. If an answer has to be exactly right, or up to date, it shouldn't come from the model's memory. Maths needs a calculator. Dates need a clock, as models don't know today's date. Prices and stock need your database. Policies need your documents. The model is the decision maker, not the source of truth.

Mathsa calculator
Today's datea clock
Live datayour database
Policiesyour documents

Models decide, code does

Here's how to picture it. The model is the judgment layer. It understands the request, chooses what to do, and writes the reply. Your code is the reliable layer. It does the sums, checks the rules, and touches the real systems. Keep each one doing what it's good at.

Summary

Models decide, and code calculates. That's the end of the tools module, and you can now build a solid agent. But often, you don't need that much freedom. Next, the patterns that the best teams use most. Workflows.

Key takeaways
  • Exact answers need tools
  • Models decide, code calculates
  • The model isn't the source of truth
Next up: Prompt Chaining — break it into steps