Message class represents a single message in an agent conversation. It supports text content, tool calls, media attachments, and metadata.
Constructor
Core Fields
The role of the message author: “system”, “user”, “assistant”, or “tool”.
The contents of the message. Can be a string or list of content blocks.
Unique identifier for the message (auto-generated).
Optional name for the message participant.
Tool Calls
Tool calls generated by the model.
Tool call ID that this message is responding to (for tool messages).
Name of the tool called.
Arguments passed to the tool.
Whether the tool call resulted in an error.
Media
Images attached to the message.
Audio files attached to the message.
Videos attached to the message.
Files attached to the message.
Output Media
Audio generated by the model.
Image generated by the model.
Video generated by the model.
Reasoning
The reasoning/thinking content from the model (not sent to API).
Redacted reasoning content sent to the model API.
Metadata
Metrics for the message (tokens, timing, etc.).
References added to the message for RAG.
Citations received from the model.
Provider-specific data needed for subsequent messages.
Unix timestamp when the message was created.
Flags
If True, the agent stops executing after this tool call.
Whether to add this message to the agent’s memory.
Flag indicating the message was fetched from history.
If True, the message is sent to the model but not persisted.