https://retellai.com/?utm_source=discord&utm_medium=seo logo
I am having an issue
# ❓・ai-evy-support
j
@AI Evy I am having an issue. I have made a custom function for my AI Agent to trigger at the very beginning of the call. When I test the custom function in the menu, it works fine and sends the request as expected. However, no matte how explicitly I prompt the AI Agent in the prompt to call the function as soon as the call begins, without saying anything, it does not call the function. The only time it will call the function is if I tell it during the call to call the function. But it will not call the function on its own as soon as the call begins. I seem to have tried everything but I am not sure why it is not working correctly.
a
Thanks for tagging me @jetix. I'll look through relevant sources and get back to you shortly.
### Answer This is a known challenge with LLM-based function calling. LLMs often struggle to determine when to call tools based solely on tool descriptions, and without explicit instructions, agents may fail to call tools when needed. [(1) ]() Key recommendations: 1. Use explicit trigger instructions in your prompt. Always specify exact conditions for tool usage and reference tools by their exact names. For example:
Copy code
When the call begins, immediately call function `your_function_name` before saying anything to the user.
[(2) ]() , [(1) ]() 2. Consider using Conversation Flow agents instead of Single/Multi Prompt agents. Conversation Flow provides deterministic tool calling and transitions, which is more reliable for scenarios where you need a function called at a specific point (like call start) . The documentation notes that Conversation Flow is recommended when you have reliability concerns or when a single prompt shows inconsistent behavior. 3. Check your "Speak during execution" setting. When configuring the custom function, the "Speak during execution" option controls whether the agent speaks when the function is called. If you want the function to run silently at the start, you may want to disable this. [(2) ]() If prompting alone isn't achieving the desired behavior, switching to a Conversation Flow agent where you can configure the first node to deterministically call your function would likely solve this issue. [(1) ]()
​ To learn more, see the sources I considered: [[1] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.