AI Agent: generateObject no longer working with schema

I have this action that uses an AI Agent:
export const generateEvent = action({
args: { input: v.string() },
handler: async (ctx, { input }): Promise<schemas.EventDetails> => {
const { thread } = await eventGenerationAgent.createThread(ctx);
const result = await thread.generateObject({
prompt: input,
schema: schemas.eventSchema
});
console.log(result);
return agent.handleEventGenerationResponse({ result: result.object });
},
});
export const generateEvent = action({
args: { input: v.string() },
handler: async (ctx, { input }): Promise<schemas.EventDetails> => {
const { thread } = await eventGenerationAgent.createThread(ctx);
const result = await thread.generateObject({
prompt: input,
schema: schemas.eventSchema
});
console.log(result);
return agent.handleEventGenerationResponse({ result: result.object });
},
});
And here is the prompt:
export const eventGenerationPrompt = `
You are an event details parser.
The current date is ${new Date().toLocaleDateString('en-GB', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}.
Extract event information from the user's input and format it as a JSON object with the following structure:
{
"title": "string - The event title",
"description": "string - A detailed description of the event",
"category": "string - Must be one of: 'Meetup', 'Workshop', 'Network', 'Social', 'Other'",
"eventStart": "string - ISO date format (YYYY-MM-DDTHH:mm:ss)",
"eventEnd": "string - ISO date format (YYYY-MM-DDTHH:mm:ss)",
"spaces": "number - Maximum number of participants allowed"
}

Ensure all dates are in ISO format and the category matches one of the allowed values exactly.
If you cannot determine any of the fields, put them as null.`;
export const eventGenerationPrompt = `
You are an event details parser.
The current date is ${new Date().toLocaleDateString('en-GB', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}.
Extract event information from the user's input and format it as a JSON object with the following structure:
{
"title": "string - The event title",
"description": "string - A detailed description of the event",
"category": "string - Must be one of: 'Meetup', 'Workshop', 'Network', 'Social', 'Other'",
"eventStart": "string - ISO date format (YYYY-MM-DDTHH:mm:ss)",
"eventEnd": "string - ISO date format (YYYY-MM-DDTHH:mm:ss)",
"spaces": "number - Maximum number of participants allowed"
}

Ensure all dates are in ISO format and the category matches one of the allowed values exactly.
If you cannot determine any of the fields, put them as null.`;
When I run the action with this input:
{
input: "I want to host a coding club with 20 members",
}
{
input: "I want to host a coding club with 20 members",
}
I get an error (see text file of next message). I did not used to get this error which makes me think that OpenAI maybe changed their return format to include 'content', 'id' and 'role', but not too sure.
3 Replies
Convex Bot
Convex Bot3mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Uzi (ꏿ﹏ꏿ;)
Uzi (ꏿ﹏ꏿ;)OP3mo ago
Included the error in this text file because of character limits
erquhart
erquhart2mo ago
The message has a string uuid under id property, which isn't in your validator.

Did you find this page helpful?