Chris
Chris6d ago

Inconsistent behavior with Convex Agent Text & Vector Search

When I try to search for messages using the generate text or stream text functions, I receive an error stating that there are no messages to search. However, when I call the fetch context message function, I can search for messages. I'm wondering what's going on or what I might be missing. Error --[Error: No messages to search]
const stream = createUIMessageStream({
execute: async ({ writer }) => {
try {
const result = await thread.streamText(
{ ...streamTextConfig },
{
saveStreamDeltas: true,
contextOptions: {
searchOptions: {
// textSearch: true,
vectorSearch: true,
limit: 10,
},
searchOtherThreads: true,
},
}
);
// console.log(await result.steps);
writer.merge(result.toUIMessageStream({ originalMessages: [] }));
} catch (error) {
console.log("Something went wrong");
console.error(error);
}
},
});
const stream = createUIMessageStream({
execute: async ({ writer }) => {
try {
const result = await thread.streamText(
{ ...streamTextConfig },
{
saveStreamDeltas: true,
contextOptions: {
searchOptions: {
// textSearch: true,
vectorSearch: true,
limit: 10,
},
searchOtherThreads: true,
},
}
);
// console.log(await result.steps);
writer.merge(result.toUIMessageStream({ originalMessages: [] }));
} catch (error) {
console.log("Something went wrong");
console.error(error);
}
},
});
But this fetches the messages:
const messages: MessageDoc[] = await agent.fetchContextMessages(ctx, {
threadId,
messages: [{ role: "user", content: args.input.prompt }],
userId, // Optional, unless `searchOtherThreads` is true.
contextOptions: {
searchOptions: {
vectorSearch: true,
limit: 10,
},
searchOtherThreads: true,
},
});
const messages: MessageDoc[] = await agent.fetchContextMessages(ctx, {
threadId,
messages: [{ role: "user", content: args.input.prompt }],
userId, // Optional, unless `searchOtherThreads` is true.
contextOptions: {
searchOptions: {
vectorSearch: true,
limit: 10,
},
searchOtherThreads: true,
},
});
1 Reply
Convex Bot
Convex Bot6d 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!

Did you find this page helpful?