pub struct Message {
pub text: String,
pub origin: MessageOrigin,
pub attachments: Option<Vec<MessageAttachment>>,
pub model: Option<ModelSelection>,
pub agent: Option<AgentSelection>,
pub meta: Option<JsonObject>,
}Expand description
A message that initiates or steers a turn. Messages can originate from the user, the agent, a tool, or be system-generated (see {@link MessageOrigin}).
Attachments MAY be referenced inside {@link Message.text} via their {@link MessageAttachmentBase.range} field. Attachments without a range are still associated with the message but do not correspond to a specific span in the text.
Fields§
§text: StringMessage text
origin: MessageOriginThe origin of the message
attachments: Option<Vec<MessageAttachment>>File/selection attachments
model: Option<ModelSelection>The model this message was, or will be, sent with.
For historic user/agent messages this records the model actually used, so a client editing or resending the message can retain that selection. For a {@link ChatState.draft | draft} it carries the model the user picked for the message they are composing. Absent means the agent host’s default model applies.
agent: Option<AgentSelection>The custom agent this message was, or will be, sent with.
For historic messages this records the agent actually used; for a {@link ChatState.draft | draft} it carries the agent the user picked. Absent means no custom agent — the provider’s default behavior applies.
meta: Option<JsonObject>Additional provider-specific metadata for this message.
Clients MAY look for well-known keys here to provide enhanced UI, and
agent hosts MAY use it to carry context that does not fit any other
field. Mirrors the MCP _meta convention.