Skip to main content

Core Types

The Agent User Interaction Protocol Python SDK is built on a set of core types that represent the fundamental structures used throughout the system. This page documents these types and their properties.

RunAgentInput

from ag_ui.core import RunAgentInput Input parameters for running an agent. In the HTTP API, this is the body of the POST request. tools contains tools provided by the client for this run. Backend-defined tools should remain in the backend agent or framework configuration, and may be advertised separately through agent capabilities.
class RunAgentInput(ConfiguredBaseModel):
    thread_id: str
    run_id: str
    parent_run_id: Optional[str] = None
    state: Any
    messages: List[Message]
    tools: List[Tool]
    context: List[Context]
    forwarded_props: Any
PropertyTypeDescription
thread_idstrID of the conversation thread
run_idstrID of the current run
parent_run_idOptional[str](Optional) ID of the run that spawned this run
stateAnyCurrent state of the agent
messagesList[Message]List of messages in the conversation
toolsList[Tool]Client-provided tools available for this run
contextList[Context]List of context objects provided to the agent
forwarded_propsAnyAdditional properties forwarded to the agent

Message Types

The SDK includes several message types that represent different kinds of messages in the system.

Role

from ag_ui.core import Role Represents the possible roles a message sender can have.
Role = Literal["developer", "system", "assistant", "user", "tool", "activity", "reasoning"]

DeveloperMessage

from ag_ui.core import DeveloperMessage Represents a message from a developer.
class DeveloperMessage(BaseMessage):
    role: Literal["developer"]
    content: str
PropertyTypeDescription
idstrUnique identifier for the message
roleLiteral["developer"]Role of the message sender, fixed as “developer”
contentstrText content of the message (required)
nameOptional[str]Optional name of the sender

SystemMessage

from ag_ui.core import SystemMessage Represents a system message.
class SystemMessage(BaseMessage):
    role: Literal["system"]
    content: str
PropertyTypeDescription
idstrUnique identifier for the message
roleLiteral["system"]Role of the message sender, fixed as “system”
contentstrText content of the message (required)
nameOptional[str]Optional name of the sender

AssistantMessage

from ag_ui.core import AssistantMessage Represents a message from an assistant.
class AssistantMessage(BaseMessage):
    role: Literal["assistant"]
    content: Optional[str] = None
    tool_calls: Optional[List[ToolCall]] = None
PropertyTypeDescription
idstrUnique identifier for the message
roleLiteral["assistant"]Role of the message sender, fixed as “assistant”
contentOptional[str]Text content of the message
nameOptional[str]Name of the sender
tool_callsOptional[List[ToolCall]]Tool calls made in this message

UserMessage

from ag_ui.core import UserMessage Represents a message from a user.
class UserMessage(BaseMessage):
    role: Literal["user"]
    content: Union[str, List["InputContent"]]
PropertyTypeDescription
idstrUnique identifier for the message
roleLiteral["user"]Role of the message sender, fixed as “user”
contentUnion[str, List["InputContent"]]Either a plain text string or an ordered list of multimodal fragments
nameOptional[str]Optional name of the sender

InputContentSource

Represents how a non-text part is supplied.
InputContentSource = Annotated[
    Union[InputContentDataSource, InputContentUrlSource],
    Field(discriminator="type"),
]

class InputContentDataSource(ConfiguredBaseModel):
    type: Literal["data"]
    value: str
    mime_type: str

class InputContentUrlSource(ConfiguredBaseModel):
    type: Literal["url"]
    value: str
    mime_type: Optional[str] = None

TextInputContent

Represents a text fragment inside a multimodal user message.
class TextInputContent(ConfiguredBaseModel):
    type: Literal["text"]
    text: str
PropertyTypeDescription
typeLiteral["text"]Identifies the fragment type
textstrText content

BinaryInputContent

Represents binary data such as images, audio, or files.
class BinaryInputContent(ConfiguredBaseModel):
    type: Literal["binary"]
    mime_type: str
    id: Optional[str] = None
    url: Optional[str] = None
    data: Optional[str] = None
    filename: Optional[str] = None
PropertyTypeDescription
typeLiteral["binary"]Identifies the fragment type
mime_typestrMIME type, for example "image/png"
idOptional[str]Reference to previously uploaded content
urlOptional[str]Remote URL where the content can be retrieved
dataOptional[str]Base64 encoded content
filenameOptional[str]Optional filename hint
Validation: At least one of id, url, or data must be provided. Deprecated: BinaryInputContent remains available as a temporary compatibility model. Prefer modality-specific parts below.

