Using createVectorQueryTool in agent configuration throwing TS Error

Hey, I'm using the latest mastra packages and trying to add a vector tool to the agent, but this is throwing a Zod error:
Type 'RagTool<ZodObject<{ filter: ZodString; queryText: ZodString; topK: ZodNumber; }, "strip", ZodTypeAny, { filter: string; topK: number; queryText: string; }, { ...; }> | ZodObject<...>, any>' is not assignable to type 'ToolAction<any, any, any, any, ToolExecutionContext<any, any, any>> | VercelTool | VercelToolV5'.
[deleted]
Types of property 'inputSchema' are incompatible.
Type 'ZodObject<{ filter: ZodString; queryText: ZodString; topK: ZodNumber; }, "strip", ZodTypeAny, { filter: string; topK: number; queryText: string; }, { ...; }> | ZodObject<...> | undefined' is not assignable to type 'FlexibleSchema<any>'.
Type 'undefined' is not assignable to type 'FlexibleSchema<any>'
Type 'RagTool<ZodObject<{ filter: ZodString; queryText: ZodString; topK: ZodNumber; }, "strip", ZodTypeAny, { filter: string; topK: number; queryText: string; }, { ...; }> | ZodObject<...>, any>' is not assignable to type 'ToolAction<any, any, any, any, ToolExecutionContext<any, any, any>> | VercelTool | VercelToolV5'.
[deleted]
Types of property 'inputSchema' are incompatible.
Type 'ZodObject<{ filter: ZodString; queryText: ZodString; topK: ZodNumber; }, "strip", ZodTypeAny, { filter: string; topK: number; queryText: string; }, { ...; }> | ZodObject<...> | undefined' is not assignable to type 'FlexibleSchema<any>'.
Type 'undefined' is not assignable to type 'FlexibleSchema<any>'
Code:
tools: {
organizationDetailsTool,
searchOrganizationsTool,
pgVectorQueryTool,
},
tools: {
organizationDetailsTool,
searchOrganizationsTool,
pgVectorQueryTool,
},
Tool definition
import { INDEX_NAME, pgVector } from "@/mastra/vectors/db-config";
import { openai } from "@ai-sdk/openai";
import { createVectorQueryTool } from "@mastra/rag";

export const pgVectorQueryTool = createVectorQueryTool({
indexName: INDEX_NAME,
model: openai.embedding("text-embedding-3-small"),
vectorStore: pgVector,
enableFilter: true,
includeSources: true,
databaseConfig: {
pgvector: {
minScore: 0.4, // Filter low-quality results
},
},
});
import { INDEX_NAME, pgVector } from "@/mastra/vectors/db-config";
import { openai } from "@ai-sdk/openai";
import { createVectorQueryTool } from "@mastra/rag";

export const pgVectorQueryTool = createVectorQueryTool({
indexName: INDEX_NAME,
model: openai.embedding("text-embedding-3-small"),
vectorStore: pgVector,
enableFilter: true,
includeSources: true,
databaseConfig: {
pgvector: {
minScore: 0.4, // Filter low-quality results
},
},
});
package.json
"@mastra/ai-sdk": "^0.2.5",
"@mastra/client-js": "^0.16.8",
"@mastra/core": "^0.23.3",
"@mastra/langfuse": "0.2.2",
"@mastra/libsql": "^0.16.1",
"@mastra/loggers": "^0.10.18",
"@mastra/memory": "^0.15.10",
"@mastra/observability": "^0.0.4",
"@mastra/pg": "^0.17.7",
"@mastra/rag": "^1.3.3",
"@mastra/ai-sdk": "^0.2.5",
"@mastra/client-js": "^0.16.8",
"@mastra/core": "^0.23.3",
"@mastra/langfuse": "0.2.2",
"@mastra/libsql": "^0.16.1",
"@mastra/loggers": "^0.10.18",
"@mastra/memory": "^0.15.10",
"@mastra/observability": "^0.0.4",
"@mastra/pg": "^0.17.7",
"@mastra/rag": "^1.3.3",
documentation: https://mastra.ai/en/examples/rag/usage/filter-rag#vector-query-tool-creation
Example: Agent-Driven Metadata Filtering | Retrieval | RAG | Mastra...
Example of using a Mastra agent in a RAG system to construct and apply metadata filters for document retrieval.
1 Reply
Mastra Triager
GitHub
[DISCORD:1433425201961500712] Using createVectorQueryTool in agent ...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1433425201961500712 Hey, I&#39;m using the latest mastra packages and trying to add a vector tool to the a...

Did you find this page helpful?