Custom Tool not picking up tool failure
# support
l
Call id: 7ccb1e13-b4b8-4c95-9c9e-9d9b7eeb54c2 As you can see, my assistant wrongly said the "request-complete" message even though the request failed. we ended up getting a tool call result like this: { "name": "place_order", "role": "tool_call_result", "time": 1747689324398, "result": "Error: Failed to add order (forced failure for testing)", "metadata": {}, "toolCallId": "call_PkVjPULo9vPHH5Q8tIfNfLyg", "secondsFromStart": 22.109 } Is there a way to mark the request as failed? Is this tool call result not the right way to do it?
v
To ensure your assistant says the correct failure message, update your tool's configuration to include a
request-failed
message type, like this:
Copy code
json
"messages": [
  { "type": "request-complete", "content": "Order placed successfully." },
  { "type": "request-failed", "content": "Sorry, there was a problem placing your order." }
]
Then, adjust your server logic so that when an error occurs, the result is structured in a way that triggers the
request-failed
path (e.g., by returning a recognizable error string or object). This helps the assistant pick up failures correctly. [See documentation for details](https://docs.vapi.ai/tools/custom-tools#adapting-the-payload-for-your-needs) Source: - [Custom Tools – Adapting the Payload for Your Needs](https://docs.vapi.ai/tools/custom-tools#adapting-the-payload-for-your-needs)
l
I did that already. request complete, request start both work. but it doenst recognize request failed. is that something my tool must return? "messages": [ { "type": "request-start", "content": "One moment while I place your order..." }, { "type": "request-complete", "content": "I've sent your order to the kitchen. It will be ready in around 30 minutes." }, { "type": "request-failed", "content": "I apologize, but I'm having trouble placing your order right now. Would you like me to try again?" }, { "type": "request-response-delayed", "content": "It's taking a moment to process your order. Please hold on...", "timingMilliseconds": 2000 } ] } ],
Or do I have to say async = false. Is async = true by default?
Because async is already false for my functions...
a
Remove the request-complete part and then set async = false. It will work.
l
What do you mean
async is already false. If I remove request-complete, wouldn't it not say anything if the tool call is successful?
a
Hi Liamdu, For your failed tool call to properly trigger the "request-failed" message, return this structure: { "results": \[{ "name": "place_order", "toolCallId": "call_PkVjPULo9vPHH5Q8tIfNfLyg", "error": "Failed to add order (forced failure for testing)" }\] } The key difference from your current implementation is: 1\. Wrap your tool result in a
results
array 2\. Use the
error
field instead of
result
for error messages Your message configuration is correct - this change in response format will ensure the appropriate "request-failed" message is triggered.
Vapi determines whether to use the "request-failed" message by looking for the presence of an error field in the tool call result, not by analyzing the content of the result field. When no error field is present, Vapi treats it as a successful call and uses the "request-complete" message.