Agent answer before tool_call_result
# support
s
my agent is triggering a "role": "tool_calls", but he answer the question before received the tool_call_result (ex call ID : 7de5313b-9a93-44cb-a777-2ca7833206cc) so almost all the time he answer with the wrong answer. how to fix that ? i've already tried to add - When you call "tool_calls", wait "tool_call_result" before answering in the prompt. but it doesnt fix but it seems something that VAPI need to support nativly
v
Hi there! đź‘‹ This is a known issue with VAPI agents. Let me share some configuration options that might help: 1. **Use synchronous tool calls**: Make sure your tool is configured with
async: false
to ensure the function waits for the completion of the tool execution before proceeding [Discord conversation](https://discord.com/channels/1211482211119796234/1211483291191083018/1333880245681393756). 2. **Configure blocking messages**: Try using
ToolMessageStart.blocking=true
which is a recent update that allows you to configure your tool calls to wait until a message is fully spoken before starting [Changelog](https://docs.vapi.ai/changelog/2025/2/4). 3. **Check response format**: Ensure your server responds with the correct JSON format containing
toolCallId
and `result`:
Copy code
json
{
  "results": [
    {
      "toolCallId": "X",
      "result": "Y"
    }
  ]
}
There are some known limitations: - Some users have reported that VAPI doesn't always wait for tool_call_result before proceeding - With async settings, the client might return a default 'Success' message - For Realtime API, requests might proceed with a placeholder message that a tool result is still pending You're right that this might need better native support from VAPI, as several users have reported similar issues in the Discord community. Let me know if you need more specific help with your implementation! Sources: - [Discord conversation about tool call issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342336047589359618) - [VAPI Tools Calling documentation](https://docs.vapi.ai/tools-calling) - [VAPI Changelog](https://docs.vapi.ai/changelog/2025/2/4) - [Discord conversation about async/sync tool calls](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333880245681393756)
s
where should i put ToolMessageStart.blocking = true ??
@Vapi Support Bot
v
I don't have the specific implementation details for where to place
ToolMessageStart.blocking = true
in your code based on the information I found. 🤔 This feature appears to be a recent update mentioned in the [VAPI Changelog](https://docs.vapi.ai/changelog/2025/2/4), but the exact implementation isn't detailed in the information I have access to. I'd recommend: 1. Checking the full changelog documentation for implementation examples 2. Looking at the VAPI tools documentation for more detailed guidance 3. If you're using an SDK, check if there's a specific method or property for setting this configuration Would you like me to try finding more specific information about this implementation detail? Source: - [VAPI Changelog](https://docs.vapi.ai/changelog/2025/2/4)
p
@Solaris could you please provide more specific details in the following format?  To help track down this issue, could you share: - What response you expected to get - What response you actually got instead This would really help us figure out what went wrong!
s
instead of
Copy code
{
  "role": "tool_calls",
  "time": 1741604787317,
  "message": "",
  "toolCalls": [
    {
      "id": "call_2UfxMFreci5XJvIcFVc8ovVR",
      "type": "function",
      "function": {
        "name": "confirmReservationWithEmail",
        "arguments": "{\n  \"date\": \"2025-03-10\",\n  \"time\": \"14:30\",\n  \"email\": \"antoine.marcel@hotmail.fr\",\n  \"lastname\": \"Marcel\",\n  \"firstname\": \"Antoine\",\n  \"people_count\": 2,\n  \"phone_number\": \"\"\n}"
      }
    }
  ],
  "secondsFromStart": 41.882
}
{
  "role": "bot",
  "time": 1741604788313,
  "source": "",
  "endTime": 1741604791453,
  "message": "C'est bon Antoine votre table pour deux personnes est réservée aujourd'hui",
  "duration": 3140,
  "secondsFromStart": 46.34
}
{
  "name": "confirmReservationWithEmail",
  "role": "tool_call_result",
  "time": 1741604789399,
  "result": {
    "result": "Réservation confirmée"
  },
  "toolCallId": "call_2UfxMFreci5XJvIcFVc8ovVR",
  "secondsFromStart": 43.964
}
i would prefer
Copy code
{
  "role": "tool_calls",
  "time": 1741604787317,
  "message": "",
  "toolCalls": [
    {
      "id": "call_2UfxMFreci5XJvIcFVc8ovVR",
      "type": "function",
      "function": {
        "name": "confirmReservationWithEmail",
        "arguments": "{\n  \"date\": \"2025-03-10\",\n  \"time\": \"14:30\",\n  \"email\": \"antoine.marcel@hotmail.fr\",\n  \"lastname\": \"Marcel\",\n  \"firstname\": \"Antoine\",\n  \"people_count\": 2,\n  \"phone_number\": \"\"\n}"
      }
    }
  ],
  "secondsFromStart": 41.882
},
{
  "name": "confirmReservationWithEmail",
  "role": "tool_call_result",
  "time": 1741604789399,
  "result": {
    "result": "Réservation confirmée"
  },
  "toolCallId": "call_2UfxMFreci5XJvIcFVc8ovVR",
  "secondsFromStart": 43.964
}
{
  "role": "bot",
  "time": 1741604788313,
  "source": "",
  "endTime": 1741604791453,
  "message": "C'est bon Antoine votre table pour deux personnes est réservée aujourd'hui",
  "duration": 3140,
  "secondsFromStart": 46.34
}
because sometime he answer before having the result from the tool
p
Try setting the
async
parameter to
false
in your tool configuration to ensure that the AI waits for the
tool_call_result
before responding. This will make your tool calls synchronous and should prevent premature responses. If this doesn’t help, you might want to confirm your server is returning responses correctly, as per the VAPI documentation.