https://retellai.com/?utm_source=discord&utm_medium=seo logo
Why does my agent get stuck in a loop at the end o...
# ❓・ai-evy-support
e
@AI Evy Why does my agent get stuck in a loop at the end of a call? I have a node that should say a farewell and then end the call, but it waits for more user input instead of executing the end_call command immediately after speaking.
a
Thanks for tagging me @enes (ekkovoice). I'll look through relevant sources and get back to you shortly.
​ To learn more, see the sources I considered: [[1] End Node](https://docs.retellai.com/build/conversation-flow/end-node) [[2] Discord message from @mike_56558 on 2025-03-14](https://discord.com/channels/1186424376300679209/1294891368505937952/1350217287109705728) [[3] Agent fails to say goodbye before ending the call](https://discord.com/channels/1186424376300679209/1294639127895212083) [[4] Discord message from @sanava.ai on 2025-03-14](https://discord.com/channels/1186424376300679209/1294891368505937952/1350213549460553779) [[5] Create Voice Agent](https://docs.retellai.com/api-references/create-agent) [[6] Update Voice Agent](https://docs.retellai.com/api-references/update-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
### Answer This is a common issue with end call behavior. Here are the key points: How the End Node Works The End Node ends the call the moment the agent enters it—it does not wait for additional input. [(1) ]() The Problem If you're prompting the agent to say goodbye and then call
end_call
, the agent may not complete the farewell message before the call terminates. Others have reported similar behavior where the agent hangs up without delivering the goodbye. [(2) ]() [(3) ]() Recommended Solutions 1. Use "Speak During Execution" on the End Node—this allows you to write instructions for an utterance like "Goodbye, have a nice day" that the agent says while the end call executes. [(1) ]() 2. Structure your prompt explicitly with numbered steps:
Copy code
When the conversation comes to an end or the user says "bye":
   1. Say "have a great rest of your day"
   2. Use "end_call" tool to end the call
[(4) ]() 3. As a fallback, configure
end_call_after_silence_ms
and
max_call_duration_ms
in your agent settings so the call ends automatically if the tool isn't triggered properly. [(5) ]() [(6) ]() The numbered step approach combined with the "Speak During Execution" setting on the End Node should resolve the loop issue.
e
he previous prompt change didn't work. When I say 'bye', the agent says the farewell sentence from the END_CALL_GRACEFUL node, but it still waits for user input. Only after I say 'bye' a second time does it actually trigger the end_call tool. The agent is stuck in a loop where the speech and the tool execution are not sequential. How do I force the agent to trigger the end_call tool automatically and immediately after finishing the farewell sentence without requiring any further user interaction? Should I use a specific function node configuration or a different prompt structure for the tool call itself?
@AI Evy The previous prompt change didn't work. When I say 'bye', the agent says the farewell sentence from the END_CALL_GRACEFUL node, but it still waits for user input. Only after I say 'bye' a second time does it actually trigger the end_call tool. The agent is stuck in a loop where the speech and the tool execution are not sequential. How do I force the agent to trigger the end_call tool automatically and immediately after finishing the farewell sentence without requiring any further user interaction? Should I use a specific function node configuration or a different prompt structure for the tool call itself?
a
Thanks for the follow-up, @enes (ekkovoice). I'll get back to you soon.
### Answer Based on your description, the issue is that your conversation node says the farewell but doesn't automatically transition to the End Node—it waits for more input instead. Key insight: The End Node ends the call the moment the agent enters it. [(1) ]() The problem is getting the agent to enter that node immediately after speaking. Recommended approach: 1. Use the End Node's "Speak During Execution" setting instead of a separate conversation node for the farewell. This allows you to write instructions for the agent to say something like "Goodbye, have a nice day" while the end call executes. This eliminates the gap where the agent waits for input. 2. If you must use a separate node before the End Node, ensure the transition edge is configured to move to the End Node unconditionally after the farewell—not based on user input. 3. Alternative: Switch to Conversation Flow if you haven't already. One user reported that switching from single prompt agents to conversation flow resolved their
end_call
triggering issues with agent transfers. [(2) ]() 4. As a safety net, configure
end_call_after_silence_ms
in your agent settings so the call ends automatically after a period of silence. [(3) ]() The most reliable fix is to move your farewell message into the End Node's "Speak During Execution" field rather than having a separate conversation node that requires a transition.
​ To learn more, see the sources I considered: [[1] End Node](https://docs.retellai.com/build/conversation-flow/end-node) [[2] 'end_call' not triggering after Agent Transfer](https://discord.com/channels/1186424376300679209/1419677751551721472) [[3] Create Voice Agent](https://docs.retellai.com/api-references/create-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
e
@AI Evy I already have a conversation flow and I set up the speak during execution, but this problem still occurs
a
Thanks for the follow-up, @enes (ekkovoice). I'll get back to you soon.
### Answer --- This appears to be a known issue. Another user reported the same behavior: "I have an end call node that is supposed to speak on execution, but it never does. The calls end pretty abruptly without any goodbye." [(1) ]() A few things to check: 1. Transition configuration: Make sure the edge from your conversation node to the End Node is set to transition immediately—not waiting for user input. In Conversation Nodes, transitions can happen "when user is done speaking" or "when
Skip Response
is enabled and agent finishes speaking." [(2) ]() 2. Try enabling "Skip Response" on the conversation node before the End Node. When enabled, the agent will transition via the connected edge as soon as it finishes speaking, without waiting for user input. 3. LLM model choice: One community member asked which LLM was being used when troubleshooting a similar issue. Try switching to a different model (e.g., GPT-4.1) to see if behavior improves. [(3) ]() 4. Prompt structure: Structure your end call instructions with numbered steps:
Copy code
When the conversation comes to an end or the user says "bye":
   1. Say "have a great rest of your day"
   2. Use "end_call" tool to end the call
If the issue persists after trying these configurations, this may require direct support investigation since the "Speak During Execution" feature not working as expected has been reported by others. [(1) ]()
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Speak During Execution not working for End Call node](https://discord.com/channels/1186424376300679209/1451006517909258352) [[2] Conversation Node](https://docs.retellai.com/build/conversation-flow/conversation-node) [[3] Discord message from @sanava.ai on 2025-03-14](https://discord.com/channels/1186424376300679209/1294891368505937952/1350212730593873941) ​
e
@AI Evy this is what fixed it, can you save this solution in your database if some one else also get's this issue? I fixed this by moving the logic from the Node to the Global Prompt. In Flex Mode, a 'race condition' often causes the tool to terminate the call before the TTS finishes. Instead of using 'Speak during execution' in the node, I left the node empty and added a strict 'Output-First' protocol to the Global Prompt: Instruction: Explicitly tell the agent to output the farewell sentence (e.g., 'Have a great day') first. Sequential Action: Instruct the agent to trigger the end_call tool immediately after generating that specific sentence. No Wait: Command the agent to never wait for user input between the speech and the tool call. This forces the LLM to sequence the speech and the hangup technical action correctly every time.
a
Thanks for the follow-up, @enes (ekkovoice). I'll get back to you soon.
### Answer Thank you for sharing your solution! This is valuable information for others experiencing the same issue in Flex Mode. To summarize your fix for future reference: The Problem: In Flex Mode, there's no "Speak After Execution" setting—the agent always speaks after function execution. [(1) ]() This can cause a race condition where the
end_call
tool terminates the call before the TTS finishes the farewell message. Others have reported similar issues where "Speak During Execution" doesn't work as expected for the End Call node. [(2) ]() Your Solution - "Output-First" Protocol in Global Prompt: Instead of relying on the node's "Speak during execution" setting, move the logic to the Global Prompt with these instructions: 1. Instruction: Explicitly tell the agent to output the farewell sentence (e.g., "Have a great day") first 2. Sequential Action: Instruct the agent to trigger the
end_call
tool immediately after generating that specific sentence 3. No Wait: Command the agent to never wait for user input between the speech and the tool call This approach aligns with the documented best practice of writing node instructions in a concise manner so the LLM can better focus on the task. [(1) ]() Note: This workaround is particularly relevant for Flex Mode users, since Flex Mode compiles the conversation flow into one structured prompt where the agent navigates tasks dynamically.
​ To learn more, see the sources I considered: [[1] Flex Mode](https://docs.retellai.com/build/conversation-flow/flex-mode) [[2] Speak During Execution not working for End Call node](https://discord.com/channels/1186424376300679209/1451006517909258352) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the feedback, glad I was helpful.