MastraM
Mastra8mo ago
vz

@mastra/core 0.9.3 breaks the tool

Getting the following error with version 0.9.3.
Error in /api/ai/chat:  Error: HTTP error! status: 500 - {"error":"Cannot read properties of undefined (reading 'shape')"}
    at async POST$1 (webpack-internal:/(rsc)/src/app/api/ai/chat/src/app/api/ai/chat/route.ts:21:19)
  19 |     // runtimeContext.set("sandboxId", sandboxId);
  20 |
> 21 |     const stream = await agent.stream({
     |                   ^
  22 |       // Sending only the last message:
  23 |       //https://mastra.ai/en/examples/memory/use-chat#preventing-message-duplication-with-usechat
  24 |       messages: messages.slice(-1),
 POST /api/ai/chat 500 in 1206ms


If i remove tools from the agent, it works all fine. Downgrading to 0.9.2 is also fine.

My tools are created in the following fashion:
import { createTool } from "@mastra/core/tools";
export const xxxTool = createTool({
  id: xxxxxx
  description:
    "xxxxxx",
  inputSchema: z.object({
    path: z
      .string()
      .describe(
        "Path to the file ",
      ),
  }),
  outputSchema: z.object({
    success: z.boolean(),
    error: z.string().optional().describe("Error message if deletion failed"),
  }),
  execute: async ({ context, runtimeContext }) => {
    xxxxxx
});
Was this page helpful?