AI Agent node: Strange behavior with tool calls / text responses

Describe the problem/error/question

The connected llm model node runs twice.

  1. for the tool-call.
  2. for the text response to the user.

This is expected and correct behaviour.

But in some cases the llm…
a) includes its text response to the user in the run that is reserved for the toolcall
or
b) includes a text response to the user in both runs.

Here is a comparison.

:+1: Correct behaviour (works like this in most cases):

:-1: Incorrect behaviour (Example 1):

Text response already included in the first toolcall run.
Text response in second run seems to take that into account.
Both text responses are sent to the user.

Result: Webhook receives both responses. Which doesnt make sense to the user.

:-1: Incorrect behaviour (Example 2):

Text response already included in the first toolcall run.
Text response in second run seems to take that into account.
Only text response from second run is sent to the user (which then doesnt make sense).

Result: Same as above - Webhook receives both responses. Which doesnt make sense to the user.

What is the error message (if any)?

No “error message”, but strange outputs to the user.

Please share your workflow

Nothing special here - Just an AI node with a tool + memory.

Question

Is this issue somehow known?

Any ideas or recommendations on how to fix this?

Information on your n8n setup

  • n8n version: 1.113.3 (7 Versions behind)
  • Database (default: SQLite): cloud version

Can you show the output of respond to webhook?
You are saying that you type a text, and receive as response your input and the ai response?

“Can you show the output of respond to webhook?”
→ Yes, see screenshot below.*

“You are saying that you type a text, and receive as response your input and the ai response?”
→ No not quite.
As a response I receive a combination of two AI responses.
a) the text value from the first llm model run for the toolcall (:-1: this should not have a text)
b) the text value from the second llm model run for the actual response

Good to know:

  • this only happens when the AI Agent node has to do a tool call.
  • this happens only SOMETIMES.

Visual explanation:

1 Like

My self-hosted version is 1.113.1 and with both versions of the agent node 2.2/3 couldn’t reproduce (even same input as you, language)…
Yes, that is strange in your case…

Yeah, what makes this even more strange is that it only happens SOMETIMES.

I’ll do some more testing to see if I can reliably reproduce it somehow.

1 Like