CopilotKit

Types

The Agent User Interaction Protocol Ruby 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.

Context

AgUiProtocol::Core::Types::Context

Represents a piece of contextual information provided to an agent.


ctx = AgUiProtocol::Core::Types::Context.new(description: "User locale",
value: "es-CL")
PropertyTypeDescription
descriptionStringDescription of what this context represents.
valueStringThe actual context value.

RunAgentInput

AgUiProtocol::Core::Types::RunAgentInput

Input parameters for running an agent. In the HTTP API, this is the body of the POST request.


input = AgUiProtocol::Core::Types::RunAgentInput.new(
    thread_id: "thread_123",
    run_id: "run_123",
    parent_run_id: nil,
    state: {},
    messages: [],
    tools: [],
    context: [],
    forwarded_props: {}

)
PropertyTypeDescription
thread_idStringID of the conversation thread
run_idStringID of the current run
stateObjectCurrent state of the agent
messagesArray<BaseMessage>List of messages in the conversation
toolsArray<Tool>List of tools available to the agent
contextArray<Context>List of context objects provided to the agent
forwarded_propsObjectAdditional properties forwarded to the agent
parent_run_idString (optional)Lineage pointer for branching/time travel , Default: nil.

Tool

AgUiProtocol::Core::Types::Tool

Defines a tool that can be called by an agent.


tool = AgUiProtocol::Core::Types::Tool.new(
    name: "search",
    description: "Search the web",
    parameters: { "type" => "object", "properties" => { "q" => { "type" => "string" } } }

)
PropertyTypeDescription
nameStringName of the tool.
descriptionStringDescription of what the tool does.
parametersObjectJSON Schema for tool parameters.

ToolCall

AgUiProtocol::Core::Types::ToolCall

Tool calls are embedded within assistant messages.


tool_call = AgUiProtocol::Core::Types::ToolCall.new(
    id: "tc_1",
    function: { name: "search", arguments: "{\"q\":\"AG-UI\"}" }

)
PropertyTypeDescription
idStringUnique identifier for the tool call
functionFunctionCall , HashFunction name and arguments
typeString (optional)Type of the tool call , Default: 'function'.

FunctionCall

AgUiProtocol::Core::Types::FunctionCall

Function invocation descriptor used inside tool calls.


fn = AgUiProtocol::Core::Types::FunctionCall.new(
    name: "search",
    arguments: "{\"q\":\"AG-UI\"}"

)

@category [] ToolCall

PropertyTypeDescription
nameStringFunction name.
argumentsStringJSON-encoded arguments.

Message Types

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

ActivityMessage

AgUiProtocol::Core::Types::ActivityMessage

Represents structured activity progress emitted between chat messages.


msg = AgUiProtocol::Core::Types::ActivityMessage.new(
    id: "activity_1",
    activity_type: "progress",
    content: { "pct" => 10 }

)

@category [] Message Types

PropertyTypeDescription
idStringUnique identifier for the activity message.
activity_typeStringActivity discriminator used for renderer selection.
contentHashStructured payload representing the activity state.

AssistantMessage

AgUiProtocol::Core::Types::AssistantMessage

Represents a message from an assistant.


msg = AgUiProtocol::Core::Types::AssistantMessage.new(
    id: "asst_1",
    content: "Hello!",
    tool_calls: [
      {
        id: "tc_1",
        function: { name: "search", arguments: "{\"q\":\"AG-UI\"}" }
      }
    ]

)

@category [] Message Types

PropertyTypeDescription
idStringUnique identifier for the message
contentObject (optional)Text content of the message , Default: nil.
tool_callsArray<ToolCall , Hash> (optional)Tool calls made in this message , Default: nil.
nameString (optional)Name of the sender , Default: nil.

BinaryInputContent

AgUiProtocol::Core::Types::BinaryInputContent

Represents binary data such as images, audio, or files.


content = AgUiProtocol::Core::Types::BinaryInputContent.new(
    mime_type: "image/png",
    url: "https://example.com/cat.png"

)

Validation: At least one of id, url, or data must be provided.

@category [] Message Types

PropertyTypeDescription
typeString (optional)Identifies the fragment type , Default: "binary".
mime_typeStringMIME type, for example "image/png"
idString (optional)Reference to previously uploaded content , Default: nil.
urlString (optional)Remote URL where the content can be retrieved , Default: nil.
dataString (optional)Base64 encoded content , Default: nil.
filenameString (optional)Optional filename hint , Default: nil.

DeveloperMessage

AgUiProtocol::Core::Types::DeveloperMessage

Represents a message from a developer.


msg = AgUiProtocol::Core::Types::DeveloperMessage.new(
    id: "dev_1",
    content: "You are a helpful assistant."

)

@category [] Message Types

PropertyTypeDescription
idStringUnique identifier for the message
contentObjectText content of the message (required)
nameString (optional)Optional name of the sender , Default: nil.

Role

AgUiProtocol::Core::Types::Role

Represents the possible roles a message sender can have.


AgUiProtocol::Core::Types::Role # => ["developer", "system", "assistant",
"user", "tool", "activity"]

@category [] Message Types

SystemMessage

AgUiProtocol::Core::Types::SystemMessage

Represents a system message.


msg = AgUiProtocol::Core::Types::SystemMessage.new(
    id: "sys_1",
    content: "Follow the protocol."

)

@category [] Message Types

PropertyTypeDescription
idStringUnique identifier for the message
contentObjectText content of the message (required)
nameString (optional)Optional name of the sender , Default: nil.

TextInputContent

AgUiProtocol::Core::Types::TextInputContent

Represents a text fragment inside a multimodal user message.


content = AgUiProtocol::Core::Types::TextInputContent.new(text: "hello")

@category [] Message Types

PropertyTypeDescription
textStringText content
typeString (optional)Identifies the fragment type , Default: "text".

ToolMessage

AgUiProtocol::Core::Types::ToolMessage

Tool result message.


msg = AgUiProtocol::Core::Types::ToolMessage.new(
    id: "tool_msg_1",
    tool_call_id: "tc_1",
    content: "ok"

)

@category [] Message Types

PropertyTypeDescription
idStringUnique identifier for the message.
contentStringTool result content.
tool_call_idStringID of the tool call this message responds to.
errorString (optional)Error payload if the tool call failed. , Default: nil.

UserMessage

AgUiProtocol::Core::Types::UserMessage

Represents a message from a user.


msg = AgUiProtocol::Core::Types::UserMessage.new(
    id: "user_2",
    content: [
      { type: "text", text: "Please describe this image" },
      { type: "binary", mimeType: "image/png", url: "https://example.com/cat.png" }
    ]

)

@category [] Message Types

PropertyTypeDescription
idStringUnique identifier for the message
contentString , Array<TextInputContent , BinaryInputContent>Either a plain text string or an ordered list of multimodal fragments
nameString (optional)Optional name of the sender , Default: nil.

State

State is represented as Any.

The state type is flexible and can hold any data structure needed by the agent implementation.