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:role discriminator can be "user", "assistant", "system",
"tool", "developer", or "activity". Concrete message types extend this
shape with the fields they need.
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:ForThis structure keeps traditional plain-text inputs working while enabling richer payloads such as images, audio clips, or uploaded files in the same message.BinaryInputContent, provide at least one ofid,url, ordatato reference the payload.
Assistant Messages
Messages from the AI assistant to the user:System Messages
Instructions or context provided to the agent:Tool Messages
Results from tool executions:Activity Messages
Structured progress updates that appear between chat messages:ACTIVITY_SNAPSHOT and ACTIVITY_DELTA
events. The structured content object gives frontends everything they need to
render bespoke status views, such as checklists, workflow progress, or search
results in flight.
Developer Messages
Internal messages used for development or debugging: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:Message Synchronization
Messages can be synchronized between client and server through two primary mechanisms:Complete Snapshots
TheMESSAGES_SNAPSHOT event provides a complete view of all messages in a
conversation:
- 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
Tool Integration in Messages
AG-UI messages elegantly integrate tool usage, allowing agents to perform actions and process their results:Tool Calls
Tool calls are embedded within assistant messages:Tool Results
Results from tool executions are represented as tool messages:- Assistant requests a tool call
- Tool executes and returns a result
- Assistant can reference and respond to the result
Streaming Tool Calls
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: