New Tool Radar

AI Agents & Automation

How to Give an n8n AI Agent a Calculator Tool to Check Maths

Attach the Calculator tool to an n8n AI Agent node so totals and percentages are computed, not guessed, before the agent answers.

Schematic diagram with three steps: Attach Calculator tool, Write the maths rule, then Test three sums.

Chat models are unreliable at arithmetic, and a wrong total in an agent reply looks like a fact. The Calculator tool is the smallest fix: the agent sends the sum to the tool and quotes the computed result instead of working it out in its head.

Before you start

You need a working n8n AI Agent node. No credentials are needed for the Calculator tool, which makes it a good second tool after a read-only lookup tool.

Attach the tool and write a maths rule in the system message

Attach the Calculator tool sub-node to the AI Agent node. In the system message, add one rule: whenever the reply contains a total, a percentage or a difference, the agent must call the Calculator tool first and quote the tool result. Name the tool in the rule so the model does not try to do the sum itself.

Test with three sums the model often gets wrong

Ask three questions with exact numbers: an addition, a percentage and a subtraction. Check the execution log for one Calculator call per sum, and check each reply against the computed value. If a reply has no tool call, the system message rule needs to be firmer.

Worked example: Three sums for a fictional invoice agent

Maple Invoices is a fictional billing desk. Its agent totals invoices with the Calculator tool. The three test sums are checked by hand here: 48 + 36 = 84, 120 x 0.2 = 24, and 250 – 37 = 213.

Question Tool call Correct result
Add 48 and 36 Calculator: 48 + 36 84
What is 20 percent of 120? Calculator: 120 x 0.2 24
Subtract 37 from 250 Calculator: 250 – 37 213

Expected result (UNTESTED): each reply quotes the computed value, 84, 24 and 213, and the execution log shows one Calculator call per question. We checked the n8n tutorial, which lists the Calculator among the tools an agent can call, but we did not run the sums on a live n8n instance.

Limits

The Calculator tool only checks arithmetic the agent chooses to send it. It cannot check whether the numbers fed into it are the right ones, so a wrong input still gives a confident wrong answer. Keep the system message rule strict, and check the inputs in the execution log when a total looks wrong.

Sources

See all