agentc
GitHubagentc-sh/agentc
agentc
GitHubagentc-sh/agentc
›Introduction
Get started›Concepts in 5 minutes›Build your first agent›Add your first tool›Serve and connect
Concepts›Architecture overview›The manifest›The compilation pipeline›Archetypes›The graph›Tools and capabilities›Runtime libraries›Skills›Agents and prompts›Serving and protocols›Observability
Guides›Author a manifest›Write a tool›Give your agent a filesystem›Control network egress›Connect external tools via MCP›Connect agents via A2A›Use the bash tool›Control tool access with capabilities›Write templated prompts›Manage prompts with Langfuse›Pass context from the client›Configure a model provider›Connect a CopilotKit frontend›Deploy a standalone binary›Deploy with Docker and PostgreSQL›Instrument with OpenTelemetry›Extend code generation with blocks
Reference
Manifest
Runtime
›AG-UI›A2A
›Observability

AG-UI

The AG-UI protocol add-on mounted alongside the native contract.

Overview

AG-UI is a standardized streaming protocol for connecting front-end applications to AI agents. It defines a set of event types that the agent emits over a Server-Sent Events (SSE) stream as a run progresses. Enabling the AG-UI add-on gives you a path-compatible endpoint that any AG-UI client can connect to, including CopilotKit and other frameworks built on the protocol.

Enable it in your manifest:

agent.acl
http_server {
  protocol {
    ag_ui {}
  }
}

The default base path is /ag-ui, and the run endpoint is served at /ag-ui/run. You can change the base path:

protocol {
  ag_ui {
    path = "/custom-path"
  }
}

With a custom base path, the run endpoint becomes <path>/run.

Starting a run

POST/ag-ui/run

Send a POST request to the run endpoint under the configured base path (default /ag-ui/run). The request body follows the AG-UI RunAgentInput shape.

Request bodyin: body
thread_id
string

Optional session ID to continue. If omitted, a new session is created.

run_id
string

Optional identifier for this run. Generated automatically if not provided.

messages
Message[]

Conversation messages. Each has a role and content.

tools
Tool[]

Optional client-defined tool definitions to make available for this run.

context
ContextVariable[]

Optional per-run context variables.

state
object

Optional initial or updated state. Applied to the context field of the agent state.

forwarded_props
object

Optional arbitrary additional properties forwarded to the agent.

Message

Message
role
string

The role of the message sender.

userassistantsystem
content
string

The text content of the message.

Tool

Tool
name
string

The tool name.

description
string

A description of the tool.

parameters
object

A JSON Schema object describing the tool's parameters.

Context Variable

Context Variable
name
string

The variable name.

value
string

The variable value.

curl -X POST http://localhost:8080/ag-ui/run \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "user", "content": "What is 42 plus 7?" }
    ]
  }'

To continue a previous conversation, pass the thread_id from a prior run. The agent loads the checkpoint for that thread and resumes the conversation from where it left off.

Responses

SSE wire format

The response is a Server-Sent Events stream. Each event has an event line and a JSON data payload.

event: RUN_STARTED
data: {"type":"RUN_STARTED","timestamp":1710000000.0,"threadId":"...","runId":"..."}

event: TEXT_MESSAGE_START
data: {"type":"TEXT_MESSAGE_START","timestamp":1710000000.1,"messageId":"..."}

event: TEXT_MESSAGE_CONTENT
data: {"type":"TEXT_MESSAGE_CONTENT","timestamp":1710000000.2,"messageId":"...","delta":"Hello"}

event: TEXT_MESSAGE_END
data: {"type":"TEXT_MESSAGE_END","timestamp":1710000000.3,"messageId":"..."}

event: RUN_FINISHED
data: {"type":"RUN_FINISHED","timestamp":1710000000.4,"threadId":"...","runId":"...","result":null}

JSON Patches

JSON patches are used to update the agent state, often found in events like STATE_DELTA. They follow the RFC 6902 JSON Patch standard. Each patch operation has an op (operation), a path (location in the JSON document), and a value (the new value to apply).

JSONPatch
op
string

The operation to perform.

addremovereplacemovecopytest
path
string

The location in the JSON document to apply the operation.

value
object | string | number | boolean | null

The new value to apply.

Event stream

The response is a Server-Sent Events stream. Events follow the AG-UI event schema. All events have a type field and an optional timestamp.

Lifecycle events

RUN_STARTED      emitted when the run begins
RUN_FINISHED     emitted when the run completes successfully
RUN_ERROR        emitted if the run encounters an unrecoverable error
STEP_STARTED     emitted at the start of each reasoning step
STEP_FINISHED    emitted at the end of each reasoning step

Text message events

Text output from the model is streamed using a start-content-end pattern:

TEXT_MESSAGE_START    begins a new message, includes the message ID and role
TEXT_MESSAGE_CONTENT  a chunk of content for the current message
TEXT_MESSAGE_END      marks the end of the current message

Tool call events

Tool invocations are streamed in the same pattern:

TOOL_CALL_START  begins a tool call, includes the call ID and tool name
TOOL_CALL_ARGS   a chunk of the tool call arguments (streamed JSON)
TOOL_CALL_END    marks the end of the tool call

State management events

MESSAGES_SNAPSHOT  the full conversation history at a point in time
STATE_SNAPSHOT     the complete agent state (context field) at a point in time
STATE_DELTA        incremental state update as RFC 6902 JSON Patch operations

STATE_DELTA events are emitted when tools return state updates. Only the context field of the agent state is visible to clients via these events.

Custom events

CUSTOM  used to deliver real-time updates from tools to the client

When a tool calls agentc.emit (JavaScript) or input.emit (Python) during execution, the update is delivered to the client as a CUSTOM event. Note that AG-UI defines its own ACTIVITY_DELTA event type; agentc tool emissions are not that. They arrive as CUSTOM events because agentc's concept of an activity update does not map to AG-UI's ACTIVITY_DELTA.

These updates are stateless and not persisted. They are intended for generative UI, such as showing progress or intermediate results while a tool is working.

For more information about the AG-UI protocol, see the AG-UI specification.

CopilotKit

AG-UI is the protocol that CopilotKit uses to connect to backend agents. Enabling the AG-UI add-on makes your agent directly compatible with CopilotKit without any additional adapter work. See Connect a CopilotKit frontend for the connection steps.

← PreviousStateNext →A2A

© 2026 pogue.dev. All rights reserved.

Creative CommonsCC BY 4.0
On this pageOverviewStarting a runMessageToolContext VariableSSE wire formatJSON PatchesEvent streamLifecycle eventsText message eventsTool call eventsState management eventsCustom eventsCopilotKit

Search docs

Search the agentc documentation