#Why do I get only user messages but not bot?

6 messages · Page 1 of 1 (latest)

dreamy phoenix
#
export const getThreadMessages = query({
  args: { threadId: v.string() },
  handler: async (ctx, { threadId }) => {
    return await ctx.runQuery(components.agent.messages.getThreadMessages, {
      threadId,
    });
  },
});
narrow bobcat
#

Sorry about that - currently debugging a possible regression - I'm assuming you're on version 0.9.0?

narrow bobcat
#

Try in 0.0.10

dreamy phoenix
#

Works in 0.0.10. Thank you.
I first thought that this is expected behaviour

#

FYI "limit" prop is not available here anymore

    return await ctx.runQuery(components.agent.messages.getThreadMessages, {
      threadId,
      limit: 100,
    });
narrow bobcat
#

Ah yes that API changed to support pagination more easily. e.g.

export const getThreadMessages = query({
  args: { threadId: v.string(), paginationOpts: paginationOptsValidator },
  handler: async (ctx, { threadId, paginationOpts }) => {
    const messages = await ctx.runQuery(
      components.agent.messages.getThreadMessages,
      { threadId, paginationOpts },
    );
    return messages;
  },
});

example: https://github.com/get-convex/agent/blob/main/example/convex/example.ts#L147-L156

So { threadId, paginationOpts: { cursor: null, numItems: 100 } } will do the same now if you're not paginating. Sorry it's more verbose

GitHub

Build AI agents on Convex with persistent chat history - get-convex/agent