Skip to main content
The Message class represents a single message in an agent conversation. It supports text content, tool calls, media attachments, and metadata.

Constructor

from agno.models.message import Message

message = Message(
    role="user",
    content="Hello!"
)

Core Fields

role
str
required
The role of the message author: “system”, “user”, “assistant”, or “tool”.
content
str | List[Any]
default:"None"
The contents of the message. Can be a string or list of content blocks.
id
str
Unique identifier for the message (auto-generated).
name
str
default:"None"
Optional name for the message participant.

Tool Calls

tool_calls
List[Dict[str, Any]]
default:"None"
Tool calls generated by the model.
tool_call_id
str
default:"None"
Tool call ID that this message is responding to (for tool messages).
tool_name
str
default:"None"
Name of the tool called.
tool_args
Any
default:"None"
Arguments passed to the tool.
tool_call_error
bool
default:"None"
Whether the tool call resulted in an error.

Media

images
Sequence[Image]
default:"None"
Images attached to the message.
audio
Sequence[Audio]
default:"None"
Audio files attached to the message.
videos
Sequence[Video]
default:"None"
Videos attached to the message.
files
Sequence[File]
default:"None"
Files attached to the message.

Output Media

audio_output
Audio
default:"None"
Audio generated by the model.
image_output
Image
default:"None"
Image generated by the model.
video_output
Video
default:"None"
Video generated by the model.

Reasoning

reasoning_content
str
default:"None"
The reasoning/thinking content from the model (not sent to API).
redacted_reasoning_content
str
default:"None"
Redacted reasoning content sent to the model API.

Metadata

metrics
MessageMetrics
Metrics for the message (tokens, timing, etc.).
references
MessageReferences
default:"None"
References added to the message for RAG.
citations
Citations
default:"None"
Citations received from the model.
provider_data
Dict[str, Any]
default:"None"
Provider-specific data needed for subsequent messages.
created_at
int
Unix timestamp when the message was created.

Flags

stop_after_tool_call
bool
default:"False"
If True, the agent stops executing after this tool call.
add_to_agent_memory
bool
default:"True"
Whether to add this message to the agent’s memory.
from_history
bool
default:"False"
Flag indicating the message was fetched from history.
temporary
bool
default:"False"
If True, the message is sent to the model but not persisted.

Methods

get_content_string()

Return content as a string.
text = message.get_content_string()

to_dict()

Serialize message to dictionary.
data = message.to_dict()

from_dict()

Deserialize message from dictionary.
message = Message.from_dict(data)

log()

Log the message to console.
message.log(metrics=True, level="info")

Example Usage

from agno.models.message import Message

message = Message(
    role="user",
    content="What's the weather?"
)

Build docs developers (and LLMs) love