fromAgUiMessages still splits a turn whose prose arrived before its tool call
problem
#7710 folds a turn back into one message when the client opened an assistant record for a tool call that carried no parentMessageId: the prose that follows that container, and any further container for a parallel call, join it. The opposite order does not fold.
fromAgUiMessages([
{ id: "u-1", role: "user", content: "weather?" },
{ id: "m-1", role: "assistant", content: "let me check" },
{ id: "c-1", role: "assistant", toolCalls: [/* c-1 */] },
{ id: "t-1", role: "tool", toolCallId: "c-1", content: "sunny" },
]);
// => user, assistant m-1 [text], assistant c-1 [tool-call]the live RunAggregator renders that run as one message, so the reload still carries one message more than the session that produced it whenever the run said something before calling its tool.
mechanism
the fold in fromAgUiMessages (packages/react-ag-ui/src/runtime/adapter/conversions.ts) is forward only: a container absorbs what follows it, never the record ahead of it. the fingerprint that identifies a container (its own id is one of the calls it carries) says the container is not a boundary, but it says nothing about which side of it the turn began on, and two adjacent assistant records with a container second are equally the shape of a new run opening with a tool call after a previous run ended in prose. folding backward would merge those two runs into one message.
what would close it
the same thing #7533 named: a run id shared by the records of one run. @ag-ui/[email protected] still gives a message only subagentRunId and free-form metadata, and defaultApplyEvents writes no run id anywhere, so there is nothing to group on today. with that id the fold becomes a group-by and the direction question disappears.
until then the limit is documented on the runtime options page next to the forward fold.
Source: assistant-ui/assistant-ui