import { createTool } from '@mastra/core';
import { z } from 'zod';
// Schema with nested partial object
const inputSchema = z.object({
eventId: z.string(),
request: z.object({
City: z.string(),
Name: z.string(),
Slug: z.string(),
}).partial().passthrough(),
eventImageFile: z.any().optional()
});
// This validates successfully:
const testData = {
eventId: '123',
request: { Name: 'Test' }, // Only providing one field
eventImageFile: null
};
console.log(inputSchema.safeParse(testData).success); // :white_check_mark: true
// But when passed to Mastra:
const tool = createTool({
id: 'updateEvent',
description: 'Update event',
inputSchema,
execute: async (input) => {
return { success: true };
}
});
// LLM calls with: { eventId: '123', request: { Name: 'Test' }, eventImageFile: null }
// :x: Mastra validation fails with:
// Tool input validation failed for 'updateEvent'
// errors: {
// request: {
// City: { _errors: ['Invalid input: expected string, received undefined'] },
// Slug: { _errors: ['Invalid input: expected string, received undefined'] },
// }
// }
import { createTool } from '@mastra/core';
import { z } from 'zod';
// Schema with nested partial object
const inputSchema = z.object({
eventId: z.string(),
request: z.object({
City: z.string(),
Name: z.string(),
Slug: z.string(),
}).partial().passthrough(),
eventImageFile: z.any().optional()
});
// This validates successfully:
const testData = {
eventId: '123',
request: { Name: 'Test' }, // Only providing one field
eventImageFile: null
};
console.log(inputSchema.safeParse(testData).success); // :white_check_mark: true
// But when passed to Mastra:
const tool = createTool({
id: 'updateEvent',
description: 'Update event',
inputSchema,
execute: async (input) => {
return { success: true };
}
});
// LLM calls with: { eventId: '123', request: { Name: 'Test' }, eventImageFile: null }
// :x: Mastra validation fails with:
// Tool input validation failed for 'updateEvent'
// errors: {
// request: {
// City: { _errors: ['Invalid input: expected string, received undefined'] },
// Slug: { _errors: ['Invalid input: expected string, received undefined'] },
// }
// }