Skip to content

AG-UI Protocol

The AG-UI adapter translates Awaken’s AgentEvent stream into the AG-UI (CopilotKit) event format. This enables CopilotKit frontends to drive Awaken agents with no custom adapter code.

POST /v1/ag-ui/run
{
"threadId": "optional-thread-id",
"agentId": "optional-agent-id",
"messages": [{ "role": "user", "content": "Hello" }],
"context": {}
}
FieldTypeRequiredDescription
messagesAgUiMessage[]yesChat messages with role and content strings.
threadIdstringnoExisting thread. Omit to create a new thread.
agentIdstringnoTarget agent. Uses the default agent when omitted.
contextobjectnoCopilotKit context forwarding (reserved).

SSE stream (text/event-stream). Each frame is a JSON-encoded AG-UI Event.

RouteMethodDescription
/v1/ag-ui/runPOSTStart a run and stream AG-UI events.
/v1/ag-ui/threads/:thread_id/runsPOSTStart a thread-scoped run.
/v1/ag-ui/agents/:agent_id/runsPOSTStart an agent-scoped run.
/v1/ag-ui/threads/:thread_id/interruptPOSTInterrupt the thread and supersede queued work.
/v1/ag-ui/threads/:thread_id/replayGETReplay durable protocol frames for a thread.
/v1/ag-ui/threads/:id/messagesGETRetrieve thread message history.

Replay requires a configured ProtocolReplayLog. It accepts ?cursor= or Last-Event-ID, plus ?limit= (default 100, max 500), and returns SSE frames with the protocol replay cursor as the SSE id. Missing replay storage returns 503; malformed cursors return 400; expired cursors return 410 Gone.

The AgUiEncoder is a stateful transcoder that manages text message and step lifecycles.

AgentEventAG-UI Event(s)
RunStartRUN_STARTED
TextDeltaTEXT_MESSAGE_START (if not open) + TEXT_MESSAGE_CONTENT
ReasoningDeltaREASONING_MESSAGE_START (if not open) + REASONING_MESSAGE_CONTENT
ToolCallStartClose text/reasoning, STEP_STARTED, TOOL_CALL_START
ToolCallDeltaTOOL_CALL_ARGS
ToolCallDoneTOOL_CALL_END, STEP_FINISHED
StateSnapshotSTATE_SNAPSHOT
StateDeltaSTATE_DELTA
RunFinish (success)Close text/reasoning, RUN_FINISHED
RunFinish (error)Close text/reasoning, RUN_ERROR

Events use an uppercase type discriminant:

  • RUN_STARTED / RUN_FINISHED / RUN_ERROR — run lifecycle
  • TEXT_MESSAGE_START / TEXT_MESSAGE_CONTENT / TEXT_MESSAGE_END — assistant text
  • REASONING_MESSAGE_START / REASONING_MESSAGE_CONTENT / REASONING_MESSAGE_END — reasoning trace
  • STEP_STARTED / STEP_FINISHED — step boundaries (wrapping tool calls)
  • TOOL_CALL_START / TOOL_CALL_ARGS / TOOL_CALL_END — tool call lifecycle
  • STATE_SNAPSHOT / STATE_DELTA — shared state synchronization
  • MESSAGES_SNAPSHOT — full thread message history

All events carry a BaseEvent with optional timestamp and rawEvent fields.

AG-UI messages use lowercase role strings: system, user, assistant, tool.

  1. First TextDelta emits TEXT_MESSAGE_START followed by TEXT_MESSAGE_CONTENT.
  2. Subsequent deltas emit only TEXT_MESSAGE_CONTENT.
  3. A ToolCallStart or RunFinish closes the open message with TEXT_MESSAGE_END.

Reasoning messages follow the same pattern with REASONING_MESSAGE_* events.