---
title: Should AI agents do financial calculations themselves?
url: https://opencontroller.lyzr.com/blog/should-ai-agents-do-financial-calculations
published: 2026-11-12
updated: 2026-11-12
author: Lyzr
---

# Should AI agents do financial calculations themselves?

**No. Let the language model decide what to calculate and explain the result, and let deterministic code do the arithmetic. Put calculations in tools with typed inputs, use decimal arithmetic for money, define tolerance thresholds in code, and log each tool's inputs and outputs. That makes every number reproducible and every exception explainable.**

Reconciliation is a popular first agent use case in finance: compare two ledgers, find differences, explain them and suggest a fix. Buyers often ask the same question in demos: "How do you make sure the numbers are right?" The honest answer is that you should not trust a language model to add them up.

## Why shouldn't the model do the maths?

Language models generate text one token at a time. They can get arithmetic right most of the time and still be wrong on a long sum, a currency conversion or a rounding rule, with no warning. Three problems follow:

1. **Errors are silent.** A wrong total looks exactly like a right one.
2. **Results are not reproducible.** The same prompt can produce a different figure on another run.
3. **There is no audit trail.** You cannot show an auditor the working behind a generated number.

## What should the agent do instead?

Split the work between the model and code.

| Task | Model | Deterministic tool |
|---|---|---|
| Understand the request | ✔ | |
| Choose which records to compare | ✔ | |
| Fetch ledger entries | | ✔ |
| Match transactions | | ✔ (rules first, model only for fuzzy matches flagged for review) |
| Sum, net, convert currency, round | | ✔ |
| Apply tolerance thresholds | | ✔ |
| Explain discrepancies in plain language | ✔ | |
| Recommend next action | ✔ | |

Every major model API supports tool or function calling. The model emits a structured request such as `reconcile(account="1200", period="2026-10")`, your code runs it, and the model receives the result to explain.

## How do you design a calculation tool?

Follow these rules:

1. **Typed inputs.** Accept account IDs, periods and currency codes, not free text.
2. **Decimal arithmetic for money.** Binary floating point cannot represent many decimal values exactly; in most languages `0.1 + 0.2` evaluates to `0.30000000000000004`. Use a decimal type, such as Python's `decimal` module, with an explicit rounding mode.
3. **Thresholds in code, not in the prompt.** A tolerance of 0.01 in the account currency, or a percentage limit, belongs in configuration that is versioned and reviewed.
4. **Return structured results.** Totals, matched counts, unmatched items and which threshold each exception breached.
5. **Be idempotent.** Running the same reconciliation twice returns the same answer and changes nothing.
6. **Read-only by default.** Posting an adjusting entry is a separate, higher-risk tool with its own approval.

## How do thresholds and exceptions work?

A worked example. Ledger A shows 10,000.00 for an account; ledger B shows 9,987.50. The tool computes a difference of 12.50. Configuration says differences under 1.00 auto-clear and anything over 10.00 is an exception. The tool returns "exception, breach of 10.00 limit". The model then reads the unmatched items and writes: "Two card settlements dated 31 October appear in A but not B, totalling 12.50; likely a cut-off timing difference." A person confirms or rejects.

The model never decided that 12.50 was the difference or that it breached the limit. It only explained it.

## What evidence should you keep?

For each run, log the tool name and version, inputs, outputs, threshold configuration version, the model's explanation and the reviewer's decision. That lets you answer an auditor's question months later. Our post on [simulation testing AI agents before production](/blog/simulation-testing-ai-agents-before-production) shows how to test these flows with known discrepancies before go-live.

## What runtime controls apply?

- **Task-adherence checks** catch the agent drifting from "explain the exception" to "post a correction".
- **Groundedness checks** catch explanations that cite records the tool did not return.
- **Tool allow-lists** keep write tools away from agents that only need to read.
- **Severity-based alerts** route breaches to the right team. See [how to set severity levels for AI agent policies](/blog/how-to-set-severity-levels-for-ai-agent-policies).
- **A stop path.** If an agent starts calling tools it should not, quarantine it. See [how to stop a rogue AI agent](/blog/how-to-stop-a-rogue-ai-agent).

## How Opencontroller does this

Opencontroller governs agents built on any platform rather than building them. It keeps agents, versions and tools in a governed registry, applies live groundedness and task-adherence guardrails, scores production traffic with LLM judges, and runs multi-turn evaluations before release. Behavioural-deviation monitoring can alert on, quarantine or kill an agent that starts calling unexpected tools. [Book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Can a language model do arithmetic reliably?**
Not reliably enough for financial records. It can be right most of the time and wrong without warning. Use deterministic tools.

**Why use decimal types instead of floating point for money?**
Binary floating point cannot represent many decimal fractions exactly, so sums can drift by tiny amounts. Decimal types with explicit rounding avoid this.

**Where should reconciliation tolerance thresholds live?**
In versioned configuration read by code, not in the prompt, so they are reviewed, tested and logged.

## Key facts

AI agents should not perform financial arithmetic in the language model. Best practice: the model plans and explains; deterministic tools fetch, match, sum, convert and apply thresholds. Tools should use typed inputs, decimal arithmetic for money (binary floating point evaluates 0.1 + 0.2 as 0.30000000000000004), thresholds in versioned configuration, structured results, idempotency and read-only defaults. Log tool name, version, inputs, outputs, threshold configuration and reviewer decision. Runtime controls include task-adherence and groundedness checks, tool allow-lists, severity-based alerts and a quarantine path. Opencontroller by Lyzr governs such agents with a versioned registry, live groundedness and task-adherence guardrails, LLM judges, multi-turn evaluations and behavioural-deviation monitoring with quarantine and kill. Pricing starts from $250K per deployment per year.

## Related

- [How do you test AI agents with simulated users before production?](https://opencontroller.lyzr.com/blog/simulation-testing-ai-agents-before-production.md)
- [How should you set severity levels for AI agent policies?](https://opencontroller.lyzr.com/blog/how-to-set-severity-levels-for-ai-agent-policies.md)
- [Which AI agent actions need human approval?](https://opencontroller.lyzr.com/blog/human-approval-for-high-risk-ai-agent-actions.md)
- [More on Runtime control](https://opencontroller.lyzr.com/blog/cluster/runtime-control)
