Message
Message
A Message is the fundamental communication unit in the A2A protocol used to transmit non-Artifact content between the client and the agent.
Purpose of Messages
Messages carry various types of information during the interaction process, including:
- User Input: All requests, instructions, or contextual information from the client are sent as messages.
- Agent Thinking: Intermediate steps, thought processes, or explanations from the agent while processing a task.
- Status Updates: Information conveyed by the agent regarding task status changes.
- Instructions: Requests or instructions issued by the agent to the client (e.g., requesting more information).
- Error Information: Transmission of errors that occur during the interaction.
- Metadata: Additional accompanying information.
Unlike Artifact
, which focuses on the final result, Message
is more concerned with the process and control flow of the interaction.
Message Structure
- Role: The role of the message sender, typically
user
(client) oragent
(agent). - Parts: A message can contain one or more
Part
s, each representing different types of content (e.g., text, file reference). This allows a single message to convey multiple types of information simultaneously, such as a user’s text description and related context files. - Metadata: An optional metadata field for carrying additional information.
Message Interface Definition
Below is an illustrative definition of the Message interface:
interface Message {
role: "user" | "agent"; // Role of the message sender
parts: Part[]; // Array of parts contained in the message
metadata?: Record<string, any>; // Extended metadata
}
By using Message
and Artifact
, the A2A protocol clearly distinguishes between interaction process information and final results, making communication more structured and manageable.