Function: loadHistory()
loadHistory(
opts):Promise<{hasMore:boolean;page:number;perPage:number;total:number;uiMessages:object[]; }>
Fetch a page of UI-formatted messages for a thread.
Uses the agent’s resolved Memory (getMemory()) so per-agent
storage namespaces (mastra_<agentId> schemas) and any future
memory-side filters apply automatically. When the agent has no
memory configured the response is a successful empty page so
callers don’t have to special-case stateless agents.
Pagination is descending-by-default: page 0 is the most recent
page, page 1 the page before that, etc. The returned uiMessages
are always re-sorted into chronological order (oldest -> newest)
so the client can prepend them above the existing transcript
without sorting locally.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<{ hasMore: boolean; page: number; perPage: number; total: number; uiMessages: object[]; }>