Using @convex-dev/agent@0.6.1
I have an agent configured with:
contextOptions: {
searchOtherThreads: true,
searchOptions: {
limit: 10,
textSearch: true,
},
}
and my contextHandler includes args.search.
Expected: a new thread should be able to retrieve matching messages from older threads with the same stored userId.
Actual: direct text search finds the old matching messages, but they get filtered out when the new thread’s current message has a lower order.
Example:
- New thread prompt:
what do you remember about high-ticket coaches
- Old thread message:
tom and jerry are both amazing high-ticket coaches and educators...
Both threads have the same userId.
Raw text_search returns the old message.
But the agent context search returns no cross-thread match.
It looks like the “only include messages before targetMessageId” filter compares order across different threads. That makes sense within one thread, but not across threads where the search results could be used in order 0 or 1 even though in other threads they may have been order 100.
Files affected
Potential fix
When searchAllMessagesForUserId is set, only apply the targetMessageId order filter to messages from the same threadId.
Using
@convex-dev/agent@0.6.1I have an agent configured with:
and my contextHandler includes
args.search.Expected: a new thread should be able to retrieve matching messages from older threads with the same stored
userId.Actual: direct text search finds the old matching messages, but they get filtered out when the new thread’s current message has a lower order.
Example:
what do you remember about high-ticket coachestom and jerry are both amazing high-ticket coaches and educators...Both threads have the same
userId.Raw
text_searchreturns the old message.But the agent context search returns no cross-thread match.
It looks like the “only include messages before
targetMessageId” filter compares order across different threads. That makes sense within one thread, but not across threads where the search results could be used in order 0 or 1 even though in other threads they may have been order 100.Files affected
src/component/messages.tstextSearchfilters results usingtargetMessage.order.src/client/search.tspasses
targetMessageIdintosearchMessageswhile also usingsearchOtherThreads.Potential fix
When
searchAllMessagesForUserIdis set, only apply thetargetMessageIdorder filter to messages from the samethreadId.