Messages
Messages form the backbone of communication in the AG-UI protocol. They
represent the conversation history between users and AI agents, and provide a
standardized way to exchange information regardless of the underlying AI service
being used.
Message Structure
AG-UI messages follow a vendor-neutral format, ensuring compatibility across
different AI providers while maintaining a consistent structure. This allows
applications to switch between AI services (like OpenAI, Anthropic, or custom
models) without changing the client-side implementation.
The basic message structure includes:
The role discriminator can be "user", "assistant", "system", "tool",
"developer", "activity", or "reasoning". Concrete message types extend
this shape with the fields they need.
The encryptedContent field enables privacy-preserving workflows where
sensitive content (such as reasoning chains) can be passed across turns
without exposing the raw content. This is particularly useful for zero data
retention (ZDR) compliance and store:false scenarios.
Message Types
AG-UI supports several message types to accommodate different participants in a
conversation:
User Messages
Messages from the end user to the agent:
In Python, the previous BinaryInputContent model is deprecated and remains
temporarily available as a compatibility path.
This structure keeps traditional plain-text inputs working while enabling richer
payloads such as images, audio clips, or uploaded files in the same message.
Assistant Messages
Messages from the AI assistant to the user:
System Messages
Instructions or context provided to the agent:
Results from tool executions:
Key points:
- The
toolCallId links the result back to the original tool call
- Use
error to indicate tool execution failures
- Use
encryptedValue to attach encrypted chain-of-thought related to how the
agent interpreted or processed the tool result
Activity Messages
Structured UI messages that exist only on the frontend. Used for progress,
status, or any custom visual element that shouldn’t be sent to the model:
Key points
- Emitted via
ACTIVITY_SNAPSHOT and ACTIVITY_DELTA to support live,
updateable UI (checklists, steps, search-in-progress, etc.).
- Frontend-only: never forwarded to the agent, so no filtering and no LLM
confusion.
- Customizable: define your own
activityType and content and render a
matching UI component.
- Streamable: can be updated over time for long-running operations.
- Helps persist/restore custom events by turning them into durable message
objects.
Developer Messages
Internal messages used for development or debugging:
Reasoning Messages
Messages representing the agent’s internal reasoning or chain-of-thought
process:
Unlike Activity messages, Reasoning messages are intended to represent the
agent’s internal thought process and may be encrypted for privacy and are
meant to be sent back to the agent for further processing on subsequent turns.
Key points:
- Emitted via
REASONING_MESSAGE_START, REASONING_MESSAGE_CONTENT, and
REASONING_MESSAGE_END events.
- Visibility control: Content may be visible to users (as a summary) or
fully encrypted.
- Encrypted values: Use
REASONING_ENCRYPTED_VALUE events to attach
encrypted chain-of-thought to messages or tool calls without exposing content.
- State continuity: Encrypted reasoning items can be passed across
conversation turns without exposing raw chain-of-thought.
- Privacy-first: Supports
store:false and zero data retention (ZDR)
policies while preserving reasoning capabilities.
- Separate from assistant messages: Reasoning is kept distinct from final
responses to avoid polluting the conversation history.
See Reasoning Events for the streaming
event lifecycle.
Vendor Neutrality
AG-UI messages are designed to be vendor-neutral, meaning they can be easily
mapped to and from proprietary formats used by various AI providers:
This abstraction allows AG-UI to serve as a common interface regardless of the
underlying AI service.
Message Synchronization
Messages can be synchronized between client and server through two primary
mechanisms:
Complete Snapshots
The MESSAGES_SNAPSHOT event provides a complete view of all messages in a
conversation:
This is typically used:
- When initializing a conversation
- After connection interruptions
- When major state changes occur
- To ensure client-server synchronization
Streaming Messages
For real-time interactions, new messages can be streamed as they’re generated:
-
Start a message: Indicate a new message is being created
-
Stream content: Send content chunks as they become available
-
End a message: Signal the message is complete
This streaming approach provides a responsive user experience with immediate
feedback.
AG-UI messages elegantly integrate tool usage, allowing agents to perform
actions and process their results:
Tool calls are embedded within assistant messages:
Example assistant message with tool calls:
Results from tool executions are represented as tool messages:
This creates a clear chain of tool usage:
- Assistant requests a tool call
- Tool executes and returns a result
- Assistant can reference and respond to the result
Similar to text messages, tool calls can be streamed to provide real-time
visibility into the agent’s actions:
-
Start a tool call:
-
Stream arguments:
-
End a tool call:
This allows frontends to show tools being invoked progressively as the agent
constructs its reasoning.
Practical Example
Here’s a complete example of a conversation with tool usage:
Conclusion
The message structure in AG-UI enables sophisticated conversational AI
experiences while maintaining vendor neutrality. By standardizing how messages
are represented, synchronized, and streamed, AG-UI provides a consistent way to
implement interactive human-agent communication regardless of the underlying AI
service.
This system supports everything from simple text exchanges to complex tool-based
workflows, all while optimizing for both real-time responsiveness and efficient
data transfer.