Skip to main content

AGUI.Abstractions Types

AGUI.Abstractions contains the protocol model shared by AG-UI .NET clients and servers. The JSON wire names are camel-case and match the AG-UI protocol.

RunAgentInput

RunAgentInput is the request payload for running an agent. In the HTTP API, it is the body of the POST request.
using System.Text.Json;
using AGUI.Abstractions;

var input = new RunAgentInput
{
    ThreadId = "thread-1",
    RunId = "run-1",
    Messages =
    [
        new AGUIUserMessage
        {
            Id = "msg-1",
            Content = "Hello!"
        }
    ],
    Tools =
    [
        new AGUITool
        {
            Name = "get_weather",
            Description = "Get the weather for a city",
            Parameters = JsonDocument.Parse("""
                {
                  "type": "object",
                  "properties": {
                    "city": { "type": "string" }
                  },
                  "required": ["city"]
                }
                """).RootElement.Clone()
        }
    ]
};
C# propertyJSON fieldTypeDescription
ThreadIdthreadIdstringID of the conversation thread
RunIdrunIdstringID of the current run
ParentRunIdparentRunIdstring?Optional lineage pointer for branching or time travel
MessagesmessagesIList<AGUIMessage>Conversation messages
ToolstoolsIList<AGUITool>?Tools available to the agent
StatestateJsonElement?Current frontend or agent state
ResumeresumeIList<AGUIResume>?Resume payloads for interrupted runs
ContextcontextIList<AGUIContext>?Context objects provided to the agent
ForwardedPropertiesforwardedPropsJsonElementAdditional properties forwarded by the client

Message Types

Messages form a closed hierarchy rooted at AGUIMessage. The base type carries only the fields shared by every role: Id and Role. Role-specific properties such as content, name, encryptedValue, toolCalls, and toolCallId are declared on the sealed role classes.
public abstract class AGUIMessage
{
    public string? Id { get; set; } // "id"
    public abstract string Role { get; } // "role"
}

Roles

The Role property returns one of the lowercase constants in AGUIRoles:
ConstantJSON value
AGUIRoles.Developerdeveloper
AGUIRoles.Systemsystem
AGUIRoles.Assistantassistant
AGUIRoles.Useruser
AGUIRoles.Tooltool
AGUIRoles.Activityactivity
AGUIRoles.Reasoningreasoning

AGUIDeveloperMessage

var message = new AGUIDeveloperMessage
{
    Id = "dev-1",
    Content = "Prefer concise answers.",
    Name = "policy"
};
C# propertyJSON fieldTypeDescription
Ididstring?Message ID
Rolerole"developer"Fixed role discriminator
ContentcontentstringDeveloper instruction content
Namenamestring?Optional sender name
EncryptedValueencryptedValuestring?Optional opaque encrypted value

AGUISystemMessage

var message = new AGUISystemMessage
{
    Id = "sys-1",
    Content = "You are a helpful assistant.",
    Name = "system"
};
C# propertyJSON fieldTypeDescription
Ididstring?Message ID
Rolerole"system"Fixed role discriminator
ContentcontentstringSystem instruction content
Namenamestring?Optional sender name
EncryptedValueencryptedValuestring?Optional opaque encrypted value

AGUIAssistantMessage

var message = new AGUIAssistantMessage
{
    Id = "asst-1",
    Content = "I can help with that.",
    ToolCalls =
    [
        new AGUIToolCall
        {
            Id = "call-1",
            Function = new AGUIToolCallFunction
            {
                Name = "get_weather",
                Arguments = """{"city":"Seattle"}"""
            }
        }
    ]
};
C# propertyJSON fieldTypeDescription
Ididstring?Message ID
Rolerole"assistant"Fixed role discriminator
Contentcontentstring?Optional assistant text
Namenamestring?Optional assistant name
EncryptedValueencryptedValuestring?Optional opaque encrypted value
ToolCallstoolCallsIList<AGUIToolCall>?Tool calls made in the message

AGUIUserMessage

AGUIUserMessage.Content is an AGUIUserContent value. It models the AG-UI wire union string | InputContent[].
var textOnly = new AGUIUserMessage
{
    Id = "user-1",
    Content = "Summarize this image."
};

AGUIInputContent textPart = new AGUITextInputContent
{
    Text = "What is shown here?"
};

AGUIInputContent imagePart = new AGUIImageInputContent
{
    Source = new AGUIInputContentUrlSource
    {
        Value = "https://example.com/screen.png",
        MimeType = "image/png"
    }
};

var multimodal = new AGUIUserMessage
{
    Id = "user-2",
    Content = [textPart, imagePart]
};
AGUIUserContent supports implicit conversions from string, List<AGUIInputContent>, and AGUIInputContent[]. It also has a collection builder, so C# collection expressions work. For reading, it implements IReadOnlyList<AGUIInputContent>; a plain string is exposed as one AGUITextInputContent part.
C# propertyJSON fieldTypeDescription
Ididstring?Message ID
Rolerole"user"Fixed role discriminator
ContentcontentAGUIUserContentPlain text or ordered multimodal parts
Namenamestring?Optional user name
EncryptedValueencryptedValuestring?Optional opaque encrypted value
See Multimodal Inputs for the AGUIInputContent hierarchy.

AGUIToolMessage

var message = new AGUIToolMessage
{
    Id = "tool-msg-1",
    ToolCallId = "call-1",
    Content = """{"temperature":72}"""
};
C# propertyJSON fieldTypeDescription
Ididstring?Message ID
Rolerole"tool"Fixed role discriminator
ContentcontentstringTool result content
ToolCallIdtoolCallIdstringID of the tool call this message answers
Errorerrorstring?Optional error message
EncryptedValueencryptedValuestring?Optional opaque encrypted value

AGUIActivityMessage

var message = new AGUIActivityMessage
{
    Id = "activity-1",
    ActivityType = "PLAN",
    Content = JsonDocument.Parse("""{"status":"running"}""").RootElement.Clone()
};
C# propertyJSON fieldTypeDescription
Ididstring?Message ID
Rolerole"activity"Fixed role discriminator
ActivityTypeactivityTypestringActivity discriminator for renderer selection
ContentcontentJsonElementStructured activity payload

AGUIReasoningMessage

var message = new AGUIReasoningMessage
{
    Id = "reasoning-1",
    Content = "Thinking through the problem..."
};
C# propertyJSON fieldTypeDescription
Ididstring?Message ID
Rolerole"reasoning"Fixed role discriminator
ContentcontentstringReasoning text
EncryptedValueencryptedValuestring?Optional opaque encrypted value

AGUIToolCall

var call = new AGUIToolCall
{
    Id = "call-1",
    Type = "function",
    Function = new AGUIToolCallFunction
    {
        Name = "get_weather",
        Arguments = """{"city":"Seattle"}"""
    }
};
C# propertyJSON fieldTypeDescription
IdidstringTool call ID
TypetypestringTool call type; defaults to "function"
FunctionfunctionAGUIToolCallFunctionFunction name and JSON-encoded arguments
EncryptedValueencryptedValuestring?Optional opaque encrypted value
AGUIToolCallFunction has Name (name) and Arguments (arguments).

Context

AGUIContext represents a piece of contextual information provided to an agent.
var context = new AGUIContext
{
    Description = "Current customer tier",
    Value = "enterprise"
};
C# propertyJSON fieldTypeDescription
DescriptiondescriptionstringDescription of what the context represents
ValuevaluestringContext value

Tool

AGUITool defines a tool that an agent can call.
var tool = new AGUITool
{
    Name = "get_weather",
    Description = "Get the weather for a city",
    Parameters = JsonDocument.Parse("""
        {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
        """).RootElement.Clone(),
    Metadata = JsonDocument.Parse("""{"ui":"compact"}""").RootElement.Clone()
};
C# propertyJSON fieldTypeDescription
NamenamestringTool name
Descriptiondescriptionstring?Optional tool description
ParametersparametersJsonElementJSON Schema for the tool parameters
MetadatametadataJsonElement?Optional arbitrary tool metadata

State

State is represented as JsonElement? on RunAgentInput.State and as JsonElement payloads in StateSnapshotEvent and StateDeltaEvent.
input.State = JsonDocument.Parse("""{"draft":"hello"}""").RootElement.Clone();
The schema of the state is defined by the agent. The protocol only carries it.

AgentCapabilities

AgentCapabilities is a structured declaration that an agent can expose so clients can discover what it supports. All fields are optional.
var capabilities = new AgentCapabilities
{
    Identity = new IdentityCapabilities
    {
        Name = "Support Agent",
        Version = "1.0.0"
    },
    Transport = new TransportCapabilities
    {
        Streaming = true,
        Resumable = true
    },
    Tools = new ToolsCapabilities
    {
        Supported = true,
        ClientProvided = true
    },
    Multimodal = new MultimodalCapabilities
    {
        Input = new MultimodalInputCapabilities
        {
            Image = true,
            Audio = true,
            Pdf = true
        }
    }
};
C# propertyJSON fieldTypeDescription
IdentityidentityIdentityCapabilities?Agent identity and metadata
TransporttransportTransportCapabilities?Streaming, websocket, binary, push, and resumability support
ToolstoolsToolsCapabilities?Tool support and tool-calling configuration
OutputoutputOutputCapabilities?Structured output and supported MIME types
StatestateStateCapabilities?Snapshot, delta, memory, and persistence support
MultiAgentmultiAgentMultiAgentCapabilities?Delegation, handoffs, and sub-agent information
ReasoningreasoningReasoningCapabilities?Reasoning, streaming, and encrypted reasoning support
MultimodalmultimodalMultimodalCapabilities?Multimodal input and output support
ExecutionexecutionExecutionCapabilities?Code execution and iteration/time limits
HumanInTheLoophumanInTheLoopHumanInTheLoopCapabilities?Approvals, interventions, feedback, interrupts, and approve-with-edits
CustomcustomIDictionary<string, object?>?Integration-specific capabilities
See Capabilities for protocol-level concepts and usage patterns.

Serialization

All protocol types are registered in AGUIJsonSerializerContext, a source-generated JsonSerializerContext. Use it when serializing protocol types in AOT-sensitive code.
var json = JsonSerializer.Serialize(
    input,
    AGUIJsonSerializerContext.Default.RunAgentInput);