ImageInputContent / AudioInputContent / VideoInputContent / DocumentInputContent

class ImageInputContent(ConfiguredBaseModel):
    type: Literal["image"]
    source: InputContentSource
    metadata: Optional[Any] = None

class AudioInputContent(ConfiguredBaseModel):
    type: Literal["audio"]
    source: InputContentSource
    metadata: Optional[Any] = None

class VideoInputContent(ConfiguredBaseModel):
    type: Literal["video"]
    source: InputContentSource
    metadata: Optional[Any] = None

class DocumentInputContent(ConfiguredBaseModel):
    type: Literal["document"]
    source: InputContentSource
    metadata: Optional[Any] = None

ToolMessage

from ag_ui.core import ToolMessage Represents a message from a tool.
class ToolMessage(ConfiguredBaseModel):
    id: str
    role: Literal["tool"]
    content: str
    tool_call_id: str
    error: Optional[str] = None
    encrypted_value: Optional[str] = None
PropertyTypeDescription
idstrUnique identifier for the message
contentstrText content of the message
roleLiteral["tool"]Role of the message sender, fixed as “tool”
tool_call_idstrID of the tool call this message responds to
errorOptional[str]Error message if the tool call failed
encrypted_valueOptional[str]Optional encrypted value attached via signature

ActivityMessage

from ag_ui.core import ActivityMessage Represents structured activity progress emitted between chat messages.
class ActivityMessage(ConfiguredBaseModel):
    id: str
    role: Literal["activity"]
    activity_type: str
    content: Dict[str, Any]
PropertyTypeDescription
idstrUnique identifier for the activity message
roleLiteral["activity"]Fixed discriminator identifying the message as activity
activity_typestrActivity discriminator used for renderer selection
contentDict[str, Any]Structured payload representing the activity state

ReasoningMessage

from ag_ui.core import ReasoningMessage Represents a reasoning/thinking message from an agent’s internal thought process.
class ReasoningMessage(ConfiguredBaseModel):
    id: str
    role: Literal["reasoning"]
    content: str
    encrypted_value: Optional[str] = None
PropertyTypeDescription
idstrUnique identifier for the reasoning message
roleLiteral["reasoning"]Fixed discriminator identifying the reasoning role
contentstrThe reasoning/thinking content
encrypted_valueOptional[str]Optional encrypted value attached via signature

Message

from ag_ui.core import Message A union type representing any type of message in the system.
Message = Annotated[
    Union[
        DeveloperMessage,
        SystemMessage,
        AssistantMessage,
        UserMessage,
        ToolMessage,
        ActivityMessage,
        ReasoningMessage,
    ],
    Field(discriminator="role")
]

ToolCall

from ag_ui.core import ToolCall Represents a tool call made by an agent.
class ToolCall(ConfiguredBaseModel):
    id: str
    type: Literal["function"]
    function: FunctionCall
    encrypted_value: Optional[str] = None
PropertyTypeDescription
idstrUnique identifier for the tool call
typeLiteral["function"]Type of the tool call, always “function”
functionFunctionCallDetails about the function being called
encrypted_valueOptional[str]Optional encrypted value attached via signature

FunctionCall

from ag_ui.core import FunctionCall Represents function name and arguments in a tool call.
class FunctionCall(ConfiguredBaseModel):
    name: str
    arguments: str
PropertyTypeDescription
namestrName of the function to call
argumentsstrJSON-encoded string of arguments to the function

Context

from ag_ui.core import Context Represents a piece of contextual information provided to an agent.
class Context(ConfiguredBaseModel):
    description: str
    value: str
PropertyTypeDescription
descriptionstrDescription of what this context represents
valuestrThe actual context value

Tool

from ag_ui.core import Tool Defines a tool that can be called by an agent.
class Tool(ConfiguredBaseModel):
    name: str
    description: str
    parameters: Any  # JSON Schema
PropertyTypeDescription
namestrName of the tool
descriptionstrDescription of what the tool does
parametersAnyJSON Schema defining the parameters for the tool

State

from ag_ui.core import State Represents the state of an agent during execution.
State = Any
The state type is flexible and can hold any data structure needed by the agent implementation.