shivam
05/02/2025, 10:22 AM// Spec of query tool being created
{
"type": "query",
"function": {
"name": "kb_query_for_{{sessionId}}",
"description": "use this tool whenever you need info from user's recent activity"
},
"knowledgeBases": [
{
"provider": "google",
"model": "gemini-1.5-flash",
"name": "activity_for_user_{{sessionId}}",
"description": "Use this KB for questions about user's recent activity",
"fileIds": [
"{{fileId}}"
]
}
]
}
- On assistant startup, I inject that tool’s ID into the session so that the current conversation has the user's data available as a tool and it can query any information user requests.
const token = //from backend API
const knowledgeBaseToolId = //from backend API
// Vapi init
const vapi = new Vapi(token);
// FOR CONNECTING WITH ASSISTANCE
const assistantOverrides: AssistantOverrides = {
model: {
provider: "openai",
model: "gpt-4.1",
temperature: 0.7,
toolIds: [knowledgeBaseToolId!]
},
silenceTimeoutSeconds: 60
};
const resp = await vapi.start(assistantId!, assistantOverrides);
The calls are connecting properly but there's something amiss. The assistant should automatically invoke the QueryKB tool whenever the user asks about their personal data, and incorporate the returned facts into its response. Despite the tool being available, the assistant never seems to call it—or returns empty or irrelevant answers. What configuration or prompt‐engineering steps might be missing or misordered? Would be great if someone can help.Vapi Support Bot
05/02/2025, 10:24 AMshivam
05/02/2025, 10:29 AMVapi Support Bot
05/02/2025, 10:31 AMYou are an assistant with access to the user's activity data. When asked about the user's recent activities, ALWAYS use the kb_query_for_{{sessionId}} tool to retrieve this information. If the answer isn't in the knowledge base, say "I don't have that information." Always cite the knowledge base when providing information from it.
This explicit instruction with the exact tool name and clear usage conditions will help ensure the tool gets invoked appropriately.
Sources:
- [Discord conversation about explicit KB instructions](https://discord.com/channels/1211482211119796234/1335953119275782144)
- [Discord conversation about system prompt examples](https://discord.com/channels/1211482211119796234/1334889552002809928)Vapi Support Bot
05/02/2025, 10:56 AMChiranjeet Mishra
05/02/2025, 9:02 PMshivam
05/05/2025, 3:37 AMChiranjeet Mishra
05/05/2025, 11:04 PMEthan Tan
05/08/2025, 10:41 AM