Tool Calling Infinite Loop

I have a function node that calls a n8n webhook to send an email.

The transition is ‘Response Received’.

It started an infinite loop, calling n8n every few seconds and sending hundreds of mails.

How can tool calling loops be avoided?

Is there a ‘catch-all’ transition that could be used, as I always want it to continue to the next node?

Based on the available sources, here’s how to prevent infinite loops with function nodes:

Understanding Function Node Transitions

Function nodes transition based on specific timing conditions(1):

When “wait for result” is turned on:

  • If “speak during execution” is on, the agent transitions once the function result is ready and the agent is done talking(1)
  • If “speak during execution” is off, the agent transitions once the function result is ready(1)
  • If the user interrupts, transition happens once the function result is ready and the user is done speaking(1)

When “wait for result” is turned off:

  • If “speak during execution” is on, the agent transitions once done talking(1)
  • If “speak during execution” is off, the agent transitions immediately after the function gets invoked(1)
  • If the user interrupts, transition can happen once the user is done speaking(1)

Preventing Infinite Loops

To avoid the infinite loop you’re experiencing:

  1. Enable “Wait for Result” - This ensures the agent waits for your n8n webhook to complete before attempting any transition(1)

  2. Use transition conditions based on function result - Since the function node takes function result into consideration for transition timing, you can write your transition condition based on the function result(1)

  3. Connect to a conversation node - The function node is not intended for conversation with the user, so you should attach a conversation node after it to tell the user the result(1). You can create different conversation nodes for different function results(1)

Catch-All Transition

While the sources don’t explicitly mention a “catch-all” transition option, the recommended approach is to create different conversation nodes for different function results so the agent can engage users differently when function results vary(1).

The key is ensuring “Wait for Result” is enabled so the function completes before any transition occurs, preventing the loop behavior you’re experiencing.

Hello @mg1

Can you share the call id.

I tested the voice agent using a manual chat. How do I find the call id? I don’t see any history for chats.


If you’re only seeing call history and not chat history in the dashboard, you can retrieve chat conversation details programmatically using the API.(1)

To find the chat ID and view chat history, use the Get Chat API to retrieve details of a specific chat.(2)(1) The Get Chat API endpoint is:

GET /get-chat/{chat_id}

(2)

The response will include the chat_id along with other chat details such as agent_id, chat_status, transcript, and message_with_tool_calls.(2)

You can also use the List Chat API to retrieve chat conversation details programmatically.(1)

Check out these potentially useful sources: Get Chat(2)

Hello,
Can you reproduce it in a voice call so that I can check it?
Also, you can turn off the “Wait for Result” option if the result of this tool will not be used during a call.
Additionally, you can change the transition condition to “ALWAYS GO HERE.” The phrase “Response received” may be confusing — it’s unclear whether it refers to the user’s response or the tool’s response.