Class AguiMessage

java.lang.Object
io.agentscope.core.agui.model.AguiMessage

public class AguiMessage extends Object
Represents a message in the AG-UI protocol.

Messages are the primary communication unit in the AG-UI protocol. They contain content, role information, and optionally tool calls or tool call IDs.

Message roles:

  • user - Messages from the user
  • assistant - Messages from the AI assistant
  • system - System instructions
  • tool - Tool execution results
  • Constructor Details

    • AguiMessage

      public AguiMessage(String id, String role, String content, List<AguiToolCall> toolCalls, String toolCallId)
      Creates a new AguiMessage.
      Parameters:
      id - The unique message ID
      role - The message role (user, assistant, system, tool)
      content - The message content
      toolCalls - Tool calls for assistant messages (optional)
      toolCallId - Tool call ID for tool messages (optional)
  • Method Details

    • userMessage

      public static AguiMessage userMessage(String id, String content)
      Creates a simple user message.
      Parameters:
      id - The message ID
      content - The message content
      Returns:
      A new user message
    • assistantMessage

      public static AguiMessage assistantMessage(String id, String content)
      Creates a simple assistant message.
      Parameters:
      id - The message ID
      content - The message content
      Returns:
      A new assistant message
    • systemMessage

      public static AguiMessage systemMessage(String id, String content)
      Creates a system message.
      Parameters:
      id - The message ID
      content - The message content
      Returns:
      A new system message
    • toolMessage

      public static AguiMessage toolMessage(String id, String toolCallId, String content)
      Creates a tool result message.
      Parameters:
      id - The message ID
      toolCallId - The ID of the tool call this is responding to
      content - The tool result content
      Returns:
      A new tool message
    • getId

      public String getId()
      Get the message ID.
      Returns:
      The message ID
    • getRole

      public String getRole()
      Get the message role.
      Returns:
      The role (user, assistant, system, tool)
    • getContent

      public String getContent()
      Get the message content.
      Returns:
      The content, may be null
    • getToolCalls

      public List<AguiToolCall> getToolCalls()
      Get the tool calls (for assistant messages).
      Returns:
      The tool calls as an immutable list, empty if none
    • getToolCallId

      public String getToolCallId()
      Get the tool call ID (for tool messages).
      Returns:
      The tool call ID, or null if not a tool message
    • isUserMessage

      public boolean isUserMessage()
      Check if this is a user message.
      Returns:
      true if role is "user"
    • isAssistantMessage

      public boolean isAssistantMessage()
      Check if this is an assistant message.
      Returns:
      true if role is "assistant"
    • isSystemMessage

      public boolean isSystemMessage()
      Check if this is a system message.
      Returns:
      true if role is "system"
    • isToolMessage

      public boolean isToolMessage()
      Check if this is a tool message.
      Returns:
      true if role is "tool"
    • hasToolCalls

      public boolean hasToolCalls()
      Check if this message has tool calls.
      Returns:
      true if tool calls are present
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object