---
title: Calculator
description: Evaluate arithmetic expressions.
---

Give an AI agent a calculator, so it computes numbers exactly instead of guessing.

## What it does

Calculator is a tool for an agent, not a step in the flow. It has no output port: you connect it to the **Tools** slot of a [Tools Agent](/nodes/builtin/ai/aiagents/toolsagentnode/), and the agent's model can call it whenever it needs a result.

The model sends a math expression such as `(1299 * 0.8) + 4.99` and gets the result back as text. If the expression can't be read, the tool answers "I don't know how to do that." and the model carries on. It only computes: no approval is needed and nothing outside the run is touched.

## When to use it

* The agent must add up prices, apply a discount or a tax rate, or convert units from data it read.
* Answers must be exact: language models often get long arithmetic wrong.

For a fixed calculation you already know, skip the agent and use an expression in a regular node, for example `{{ $input.price * 1.2 }}`.

## Inputs and settings

This node has no settings.

There is nothing to configure. The model writes the expression on each call.

## Outputs

This node has no output port. It plugs into a slot on another node instead of passing items along.

* **Tools** slot of [Tools Agent](/nodes/builtin/ai/aiagents/toolsagentnode/)

The result goes back to the model, not to the next node. You see it in the agent's `steps` output, and the final answer in its `response`.

## Dependencies and credentials

None. This node needs no connection and has no slots for other nodes.

## Example workflow

1. [Get All Text](/nodes/extension/getalltext/) reads your shopping cart page, with **Output field name** `text`.
2. [Tools Agent](/nodes/builtin/ai/aiagents/toolsagentnode/) with **Prompt** `Add up the item prices in this cart and apply a 15% discount: {{ $input.text }}`, a [Chat OpenAI](/nodes/builtin/ai/aidependencies/llm/openai/) model in **Model**, and Calculator connected to **Tools**.
3. [Display Markdown](/nodes/extension/displaymarkdown/) shows `{{ $input.response }}`.

## Common issues

* **The agent does the math itself and gets it wrong.** Tell it in the **Prompt** or the **System message** to "use the calculator tool for every calculation".
* **The tool answers "I don't know how to do that."** The model sent something that isn't a plain math expression, such as text with currency signs or words. Ask it to send numbers and operators only.
* **The Calculator is never called.** Some small or on-device models handle tools poorly. Try a larger model.

## Related nodes

* [Tools Agent](/nodes/builtin/ai/aiagents/toolsagentnode/): the agent this tool plugs into.
* [Think](/nodes/builtin/ai/aidependencies/tools/think/): let the agent plan multi-step work before calculating.
* [Tool Selection](/concepts/ai/tool-selection/): how an agent chooses between its tools.