You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current Issue: I'm experiencing multiple identical tool calls being sent to my backend API during a single conversation. My backend receives repeated calls with the same parameters throughout a conversation, leading to duplicate processing.
The issue here is on each message it sends call to my backend that causes tools calls duplication if we have something in configuration the agent only send req to api call when a tool the functions we provide to that agent configuration is called or how can i manage this
`import { CreateAssistantDTO } from "@vapi-ai/web/dist/api";
export const characterAssistant: CreateAssistantDTO = {
name: "Mohammad",
model: {
provider: "openai",
model: "gpt-3.5-turbo",
temperature: 0.7,
messages: [
{
role: "system",
content: "You are a helpful, polite restaurant assistant named Mohammad for a premium Middle Eastern dining restaurant called Khayal. Handle guest interactions professionally in both English (EN) and Arabic (AR), including table reservations, order placement, and menu navigation. If the user speaks Arabic, respond in Arabic. If the user speaks English, respond in English. Always provide clear options and summarize selections. If unsure, ask clarifying questions. You should use the makeReservation function when a customer wants to book a table, the addToOrder function when they want to order food, and the checkAvailability function to verify if tables are available for specific dates and times."
}
],
tools: [
{
type: "function",
function: {
name: "makeReservation",
description: "Books a table reservation for customers at the restaurant",
parameters: {
type: "object",
properties: {
guestCount: {
type: "number",
description: "Number of guests for the reservation",
},
date: {
type: "string",
description: "Date of the reservation (YYYY-MM-DD format)",
},
time: {
type: "string",
description: "Time of the reservation (HH:MM format)",
},
name: {
type: "string",
description: "Name under which the reservation is made",
},
phoneNumber: {
type: "string",
description: "Contact phone number for the reservation",
},
specialRequests: {
type: "string",
description: "Any special requests for the reservation",
},
},
required: ["guestCount", "date", "time", "name", "phoneNumber"],
},
},
async: false
},
{
type: "function",
function: {
name: "addToOrder",
description: "Adds items to a customer's order",
parameters: {
type: "object",
properties: {
items: {
type: "array",
items: {
type: "object",
properties: {
name: {
type: "string",
description: "Name of the menu item",
},
quantity: {
type: "number",
description: "Quantity of the item",
},
specialInstructions: {
type: "string",
description: "Special instructions for preparing the item",
},
},
required: ["name", "quantity"],
},
description: "List of items to add to the order",
},
},
required: ["items"],
},
},
async: false
},
{
type: "function",
function: {
name: "checkAvailability",
description: "Checks if tables are available for a specific date and time",
parameters: {
type: "object",
properties: {
guestCount: {
type: "number",
description: "Number of guests",
},
date: {
type: "string",
description: "Date to check availability (YYYY-MM-DD format)",
},
time: {
type: "string",
description: "Time to check availability (HH:MM format)",
},
},
required: ["guestCount", "date", "time"],
},
},
async: false
}
],
},
// Move idle messages to messagePlan instead of the root-level messages property
messagePlan: {
idleMessages: [
"Please wait while I process your request...",
"I'm checking our system for that information...",
"Just a moment while I update our records..."
],
idleMessageMaxSpokenCount: 1,
idleTimeoutSeconds: 5
},
voice: {
provider: "11labs",
voiceId: "paula",
},
firstMessage: "Thank you for calling Khayal Restaurant. This is Mohammad, your Arabic and English scheduling assistant. How may I help you today?",
};
`
The Problem: While this manual caching works somewhat, I have several concerns:
This feels like a workaround rather than the right solution
I'm not sure if 6 seconds is the right deduplication window
The manual cache management is not ideal and could lead to memory issues
I shouldn't need to handle this level of deduplication on my backend
My Configuration: I've configured my agent to call my backend tools at http://localhost:3000/api/tools and implemented handlers for various tool functions (makeReservation, addToOrder, checkAvailability). The agent correctly formats and sends tool calls, but I'm receiving duplicate requests.
Questions:
How can i configure in some way so my backend is only called when a tool is called?
You can ignore these caching things i have mentioned if those are unrelated.
Is there a configuration setting to prevent the agent from sending duplicate tool calls?
Is there a recommended backend approach for handling this situation that doesn't require manual caching?
Is this expected behavior, and if so, what's the recommended pattern for backend implementation?
Could this be related to how I'm responding to tool calls?
can we have a sample configuration of a sample node js server and agent config as well
The text was updated successfully, but these errors were encountered:
Current Issue: I'm experiencing multiple identical tool calls being sent to my backend API during a single conversation. My backend receives repeated calls with the same parameters throughout a conversation, leading to duplicate processing.
The issue here is on each message it sends call to my backend that causes tools calls duplication if we have something in configuration the agent only send req to api call when a tool the functions we provide to that agent configuration is called or how can i manage this
`app.post('/api/tools', async (req, res) => {
try {
logger.info('POST /api/tools endpoint called');
} catch (error) {
logger.error('Error processing tool call', { error: error.message, stack: error.stack });
// Send a properly formatted response even on error
res.json({
results: [{
toolCallId: req.body.toolCallId || "unknown",
result: JSON.stringify({
status: 'error',
message: error.message
})
}]
});
}
});`
`import { CreateAssistantDTO } from "@vapi-ai/web/dist/api";
export const characterAssistant: CreateAssistantDTO = {
name: "Mohammad",
model: {
provider: "openai",
model: "gpt-3.5-turbo",
temperature: 0.7,
messages: [
{
role: "system",
content: "You are a helpful, polite restaurant assistant named Mohammad for a premium Middle Eastern dining restaurant called Khayal. Handle guest interactions professionally in both English (EN) and Arabic (AR), including table reservations, order placement, and menu navigation. If the user speaks Arabic, respond in Arabic. If the user speaks English, respond in English. Always provide clear options and summarize selections. If unsure, ask clarifying questions. You should use the makeReservation function when a customer wants to book a table, the addToOrder function when they want to order food, and the checkAvailability function to verify if tables are available for specific dates and times."
}
],
tools: [
{
type: "function",
function: {
name: "makeReservation",
description: "Books a table reservation for customers at the restaurant",
parameters: {
type: "object",
properties: {
guestCount: {
type: "number",
description: "Number of guests for the reservation",
},
date: {
type: "string",
description: "Date of the reservation (YYYY-MM-DD format)",
},
time: {
type: "string",
description: "Time of the reservation (HH:MM format)",
},
name: {
type: "string",
description: "Name under which the reservation is made",
},
phoneNumber: {
type: "string",
description: "Contact phone number for the reservation",
},
specialRequests: {
type: "string",
description: "Any special requests for the reservation",
},
},
required: ["guestCount", "date", "time", "name", "phoneNumber"],
},
},
async: false
},
{
type: "function",
function: {
name: "addToOrder",
description: "Adds items to a customer's order",
parameters: {
type: "object",
properties: {
items: {
type: "array",
items: {
type: "object",
properties: {
name: {
type: "string",
description: "Name of the menu item",
},
quantity: {
type: "number",
description: "Quantity of the item",
},
specialInstructions: {
type: "string",
description: "Special instructions for preparing the item",
},
},
required: ["name", "quantity"],
},
description: "List of items to add to the order",
},
},
required: ["items"],
},
},
async: false
},
{
type: "function",
function: {
name: "checkAvailability",
description: "Checks if tables are available for a specific date and time",
parameters: {
type: "object",
properties: {
guestCount: {
type: "number",
description: "Number of guests",
},
date: {
type: "string",
description: "Date to check availability (YYYY-MM-DD format)",
},
time: {
type: "string",
description: "Time to check availability (HH:MM format)",
},
},
required: ["guestCount", "date", "time"],
},
},
async: false
}
],
},
// Add server configuration for function handling
server: {
url: "https://1dd0-2a09-bac1-5b20-28-00-19b-fe.ngrok-free.app/api/tools",
timeoutSeconds: 20,
secret: "mock-secret-key"
},
serverUrl: "https://1dd0-2a09-bac1-5b20-28-00-19b-fe.ngrok-free.app/api/tools",
serverUrlSecret:"mock",
// Move idle messages to messagePlan instead of the root-level messages property
messagePlan: {
idleMessages: [
"Please wait while I process your request...",
"I'm checking our system for that information...",
"Just a moment while I update our records..."
],
idleMessageMaxSpokenCount: 1,
idleTimeoutSeconds: 5
},
voice: {
provider: "11labs",
voiceId: "paula",
},
firstMessage: "Thank you for calling Khayal Restaurant. This is Mohammad, your Arabic and English scheduling assistant. How may I help you today?",
};
`
The Problem: While this manual caching works somewhat, I have several concerns:
This feels like a workaround rather than the right solution
I'm not sure if 6 seconds is the right deduplication window
The manual cache management is not ideal and could lead to memory issues
I shouldn't need to handle this level of deduplication on my backend
My Configuration: I've configured my agent to call my backend tools at http://localhost:3000/api/tools and implemented handlers for various tool functions (makeReservation, addToOrder, checkAvailability). The agent correctly formats and sends tool calls, but I'm receiving duplicate requests.
Questions:
How can i configure in some way so my backend is only called when a tool is called?
You can ignore these caching things i have mentioned if those are unrelated.
Is there a configuration setting to prevent the agent from sending duplicate tool calls?
Is there a recommended backend approach for handling this situation that doesn't require manual caching?
Is this expected behavior, and if so, what's the recommended pattern for backend implementation?
Could this be related to how I'm responding to tool calls?
can we have a sample configuration of a sample node js server and agent config as well
The text was updated successfully, but these errors were encountered: