These docs track the main branch and may describe unreleased features. The stable documentation lives at docs.docker.com.

AG-UI Protocol

Overview

The docker agent serve ag-ui command starts an HTTP server that speaks the server side of the AG-UI protocol. An application sends a RunAgentInput and receives the run as a stream of AG-UI events over Server-Sent Events (SSE): assistant text, reasoning, tool calls and their results, and the agent of a team that is currently working.

Any AG-UI client can talk to the agent, whatever its language: the AG-UI client SDKs exist for TypeScript, Python, Go and more. You don't write protocol code.

First step of AG-UI support

This release covers a streaming chat. Human-in-the-loop, frontend tools, shared state and attachments are not implemented yet. See Current limitations.

Usage

# Start an AG-UI server for an agent
$ docker agent serve ag-ui ./agent.yaml
Listening on 127.0.0.1:8084
AG-UI endpoint: http://127.0.0.1:8084/ag-ui

# Pick one agent of a team as the entry point
$ docker agent serve ag-ui ./team.yaml --agent reviewer

# Use an agent from an OCI registry, on another address
$ docker agent serve ag-ui myorg/agent:tag --listen 127.0.0.1:9090

Flags

See the CLI reference for all flags, defaults, and shared runtime options.

Endpoint

Method Path Description
POST /ag-ui Takes a RunAgentInput JSON body and answers with text/event-stream
$ curl -N http://127.0.0.1:8084/ag-ui \
    -H 'Content-Type: application/json' \
    -d '{
      "threadId": "thread-1",
      "runId": "run-1",
      "messages": [{"id": "msg-1", "role": "user", "content": "Hello"}],
      "tools": [], "context": [], "state": {}, "forwardedProps": {}
    }'

Each event is one SSE frame. Its data line is the AG-UI event as JSON:

id: RUN_STARTED_1764345600000
data: {"type":"RUN_STARTED","timestamp":1764345600000,"threadId":"thread-1","runId":"run-1"}

id: TEXT_MESSAGE_START_1764345600120
data: {"type":"TEXT_MESSAGE_START","timestamp":1764345600120,"messageId":"56738741-aa2b-4dba-a1be-7f0e005043ce","role":"assistant"}

id: TEXT_MESSAGE_CONTENT_1764345600121
data: {"type":"TEXT_MESSAGE_CONTENT","timestamp":1764345600121,"messageId":"56738741-aa2b-4dba-a1be-7f0e005043ce","delta":"Hello!"}

id: TEXT_MESSAGE_END_1764345600300
data: {"type":"TEXT_MESSAGE_END","timestamp":1764345600300,"messageId":"56738741-aa2b-4dba-a1be-7f0e005043ce"}

id: RUN_FINISHED_1764345600301
data: {"type":"RUN_FINISHED","timestamp":1764345600301,"threadId":"thread-1","runId":"run-1"}

Use an AG-UI client SDK

With the TypeScript client (npm install @ag-ui/client):

import { HttpAgent } from "@ag-ui/client";

const agent = new HttpAgent({
  url: "http://127.0.0.1:8084/ag-ui",
  threadId: "thread-1",
});
agent.messages = [{ id: "msg-1", role: "user", content: "Hello" }];

await agent.runAgent({}, {
  onTextMessageContentEvent: ({ event }) => process.stdout.write(event.delta),
});

Threads and sessions

Each AG-UI thread is a Docker Agent session.

Before each resumed run, Docker Agent reapplies the selected agent's max_iterations, max_consecutive_tool_calls, max_old_tool_call_tokens and max_tool_result_tokens. The safety policy of a thread is preserved or tightened to the server's policy, never relaxed.

Event mapping

Docker Agent runtime event AG-UI event
Run started / stopped RUN_STARTED / RUN_FINISHED
Failed, canceled or cut-short run RUN_ERROR
Assistant text TEXT_MESSAGE_START / TEXT_MESSAGE_CONTENT / TEXT_MESSAGE_END
Reasoning REASONING_START / REASONING_MESSAGE_START / REASONING_MESSAGE_CONTENT / REASONING_MESSAGE_END / REASONING_END
Tool call being streamed by the model TOOL_CALL_START / TOOL_CALL_ARGS
Tool call dispatched / tool result TOOL_CALL_END / TOOL_CALL_RESULT
Hand-over to a sub-agent and back STEP_STARTED / STEP_FINISHED (stepName is the agent name)
Token usage, warning, session title, model fallback CUSTOM

Notes:

Input validation

The request is validated before anything is stored or run. An invalid request gets 400 Bad Request with a JSON body, {"error": "<reason>"}, and changes nothing: the same threadId still accepts a valid request.

Field Rule
threadId Required, at most 256 bytes. Starts with a letter or digit and contains only letters, digits, ., _ and - (a UUID qualifies).
runId Required, at most 256 bytes.
messages Every message needs an id of at most 256 bytes and a known role. The history must end with at least one user message; those trailing user messages need distinct ids and non-empty text content (a string, or a list of text parts). The content of earlier messages is not read.
tools Must be empty: frontend tools are not supported.
state Must be empty (null, {}): shared state is not supported.
resume Must be empty: interrupts are not supported.
context, forwardedProps Accepted and ignored.

tools, state and resume are rejected rather than silently ignored, so a client finds out immediately that a feature it relies on is missing.

Other responses:

Status When
401 --auth-token is set and the bearer token is missing or wrong.
403 No --auth-token, loopback listener, and the Host header is not a loopback name.
409 The thread has a run in progress, or its session ID is taken by another kind of session.
413 The request body is larger than 8 MiB.
415 Content-Type is not application/json.
503 The server is shutting down.

Shutdown and restart

When the server is stopped it rejects new runs with 503, closes the client connections, cancels the runs in progress and waits up to 10 seconds for them to stop, including the background agents of finished runs, which are stopped once their run ends. A run that has not stopped by then (typically a tool that ignores cancellation) is abandoned: the process exits without it.

Authentication and network exposure

Loopback listeners may run without authentication. Non-loopback listeners require --auth-token. Clients must send Authorization: Bearer <token>.

--insecure-no-auth lifts that requirement: anyone who can reach the address can then start runs, and their tools execute on the server under its tool safety policy. Use it only on a network you trust.

Two checks protect a server from web pages the user visits:

Browser access is off by default. Enable it with --cors-origin; it accepts comma-separated literal origins or ~-prefixed regular expressions. Allowed origins may send the Authorization, Content-Type and Accept headers. Preflight requests are answered without credentials. On a loopback listener without --auth-token, any page served from an allowed origin can start runs.

$ docker agent serve ag-ui ./agent.yaml --auth-token "$AG_UI_TOKEN" \
    --cors-origin http://localhost:3000

Tool safety

AG-UI threads default to the restricted tool safety policy. Precedence is the --safety flag, then agent YAML, then runtime YAML. YAML may select strict, balanced, or restricted; --safety autonomous is the only way to opt in to autonomous tool execution.

Nobody can approve a tool call over AG-UI yet. A tool call that the policy does not allow is denied, and the agent is told so. An elicitation request from an MCP server is declined.

Current limitations

See also

For OpenAI-compatible clients, see Chat Server. For agent-to-agent communication, see A2A. For full control over sessions and runtime events, see API Server.