Calculator
Calculator solves arithmetic: additions, subtractions, multiplications, divisions, remainders and powers, with brackets to set the order of operations. It does not need a credential.
Its most common use is as a tool for an agent. AI models sometimes get sums wrong; with Calculator connected, the agent writes the operation and gets the exact result. You can also use it as a step in the flow by writing the operation in Expression.
When to use it
- A sales assistant calculates discounts, taxes or quote totals.
- An agent answering questions about invoices needs to add amounts without mistakes.
- You want to calculate a percentage or a unit conversion inside a flow.
- You need the agent to check a figure before giving it.
Configuration
| Field | What it does |
|---|---|
| Expression | The operation to solve, for example 4*4*(33/22)+12-20. Only used as a flow step; when the component is connected as a tool, the agent writes the operation. |
Supported operations:
| Symbol | Operation |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
// | Integer division, for example 7//2 gives 3 |
% | Remainder of a division, for example 7%3 gives 1 |
** | Power, for example 2**3 |
( ) | Groups operations to set the order |
Output
- Tool: connects to an agent’s Tools input. The agent receives the result of each operation it asks for.
- Data: the result in the
resultfield, with up to six decimals. If the operation is not valid or divides by zero, it returns anerrorfield with the reason and aninputfield with the operation received.
Example
An online shop wants its assistant to calculate the final price of an order.
- Add Calculator and connect its Tool output to the agent’s Tools input.
- In the agent’s instructions, tell it to use the calculator for any amount.
- A customer asks: “How much do I pay for 3 units at €24.90 with a 15% discount?”. The agent asks for
3*24.90*(1-0.15)and replies with the result: €63.495.
Good practices
- Use a dot as the decimal separator:
24.90, not24,90. - Functions such as square roots, sines or logarithms are not supported. For a square root you can use a power:
9**0.5. - Negative numbers are written as usual:
-3+5or(-2)**2. - Powers with an exponent above 1000 are refused, so a huge operation cannot block the flow.