Urgent - Need Support for Sequential Tool Calls Wi...
# support
s
Hi @Vapi Team, I'm implementing a voice assistant that follows a strict multi-step lifecycle to handle user requests: - validate_user_request - plan_user_request - judge_user_request_plan - modify_user_request_plan (only if needed) - execute_user_request_plan Each step is defined as a separate tool. The goal is for the assistant to automatically trigger the next step in sequence as soon as the previous tool call completes, without waiting for additional user input or confirmation. Currently, the assistant executes only the first tool (validate_user_request), then waits for the user to speak again before continuing — which breaks the intended flow. Is there a way to enable true sequential tool execution based on tool responses, or any workaround you recommend?
v
Hi there! 👋 I understand you're trying to implement a sequential tool execution flow without requiring user input between steps. This is definitely a challenge many Vapi users face! While I don't have specific information about your custom tools (validate_user_request, plan_user_request, etc.), I can help with implementing sequential tool execution in Vapi. Here are several approaches you can try: ### 1. Configure Tools as Synchronous Ensure your tools are set to synchronous rather than asynchronous execution:
Copy code
javascript
const tool = {
  type: "function",
  async: false, // Set to false for synchronous execution
  function: {
    // your function definition
  }
};
According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342315282198298729), setting tools to synchronous mode can help maintain sequential order. ### 2. Ensure Correct Response Formatting The tool call response format is critical for sequential execution. Make sure your responses are: - Strings without line breaks - If using JSON, properly stringified - Include the tool call ID in the response As noted in [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342315282198298729), incorrect formatting can prevent the next tool from triggering. ### 3. Server-Side Logic for Tool Chaining Modify your server-side logic to trigger the next tool based on the current tool's result. Instead of simply returning a result, have your endpoint trigger the next tool call in the sequence according to [Vapi documentation](https://docs.vapi.ai/documentation/advanced-concepts/customization/custom-llm/custom-llm-tool-calling-integration). ### 4. Consider Using Make.com Integration You could leverage Vapi's integration with Make.com to manage the workflow and trigger subsequent tools based on previous tool responses, as mentioned in [Vapi's documentation](https://docs.vapi.ai/tools/GHL).
### 5. Custom LLM Tool Implementation Include your tools in custom LLM tools and send a "done stream" back to Vapi with the function name when the model requests them, as suggested in [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339871158975336498). ### 6. Adjust Conversational Design Design your conversation flow to move seamlessly from one step to the next without explicit confirmation, assuming success and continuing unless an error is encountered, as recommended in [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334309208035954728). ### Known Limitations to Watch For: - Variable passing issues between tool calls - Concurrency limits that can disrupt sequential execution - The model might speak the tool call code instead of executing it - The assistant might go silent after a tool call Would you like me to elaborate on any of these approaches or help troubleshoot a specific implementation you're trying? Sources: - [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342315282198298729) - [Vapi documentation](https://docs.vapi.ai/documentation/advanced-concepts/customization/custom-llm/custom-llm-tool-calling-integration) - [Vapi's documentation](https://docs.vapi.ai/tools/GHL) - [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339871158975336498) - [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334309208035954728)
s
@Vapi Support Bot elaborate for Server-Side Logic for Tool Chaining
v
Hi there! 👋 I don't have detailed implementation specifics for server-side logic for tool chaining, but I can elaborate on the general approach based on the information I have. ### Server-Side Logic for Tool Chaining The core idea behind server-side logic for tool chaining is to implement a custom handling mechanism on your server that manages the sequential execution of tools. Here's how you might approach this: #### 1. Implement a Transformer Function According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338507206051627073), you'll need to "implement an extra function on your own server to transform the payload." This transformer function would: - Receive the initial tool call from Vapi - Process the request and generate a response - Determine which tool should be called next in your sequence - Either trigger the next tool directly or format the response in a way that prompts Vapi to call the next tool #### 2. Response Formatting for Sequential Execution Ensure your tool responses follow the exact JSON format expected by Vapi:
Copy code
json
{
    "results": [{
        "toolCallId": "message.toolCalls[].id",
        "result": "Your result data here"
    }]
}
The correct formatting is crucial for Vapi to properly interpret the output and potentially trigger the next tool in the sequence. #### 3. Managing Tool State and Flow You'll need to maintain state between tool calls to track where you are in your sequence (validate_user_request → plan_user_request → judge_user_request_plan, etc.). This could be implemented as: - A state machine on your server that tracks the current step - A context object that's passed between tool calls - Custom logic that determines the next step based on the output of the current step #### 4. Consider Using Make.com as an Integration Point
As mentioned in [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341823020469321739), some users have solved similar problems by using Make.com as an intermediary: "The workflow can interact with Make.com using the API Request Node. You can make direct API calls to Make.com scenarios." This approach could potentially provide more control over the flow between tools. Would you like me to focus on any particular aspect of server-side logic for tool chaining, or would you prefer information about the other approaches mentioned previously? Sources: - [Discord discussions on transformer functions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338507206051627073) - [Discord discussions on Make.com integration](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341823020469321739)
v
Message marked as helpful by @Pratyush Ranjan! 🎉
s
@Vapi Support Bot can you check this file contains the tools i am passing to my assistant can you check and tell me any modifications to achieve what i want https://cdn.discordapp.com/attachments/1359052773231952003/1359061741429854338/message.txt?ex=67f61c61&is=67f4cae1&hm=b6baf3ec8e960d94dde90910bbfb0dc97cd4170f69196f81f0016d2b00a58a5b&
@Shubham Bajaj can you help me out here ?
s
Hey Sahil, You can either do all other tools calling on your server in a step-by-step sequential execution manner or you can use live call control to trigger the next tool once one of your initial tools is triggered. I highly recommend going with the first approach. As of now, we don't have the option to sequentially execute a set of tools, but you can always raise a feature request for it. You can raise an feature request for it over here: https://roadmap.vapi.ai
s
Hi shubham thanks for adressing the issue i have one question if i execute tools on my server in a step-by-step then will i be able to update the user after completion of each tool ? (with specified messages)
s
Using Live Call Control and under this server timeout (seconds), yes you can achieve the same.