Math Operations within AI Agents at n8n

Hi there!

I am executing basic math operations (averages) on my ChatGPT Agent at n8n.
However it always bring back a diffent result for the exactly same data.
I tried to use CALCULATOR, but it did not work well for the amount of operatiosn I need to execute.
Please, what are the alternatives for a precise and reliable math operations within the agent?
Best regards
CA

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

Hi @CARLO_AIROLDI ,

What model are you using for your agent? I’ve found that openai’s o1 is the best for math functions. Not perfect, but might work for your case.

Best,

Robert Breen

Hi, Robert,
Thank you for reaching out.
I am using gpt-4.1-mini.
I have tried to connect the Wolfram Alpha for math operations, but it still miscalculates most of the averages. Possibly I am doing something wrong.
Also tried DeepSeek. The same.
I haven’t tried o1 yet.
I’ll try it right away.

Regards
CA
Thank

1 Like

@CARLO_AIROLDI

Can you upload your workflow into a code block? I’m sure you can use multiple tools to make it work.

Robert

@rbreen
My apologies, but I don’t undestand what want me to do! What do you mean “upload into a code block”?

1 Like

You can copy your n8n workflow, and paste it into a reply here. Then we can look at your actual flow.

Here’s an image.

Robert,

I am breaking down the Agent in smaller peaces in order to make more simple reasoning at a time.
I believe it will improve the quality of the output.
However, for sure there is an issue with math operations, mainly when I read a Sheet file and need to make math operations, like averages.
Further in my tests, I will come up to this operations again, then I will let you know whether it is working properly.
Best regards for the time being!
CA
For now I thank you

1 Like

Hi @CARLO_AIROLDI,

That makes sense. You may also want to look into passing data out of the llm if a math function is asked for, and doing the math with coding steps instead. Then the llm is doing what it is best at (language) and passing math functions to other nodes.

Best,

Robert