TanStack

uiMessagesToWire

Function: uiMessagesToWire()

ts
function uiMessagesToWire(messages): WireMessage[];

Defined in: packages/ai/src/utilities/ag-ui-wire.ts:47

Serialize TanStack UIMessages into the AG-UI RunAgentInput.messages wire shape. Each anchor (system/user/assistant) carries the canonical parts array verbatim plus AG-UI mirror fields (content, toolCalls) so AG-UI Zod parsing succeeds. Tool results and thinking parts on assistant messages are additionally emitted as fan-out {role:'tool',...} and {role:'reasoning',...} entries for strict AG-UI server consumers.

Parameters

messages

UIMessage<unknown>[]

Returns

WireMessage[]