https://retellai.com/?utm_source=discord&utm_medium=seo logo
using a prompt for my agent the function end_call ...
# ❓・ai-evy-support
p
@AI Evy using a prompt for my agent the function end_call is not firing correctly when it’s supposed to. How do I ensure it gets fired when I need it to?
a
Thanks for tagging me @pickyourknows. I'll look through relevant sources and get back to you shortly.
### Answer To ensure the
end_call
function fires correctly, you need to properly configure both the tool and your prompt instructions [(1) ]() . Here's how to set it up: 1. **Add the End Call Tool**: Click "+ Add" in the tools section and select "End Call" from the dropdown menu . 2. **Configure Termination Conditions**: Define specific conditions under which the call should be terminated . For example: "If the user says 'thank you', 'goodbye', or 'bye', use the end_call tool to terminate the conversation" . 3. **Update Your Prompt**: This is crucial - enhance the agent's understanding by incorporating the end call conditions directly into the prompt . Include specific instructions such as: "If the user says 'thank you', 'goodbye', or 'bye', use the end_call tool to terminate the conversation" . **Key Point**: By default, the agent won't end the call automatically . You must explicitly configure when and how the call should be terminated using the end call tool . The LLM determines when a function is needed based on the conversation context [(2) ]() , so your prompt instructions need to be clear and specific about the conditions that should trigger the end call function. If you're still having issues, make sure your prompt clearly states the exact scenarios where the agent should use the
end_call
tool, as the agent relies on these instructions to decide when to execute the function.
​ To learn more, see the sources I considered: [[1] End call](https://docs.retellai.com/build/single-multi-prompt/end-call) [[2] Function Calling Overview](https://docs.retellai.com/build/single-multi-prompt/function-calling) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
p
And this works reliably? I have it marked exactly where it should use it and it still doesn’t @AI Evy
a
Thanks for the follow-up, @pickyourknows. I'll get back to you soon.
​ To learn more, see the sources I considered: [[1] 'end_call' not triggering after Agent Transfer](https://discord.com/channels/1186424376300679209/1419677751551721472) [[2] End Call Function Doesn’t Work](https://discord.com/channels/1186424376300679209/1356072431994933399) [[3] Integrate Function Calling](https://docs.retellai.com/integrate-llm/integrate-function-calling) [[4] Discord message from @mike_56558 on 2025-03-14](https://discord.com/channels/1186424376300679209/1294891368505937952/1350217287109705728) [[5] Automatically test your agent](https://docs.retellai.com/test/llm-simulation-testing) [[6] Troubleshooting Guide](https://docs.retellai.com/integrate-llm/troubleshooting) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
### Answer Based on the sources, the
end_call
function can be unreliable, and you're not alone in experiencing this issue [(1) ]() [(2) ]() . Here are specific troubleshooting steps to improve reliability: 1. Define the Function Correctly For custom LLM integration, ensure your function is properly defined [(3) ]() :
Copy code
javascript
private PrepareFunctions() : ChatCompletionsFunctionToolDefinition[] {
 let functions: ChatCompletionsFunctionToolDefinition[] = [{
 type: "function",
 function: {
 name: "end_call",
2. Structure Your Prompt Instructions Use numbered structure in your prompts, which helps with reliability [(4) ]() :
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
3. Test with Simulation Use LLM simulation testing to verify the function triggers correctly [(5) ]() . You can define evaluation metrics like :
Copy code
2. Confirm that the end_call function was called at the end of the conversation.
4. Check Your Logs Add logging to verify if you're sending "end_call=true" at any point, as this can help diagnose the issue [(6) ]() . Common Issues: - Agent transfer scenarios can cause problems with
end_call
triggering [(1) ]() - Some users report better success switching to conversation flow instead of single/multi-prompt agents - The agent won't hang up unless explicitly designed to do so [(2) ]() If the issue persists, consider using conversation flow with an End Node, which some users report works more reliably than function calling for ending calls [(1) ]() .
p
It’s still not ending the sms chat. Any ideas? No agent transfers @User
It’s still not ending the sms chat. Any ideas? No agent transfers @AI Evy
a
Thanks for the follow-up, @pickyourknows. I'll get back to you soon.
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] Calling end_call programatically ends the call before the final AI message is spoken out](https://discord.com/channels/1186424376300679209/1346423473765093376) [[2] Create Outbound SMS](https://docs.retellai.com/api-references/create-sms-chat) [[3] End call](https://docs.retellai.com/build/single-multi-prompt/end-call) ​
### Answer For SMS chats specifically, there appears to be a known issue with the
end_call
function not working as expected. Based on the available sources, there's a documented problem where calling
end_call
programmatically ends the call before the final AI message is spoken out [(1) ]() . The issue affects both streaming responses and single responses with
end_call=True
, where the AI doesn't get to speak the final response and hangs up instantly instead . For SMS chats created using the API, the basic setup involves [(2) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.createSMSChat({
 from_number: '+12137771234',
 to_number: '+14155551234',
}) ;
However, the
end_call
function behavior in SMS chats appears to have reliability issues that may require support team assistance to resolve [(1) ]() . For the standard voice call configuration, you would add the End Call tool and configure termination conditions such as "If the user says 'thank you', 'goodbye', or 'bye', use the end_call tool to terminate the conversation" [(3) ]() . But given the specific SMS chat context and the documented issues, this may not work reliably. I'd recommend reaching out to support with your specific SMS chat implementation details, as this appears to be a known technical issue that may require backend investigation [(1) ]() .
p
@User is the end call function still a known bug if using a prompt? How can I ensure the call or sms chat ends when it needs to end?
Questions we need answered Supported pattern: For SMS agents, is invoking built-in end_call in the same assistant turn (right after sending a message) officially supported? Or must end_call be invoked in a separate assistant turn? Flow vs Prompt: Is there a known reliability gap for end_call on SMS in prompt-only agents? Should we switch to Conversation Flow with an explicit function node wired after the closing message to guarantee termination? Rule engine precedence: When both (a) the prompt says “call end_call now” and (b) a termination rule matches the closing sentence, which mechanism fires first? Could they be mutually blocking or require a one-turn delay? Function attachment scope: Is the built-in end_call guaranteed available for SMS (not just Voice)? Any agent-level flags (e.g., “Allow end_call in chat”) we must enable? Same-turn restriction: Does end_call for SMS require the model to send the closing message, then pause, then call the tool in a new tool-only turn (i.e., not concatenated with the chat message)? If so, please provide the canonical prompt snippet and any UI settings to enforce that pattern. Backend logs: Please check backend logs for the above run (agent id + timestamp). Did the model attempt to call end_call and get rejected? Did the termination rule fire? If something blocked it, what was the validation error or state? Known issues: Are there open bugs for end_call reliability on SMS (prompt-only agents), and if yes, is there an ETA or recommended workaround? @AI Evy
a
Thanks for the follow-up, @pickyourknows. I'll get back to you soon.
### Answer Based on the available documentation, I can address some of your questions about the
end_call
function in SMS chats, though the sources don't cover all the specific technical details you're asking about. ## What the Documentation Shows **Function Calling Basics**: Function calling works by having the LLM determine when a function is needed based on conversation context, extract required parameters, and execute the function with those parameters [(1) ]() . For the
end_call
function specifically, you can define it like this [(2) ]() :
Copy code
javascript
private PrepareFunctions() : ChatCompletionsFunctionToolDefinition[] {
 let functions: ChatCompletionsFunctionToolDefinition[] = [{
 type: "function",
 function: {
 name: "end_call",
 description: "End the call only when user explicitly requests it.",
 parameters: {
 type: "object",
 properties: {
 message: {
 type: "string",
 description: "The message you will say before ending the call with the customer.",
 },
 },
 required: ["message"],
 },
 },
 }];
 return functions;
}
n the current documentation.
**Prompt Structure Recommendations**: The documentation suggests using structured prompts with numbered steps, which can help with function calling reliability [(3) ]() . Community feedback indicates that structuring instructions like "1. Say 'have a great rest of your day'. 2. Use 'end_call' tool to end the call" usually helps [(4) ]() . **Known Issues**: There are documented reliability issues with the
end_call
function. One community member reported that "Sometimes, when the call ends, the agent doesn't end it but instead verbally announces the execution of the tool" [(5) ]() . The suggestion was to use clear instructions about when to use the function and when not to [(4) ]() . ## What's Not Covered The documentation doesn't specifically address: - SMS-specific
end_call
behavior vs voice calls - Same-turn vs separate-turn execution patterns for SMS - Rule engine precedence between prompts and termination rules - SMS-specific function attachment requirements - Backend validation details for failed
end_call
attempts ## Recommendations Based on available information, consider: 1. Using Conversation Flow instead of prompt-only agents, as some community members report better reliability 2. Setting up max call duration and max silence duration as fallbacks to avoid overcharging 3. Using clear, structured prompt instructions with numbered steps For the specific technical details about SMS chat termination patterns, backend logs analysis, and known bugs with ETAs, you'll need to contact support directly as this information isn't available i
​ To learn more, see the sources I considered: [[1] Function Calling Overview](https://docs.retellai.com/build/single-multi-prompt/function-calling) [[2] Integrate Function Calling](https://docs.retellai.com/integrate-llm/integrate-function-calling) [[3] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[4] Discord message from @sanava.ai on 2025-03-14](https://discord.com/channels/1186424376300679209/1294891368505937952/1350212730593873941) [[5] Discord message from @juanfgx on 2025-08-17](https://discord.com/channels/1186424376300679209/1294891368505937952/1406667947602083981) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
p
@AI Evy how do i contact support about this issue?
a
Thanks for the follow-up, @pickyourknows. I'll get back to you soon.
### Answer Based on the available sources, I don't have specific information about Retell AI's direct support contact methods for technical issues like the
end_call
function problem you're experiencing. However, I can provide these contact options: **Sales Contact**: Visit [Contact Sales]() for business inquiries. **GitHub Repository**: Visit [) for technical resources and potentially to file issues. For immediate technical support regarding the
end_call
function reliability issues you're experiencing with SMS chats, you may also want to check if there are additional support channels or contact information available on the main Retell AI website that aren't covered in the current sources. Would you like a general answer based on my knowledge about typical support channels for technical platforms like this?
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
message has been deleted