Calls intermittently timing out with silence after...
# support
y
Dear Vapi Team We are experiencing a weird issue, where the agent goes completely silent after a tool call, which eventually leads to the call ending with “Silence timed out” reason. This happens intermittently, and we haven’t been able to find a clear pattern. This has happened multiple times, here are some reference call IDs below: b65aff03-6f70-4152-828d-296cd831def2 ee8fcf75-6f7a-40c4-bb7b-03dfd8e4c26f 486c950e-08be-4008-a980-2903a1ca9df4 Can you please help us understand why this is happening and suggest some ways we can fix it?
v
message has been deleted
@yours truly Hello, Thank you for reaching out and providing the call IDs. I'm sorry to hear about the issue you're experiencing with intermittent silence after a tool call. To assist you better, I'll need to gather some additional information: 1. Could you please specify which tool or API call is being made when the agent goes silent? 2. Are there any specific conditions or steps that precede the silence, such as a particular action by the agent or a response from the user? 3. Is there any additional context or error messages that you've noticed which could help us diagnose the issue? Once I have more details, I'll be able to investigate further and provide you with guidance on how to resolve this problem. If you have any logs or error reports related to these incidents, that would also be very helpful.
You can continue this conversation by mentioning me in the message.
y
1. It happens with both the tools that we use. (custom get_availability and book_appointment tools) 2. Usually the agent will say "give me a moment", which it is configured for when doing a tool call, and then it will go completely silent even after the tool call has returned.
v
Got it. Tagging @User for additional help.
y
Hi @User , any updates?
s
logs
Copy code
🔵 15:14:21:948 CustomLLMRequest Messages:
[
  {
    "role": "assistant",
    "content": "Hi. Is this Johnny?"
  },
  {"role": "user", "content": "Yes."},
...,
  {
    "role": "tool",
    "tool_call_id": "c22e2e14-affb-4956-ad81-0372d6b30d15",
    "content": "Available slots:\n\nThursday, January 9, 2025\n- 6:30\u202fPM - 11:59\u202fPM\n\nFriday, January 10, 2025\n- 12:00\u202fAM - 4:30\u202fPM\n- 5:45\u202fPM - 11:59\u202fPM\n\nSaturday, January 11, 2025\n- 12:00\u202fAM - 4:30\u202fPM\n- 5:45\u202fPM - 11:59\u202fPM\n\nSunday, January 12, 2025\n- 12:00\u202fAM - 11:59\u202fPM\n\nMonday, January 13, 2025\n- 12:00\u202fAM - 4:30\u202fPM\n- 5:45\u202fPM - 11:59\u202fPM\n\nTuesday, January 14, 2025\n- 12:00\u202fAM - 1:30\u202fPM\n- 2:30\u202fPM - 4:30\u202fPM\n- 5:45\u202fPM - 11:59\u202fPM\n\nWednesday, January 15, 2025\n- 12:00\u202fAM - 4:30\u202fPM\n- 5:45\u202fPM - 11:59\u202fPM\n\nThursday, January 16, 2025\n- 12:00\u202fAM - 4:30\u202fPM\n- 5:45\u202fPM - 11:59\u202fPM\n\nFriday, January 17, 2025\n- 12:00\u202fAM - 4:30\u202fPM\n- 5:45\u202fPM - 5:59\u202fPM\n\n When offering available time slots, present them in a brief, natural sentence. For example, instead of listing out every half-hour, say something like: \"We have some openings tomorrow, including slots in the morning, afternoon, and evening. What time range works best for you?\" or \"Would any time between 9 am and 5 pm work for you?\""
  },
  {"role": "user", "content": "Yes."}
]
🔵 15:14:22:574 ElevenLabs (Websocket #undefined) State "undefined" But Received End Token. Punting 0... "" 🔵 15:14:22:574 LLM Stream Complete. Cost: 0 (+0). Prompt: 20184 (+3327). Completion: 22 (+0)
@yours truly I have shared a snippet of the logs. If you look at the timestamp after the tool call, there was no response returned from your side, which led to a silence timeout. You need to check your logs to determine what is causing it to not send a response back to Vapi.
y
Hmm, thanks for the update. Let me check it out and I'll get back to you
Thanks for your help in getting to the bottom of the issue. We have solved it on our end now
s
@yours truly what was the issue, and how did you resolve it?
y
Hi @Shubham Bajaj We noticed that the error happened when the user/assistant roles were not alternating properly, which usually happened after tool calls. This led to an exception, and our proxy code just failed open in such cases, leading to a blank response to vapi. I solved it by adding a little bit of code to ensure that user/assistant roles always alternate, by merging subsequent messages that have the same role together
d
HI there, I am experiencing the exact same problem as you guys. I am just wondering what kind of code can be used to merge subsequent messages that have the same role together? It would be greatly appreciated if you can help us, Thank you. 😆
y
We used something like this
Copy code
js
const mergedMessages = messages.reduce((acc, curr) => {
    if (acc.length === 0) {
        return [curr];
    }

    const lastMessage = acc[acc.length - 1];
    if (lastMessage.role === curr.role) {
        // Combine content of messages with same role
        lastMessage.content = `${lastMessage.content}\n${curr.content}`;
        return acc;
    }

    return [...acc, curr];
}, []);
d
Thank you, we will look into this👍 Thanks for your help!!
5 Views