UiMessage

data class UiMessage(val id: String, val role: UiRole, val parts: List<UiPart> = emptyList(), val name: String? = null)

One turn in the transcript, as an ordered list of UiParts.

A message is not the same unit as a protocol message. An assistant that reasons, speaks, calls a tool and speaks again emits four message ids across three event families; this model folds that turn into one UiMessage whose parts are in the order the agent produced them, and each part keeps the protocol id it came from. That is the whole reason this type exists: the transcript shape the upstream SDK maintains -- an assistant message with a single content string and a separate toolCalls list, and reasoning in a sibling channel keyed by its own id -- cannot say whether the tool call came before or after the sentence.

There is no TOOL role. A tool's output belongs to the call that asked for it, so a TOOL_CALL_RESULT lands on the ToolCallPart rather than opening a message of its own.

Constructors

Link copied to clipboard
constructor(id: String, role: UiRole, parts: List<UiPart> = emptyList(), name: String? = null)

Properties

Link copied to clipboard
val id: String

Identity within one transcript, and the key a list renderer is meant to use.

Link copied to clipboard

true while any part is still arriving.

Link copied to clipboard
val name: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The concatenated text of every TextPart, for a renderer that wants the message as prose.