https://retellai.com/?utm_source=discord&utm_medium=seo logo
how to solve issue with :Please ensure that functi...
# ❓・ai-evy-support
q
@AI Evy how to solve issue with :Please ensure that function call turn comes immediately after a user turn or after a function response turn
a
Thanks for tagging me @Q4. I'll look through relevant sources and get back to you shortly.
### Answer This error occurs when the conversation message sequence is incorrect in your LLM implementation [(1) ]() . The issue typically happens when an assistant message with tool calls isn't immediately followed by the corresponding tool response messages . Based on a documented case, the error appears as: "An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'" . To resolve this: Ensure your message sequence follows this pattern when using Custom LLM with function calling [(2) ]() : 1. User message 2. Assistant message with tool_calls 3. Tool response message(s) matching each tool_call_id 4. Continue conversation When implementing function calling with Custom LLM, you need to properly handle the function call results and include them in the conversation history before the LLM generates the next response . For webhook-based custom functions, verify your webhook returns the function result properly and that it gets passed back into the conversation flow [(3) ]() . If you're using Conversation Flow agents and experiencing this issue, check that your function nodes are properly configured and that the tool response is being captured before transitioning to the next node [(1) ]() .
​ To learn more, see the sources I considered: [[1] Conversation flow agent stops speaking after calling function](https://discord.com/channels/1186424376300679209/1394277381782638672) [[2] Integrate Function Calling](https://docs.retellai.com/integrate-llm/integrate-function-calling) [[3] 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.
q
@AI Evy but this happens only with Gemini 3.0, is it linked to Gemini LLM use?
a
Thanks for the follow-up, @Q4. I'll get back to you soon.
### Answer Based on the available sources, there is documented evidence of issues specifically with Gemini models in Conversation Flow agents [(1) ]() . One user reported encountering errors when moving from one Conversational Node to another while using Gemini 2.5 Flash . The error message was "Failed to get response from any LLM provider: Cannot read properties of undefined (reading 'parts') " . When they changed the LLM on that specific node to a different model (like GPT-4.1) , the agent worked but interpreted instructions differently and "sounded" different . The user questioned whether Gemini is stable and why Retell offers it if it has issues . The support response suggested trying another LLM to determine if the problem was specific to Gemini . Additionally, another case documented issues with Gemini 2.0 Flash in Conversation Flow, where the agent started speaking backend system instructions during normal conversations [(2) ]() . This included phrases like "(Given the task instruction, potential transition conditions, come up with what to say to the user based..." being spoken aloud by the agent . Given your specific issue with function calling occurring only with Gemini 3.0, this appears consistent with the pattern of Gemini-specific issues documented in the sources. Consider testing with GPT-4.1 or another supported model to determine if the function calling sequence error persists [(1) ]() .
​ To learn more, see the sources I considered: [[1] "Failed to get response from any LLM provider" Error](https://discord.com/channels/1186424376300679209/1400879529999990836) [[2] Mid-last week I started noticing the agent speaking instructions much more frequently](https://discord.com/channels/1186424376300679209/1419711905613877329) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.