#Why getThreadMessages returns only user messages but no bit messages?
4 messages · Page 1 of 1 (latest)
Hi @sacred tapir. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the knowledge sources provided, there's no indication that getThreadMessages would return only user messages and exclude bot messages. The function getThreadMessages should return all messages associated with a given thread ID.
Looking at the code you provided:
export const getThreadMessages = query({
args: { threadId: v.string() },
handler: async (ctx, { threadId }) => {
return await ctx.runQuery(components.agent.messages.getThreadMessages, {
threadId,
});
},
});
This query is simply passing the threadId to the Agent component's getThreadMessages function, which should return all messages in that thread.
According to the documentation, the Agent component stores threads, messages, and steps separately, and you can query them by thread, status, and whether they're tool calls or not AI Agents with Built-in Memory.
If you're only seeing user messages, there could be a few possibilities:
- The bot messages might not have been saved yet (they might be pending)
- There might be filtering happening in the underlying
components.agent.messages.getThreadMessagesimplementation - You might need to configure the agent to save bot messages
You can try specifying additional options when fetching messages, such as:
return await ctx.runQuery(
components.agent.messages.getThreadMessages,
{ threadId, limit: 100 }
);
Also, check your agent configuration to ensure saveOutputMessages is set to true (which is the default):
const supportAgent = new Agent(components.agent, {
// other options...
storageOptions: {
saveAllInputMessages: false, // default
saveOutputMessages: true, // default
},
});