### 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) ](
) .