DaddyIsHereD
Convex Communityβ€’5mo agoβ€’
2 replies
DaddyIsHere

thread.`generateText/streamText` returns a validator error

Heya guys, I'm new! I am building a small chat app with Convex Agents and I've encountered an error that I don't seem to be able to solve:

const response = await thread.generateText(
  {
    prompt: `# From Notes:\n\n ${contextText}\n\n---\n\n# User Prompt:\n\n"""${message}\n"""`,
  },
);

OR
const response = await thread.streamText(
    {
        prompt: `# From Notes:\n\n ${contextText}\n\n---\n\n# User Prompt:\n\n"""${message}\n"""`,
    },
    {
        saveStreamDeltas: true, // PROBLEMATIC LINE
    },
);
await response.consumeStream();


These functions (even with just {message} and not the whole prompt) are giving me the errors in the screenshots, ONLY if I actually save the message in the database. If I pass saveMessages: "none" and/or saveStreamDeltas: false the problem goes away (but streaming doesn't work and the whole flow is generally slower).

Can you help me understand what the problem is? πŸ™πŸ½
(I can give you more context if needed!)
CleanShot_2025-08-19_at_00.50.34.png
CleanShot_2025-08-19_at_00.50.54.png
Was this page helpful?