# CLI Reference


_Complete reference for all Docker Agent command-line commands and flags._

> [!TIP]
> **No config needed**
>
> Running `docker agent run` without a config argument uses `docker-agent.yaml`, `docker-agent.yml`, or `docker-agent.hcl` from the current directory when present. Otherwise, it uses a built-in default agent that is perfect for quick experimentation.

## Commands

### `docker agent run`

Launch the interactive TUI with an agent configuration (`.yaml`, `.yml`, or `.hcl`).

```bash
$ docker agent run [config] [message...] [flags]
```

| Flag                                    | Description                                                                                                                               |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `-a, --agent <name>`                    | Run a specific agent from the config                                                                                                      |
| `--yolo`                                | Auto-approve tool calls (unless explicitly denied). Legacy alias for `--safety autonomous`.                                              |
| `--safety <mode>`                       | Safety mode for tool approval: `strict` (ask for everything), `balanced` (auto-approve safe calls), `restricted` (auto-approve safe calls, deny the rest — fail-closed for unattended runs), or `autonomous` (approve everything). Wins over `--yolo` when both are given. Without the flag, the mode falls back to alias/user-config defaults, then the agent YAML's `agents.<name>.safety` / `runtime.safety`; a resumed session keeps its stored mode unless `--safety`/`--yolo` is passed explicitly. See [Safety Modes](/ai/docker-agent/configuration/permissions/#safety-modes). |
| `--model <ref>`                         | Override model(s). Use `provider/model` for all agents, or `agent=provider/model` for specific agents. Comma-separate multiple overrides. Inline overrides inherit each agent's explicit `parallel_tool_calls` setting only from a concrete, provider-qualified configured model. Existing named targets are authoritative on every invocation, including an omitted setting; harness, router, alloy/comma-list, `first_available`, providerless, and unresolved source models do not inherit it. |
| `--session <id>`                        | Resume a previous session. Supports relative refs (`-1` = newest by creation time, `-2` = second-newest, … — creation order, not last-used). An explicit ID that does not exist yet is created with that ID, so a supervisor can own the session ID upfront and reuse it across runs. |
| `-s, --session-db <path>`               | Path to the SQLite session database (default: `<data-dir>/session.db`, so `~/.cagent/session.db` unless `--data-dir` is set)              |
| `--session-read-only`                   | Open the TUI in read-only mode: conversation history is displayed but no new messages can be sent to the LLM. Cannot be used with `--exec`. |
| `--prompt-file <path>`                  | Include file contents as additional system context (repeatable)                                                                           |
| `--attach <path>`                       | Attach an image file to the initial message                                                                                               |
| `--dry-run`                             | Initialize the agent without executing anything (useful for validating a config)                                                          |
| `--remote <addr>`                       | Use a remote runtime at the given address instead of running the agent locally. Mutually exclusive with `--sandbox`, `--worktree`, `--worktree-pr`, `--worktree-base`, `--session`, `--session-db`, `--record`, and `--fake` — a remote runtime owns its own session storage and execution environment, so these local-only concerns don't apply. |
| `--remote-auth-token <token>`           | Bearer token for `--remote`. Defaults to `DOCKER_AGENT_REMOTE_AUTH_TOKEN`; the flag takes precedence. Prefer the environment variable to keep the token out of command-line arguments. |
| `--listen <addr>`                       | Expose this run's control plane over HTTP so an external process can drive the running TUI (send follow-ups, stream events, read the title). Accepts `host:port` or `unix://`, `npipe://`, `fd://`. Hidden from `docker agent run --help` — it's a stable but advanced/automation-oriented flag rather than a day-to-day one. See the [API Server](/ai/docker-agent/features/api-server/#listen) guide for the full walkthrough. |
| `--session-workingdir-root <path>`      | Confine the `working_dir` of sessions created through the `--listen` control plane to this directory and its descendants (default: no restriction — any clean host directory is accepted, though raw values containing `..` are rejected). Recommended when the control plane is reachable by other users. Hidden from `--help`, like `--listen`. |
| `--lean`                                | Use a simplified, non-alternate-screen TUI. Unlike the default full-screen TUI, this renders inline in the normal terminal buffer — useful in environments where an alternate screen is unwanted (e.g. inside tmux panes, CI with a tty, or log-friendly pipelines). Like the full TUI, displays an ASCII art banner on startup when the chat is empty (configurable via `show_banner` in [user settings](/ai/docker-agent/configuration/user-settings/)). |
| `--app-name <name>`                     | Override the application name label shown in the TUI (status bar, window title, "/exit" notifications).                                   |
| `--sidebar`                             | Control sidebar visibility. Set to `--sidebar=false` to hide the sidebar and disable the Ctrl+B toggle (default: `true`).                 |
| `--disable-commands <list>`             | Hide and disable specific slash commands in the TUI. Accepts a comma-separated list of command names (leading slash optional, case-insensitive). E.g. `--disable-commands="/cost,/eval,/model"`. |
| `--theme <name>`                        | Preselect a TUI theme by name, or `auto` to follow the terminal's light/dark background (overrides the theme from user config; ignored outside the interactive TUI) |
| `--on-event <type>=<cmd>`               | Run a shell command when an event of the given type fires (`*=<cmd>` matches any event). Repeatable.                                      |
| `--json`                                | Output results as newline-delimited JSON (use with `--exec`); with `--last`, output only the final answer as a JSON value                    |
| `--last`                                | Print only the final agent answer after all turns finish (requires `--exec`); omit thinking, tool calls/results, and intermediate responses |
| `--hide-tool-calls`                     | Hide tool calls in the output                                                                                                             |
| `--hide-tool-results`                   | Hide tool call results in the output                                                                                                      |
| `--sandbox`                             | Run the agent in sandbox mode using `sbx` (see [Sandbox](/ai/docker-agent/configuration/sandbox/))                                 |
| `--cloud` | Run in a fresh cloud sandbox without uploading host files/config/credentials; implies `--sandbox`. See [cloud sandbox mode](/ai/docker-agent/configuration/sandbox/#cloud-sandboxes). |
| `--sandbox-kit`, `--kit`, `--kit-arg` | Select an sbx workload and mixins, and pass kit arguments. Supports kits v3 through sbx. |
| `--sandbox-ttl` | Cloud sandbox lifetime, default `1h`; stopped on expiry and when the agent exits. |
| `--template <image>`                    | Template image for the sandbox (default: `docker/docker-agent-sbx-templates:latest`)                                                      |
| `--no-kit`                              | Disable the [auto-kit](/ai/docker-agent/configuration/sandbox/#auto-kit): do not stage skills or prompt files into the sandbox    |
| `--agent-picker [refs]`                 | Show a full-screen interactive picker before launching, letting you browse and select an agent. Accepts an optional comma-separated list of agent references to show (defaults to the built-in `default` and `coder` agents plus any agent configs found in `~/.agents`). Arrow keys navigate; `?` toggles the YAML preview panel; `l` (or mouse-click) toggles the **Lean Mode** checkbox to launch in the lean TUI; `b` (or clicking **[ Open Board ]**) opens the Kanban board (`docker agent board`) instead of running an agent; Enter confirms. Not available in `--exec` or non-TTY modes. |
| `-w, --worktree [name]`                 | Run the agent in a fresh git worktree of the working directory, isolating its changes from your checkout. Optionally name it (`--worktree=my-feature`); otherwise a name is generated. Requires the working directory to be inside a git repository. Every tool (the shell included) runs inside the worktree. Combine with `--working-dir` to branch from another repository, and with `--session` to resume into the same worktree later. Cannot be combined with `--remote` or `--sandbox`. When the session ends, a clean worktree is removed automatically; one with work prompts to keep or remove (never in `--exec`). |
| `--worktree-base <ref>`                  | Branch the `--worktree` from `<ref>` (a branch, tag, commit, or remote-tracking ref like `origin/main`) instead of the current `HEAD`. A remote-tracking ref is fetched first so the worktree starts from the latest remote state. Requires `--worktree`; cannot be combined with `--worktree-pr`, `--remote`, or `--sandbox`. |
| `--worktree-pr <number\|url>`            | Run the agent in a git worktree checked out on an existing GitHub pull request (PR number, `#123`, or PR URL). Continues the PR's branch so commits push back to it. Requires the [GitHub CLI](https://cli.github.com/) (`gh`). Cannot be combined with `--worktree`, `--remote`, or `--sandbox`. |
| `--working-dir <path>`                  | Set the working directory for the session (applies to tools and relative paths). In the full TUI, an explicitly supplied path also becomes the default directory for new sessions (`/new`, Ctrl+T, the `+` buttons); `/new <dir>` overrides it for one session |
| `--env-from-file <path>`                | Load environment variables from file (repeatable)                                                                                         |
| `--flavor <name>`                       | Enable a config flavor, a YAML patch defined under the config's `flavors` section (repeatable, applied in order). See [Flavors](/ai/docker-agent/configuration/flavors/). |
| `--code-mode-tools`                     | Provide a single tool to call other tools via JavaScript (forces code-mode tools globally)                                                |
| `--models-gateway <addr>`               | Route model and evaluator traffic through a gateway. Docker Desktop sign-in is required only for HTTPS `docker.com` gateways; loopback and third-party gateways need no Docker token. Also reads `DOCKER_AGENT_MODELS_GATEWAY` (legacy `CAGENT_MODELS_GATEWAY`) env var. |
| `--hook-pre-tool-use <cmd>`             | Add a pre-tool-use hook command (repeatable). See [Hooks](/ai/docker-agent/configuration/hooks/).                                  |
| `--hook-post-tool-use <cmd>`            | Add a post-tool-use hook command (repeatable)                                                                                             |
| `--hook-session-start <cmd>`            | Add a session-start hook command (repeatable)                                                                                             |
| `--hook-session-end <cmd>`              | Add a session-end hook command (repeatable)                                                                                               |
| `--hook-on-user-input <cmd>`            | Add an on-user-input hook command (repeatable)                                                                                            |
| `--hook-stop <cmd>`                     | Add a stop hook command, fired when the model finishes responding (repeatable)                                                            |
| `--fake <path>`                         | Replay AI responses from a cassette file (for testing). Mutually exclusive with `--record`.                                               |
| `--fake-stream [ms]`                    | When replaying with `--fake`, simulate streaming with a delay between chunks (defaults to 15ms when given without a value).               |
| `--record [path]`                       | Record AI API interactions to a cassette file and generate a TUI e2e test from the session (auto-generates filename if no path given). Routes through `--models-gateway` when one is configured. Encrypted agent config and its digest are never stored in cassettes. |
| `-d, --debug`                           | Enable debug logging                                                                                                                      |
| `--log-file <path>`                     | Custom debug log location                                                                                                                 |
| `-o, --otel`                            | Enable OpenTelemetry observability: traces, metrics, and logs. Requires `OTEL_EXPORTER_OTLP_ENDPOINT` to export to a collector. |

```bash
# Examples
$ docker agent run agent.yaml
$ docker agent run agent.yaml "Fix the bug in auth.go"
$ docker agent run agent.yaml -a developer --yolo
$ docker agent run agent.yaml --model anthropic/claude-sonnet-4-5
$ docker agent run agent.yaml --model "dev=openai/gpt-4o,reviewer=anthropic/claude-sonnet-4-5"
$ docker agent run agent.yaml --session -1  # resume last session
$ docker agent run agent.yaml --session -1 --session-read-only  # review last session without sending messages
$ docker agent run agent.yaml --prompt-file ./context.md  # include file as context

# Add hooks from the command line
$ docker agent run agent.yaml --hook-session-start "./scripts/setup-env.sh"
$ docker agent run agent.yaml --hook-pre-tool-use "./scripts/validate.sh" --hook-post-tool-use "./scripts/log.sh"

# Queue multiple messages (processed in sequence)
$ docker agent run agent.yaml "question 1" "question 2" "question 3"

# Customize TUI display
$ docker agent run agent.yaml --app-name "My Project"
$ docker agent run agent.yaml --sidebar=false
$ docker agent run agent.yaml --disable-commands="/cost,/eval,/model"

# Browse and pick an agent interactively
$ docker agent run --agent-picker
$ docker agent run --agent-picker=myorg/coder,myorg/researcher
```

> [!TIP]
> **Lean, inline TUI**
>
> Pass `--lean` to get a lightweight TUI that renders inline in your terminal (no alternate screen). Like the full TUI, it displays an ASCII art banner on startup when the chat is empty (configurable via `show_banner` in [user settings](/ai/docker-agent/configuration/user-settings/)), and supports the same slash commands and streaming output, making it handy inside tmux, scripts, or any context where a full-screen takeover is unwanted.

> [!TIP]
> **Background animations in tmux**
>
> When tmux supports visibility detection, Docker Agent pauses animations and defers redraws only when the pane is hidden: in a detached session, a window no client is viewing, or behind a zoomed sibling. Agent execution and streamed responses continue, and visible unfocused split panes keep updating. No tmux configuration is required; visibility is checked about once per second. Enabling `set -g focus-events on` also lets a focus event refresh a newly visible pane immediately. Rendering stays enabled on older tmux versions without the required formats, while chooser previews are open, or when control-mode clients (such as iTerm2 integration) are attached, since previews and frontends may display otherwise hidden panes.

> [!TIP]
> **Isolate a run in a git worktree**
>
> When the working directory is inside a git repository, `--worktree` creates a fresh [git worktree](https://git-scm.com/docs/git-worktree) and points the session at it, so the agent's edits land on a separate branch and never touch your checkout. Every tool — the shell included — runs inside the worktree. The worktree is stored under `<data-dir>/worktrees/<name>` on a branch named `worktree-<name>`.

```bash
# Run in an isolated worktree with a generated name (e.g. "focused_turing")
$ docker agent run agent.yaml --worktree
$ docker agent run agent.yaml -w "Refactor the auth package"

# Give the worktree (and its branch) an explicit name
$ docker agent run agent.yaml --worktree=auth-refactor

# Branch the worktree from another ref instead of the current HEAD.
# A remote-tracking ref is fetched first, so the worktree starts from the
# latest remote state.
$ docker agent run agent.yaml --worktree=auth-refactor --worktree-base origin/main

# Resume a worktree run later: the session remembers its worktree, so you
# don't pass --worktree again (which would fail — the worktree already exists).
$ docker agent run agent.yaml --worktree=auth-refactor   # first run, creates it
$ docker agent run agent.yaml --session -1               # resumes into the same worktree

# Check out an existing GitHub pull request to continue it (requires gh)
$ docker agent run agent.yaml --worktree-pr 123
$ docker agent run agent.yaml --worktree-pr https://github.com/owner/repo/pull/123
```

With `--worktree-pr`, the PR's head branch is checked out tracking its remote (via the [GitHub CLI](https://cli.github.com/)), so commits made during the run push straight back to the pull request. The worktree is stored under `<data-dir>/worktrees/pr-<number>`.

When the interactive session ends, the worktree is cleaned up based on its state:

- **Clean** (no uncommitted changes, untracked files, or new commits): the worktree and its branch are removed automatically.
- **Has work** (uncommitted changes, untracked files, or new commits): you're prompted to keep or remove it. Keeping preserves the directory and branch so you can return later; removing discards the worktree, its branch, and all that work.
- **Non-interactive runs** (`--exec`): the worktree is never cleaned up — it's left in place for inspection.

A worktree is only ever removed if `--worktree` created it for this run; a pre-existing worktree is never touched.

A kept worktree can be resumed: pass `--session` (a relative ref like `-1`, or the session id) and the run reattaches to the same worktree directory and branch automatically. Don't re-pass `--worktree` on resume — that would try to create a new worktree and fail because it already exists.

### `docker agent run --exec`

Run an agent in non-interactive (headless) mode. No TUI — output goes to stdout.

```bash
$ docker agent run --exec [config] [message...] [flags]
```

```bash
# One-shot task
$ docker agent run --exec agent.yaml "Create a Dockerfile for a Python Flask app"

# With auto-approve
$ docker agent run --exec agent.yaml --yolo "Set up CI/CD pipeline"

# Multi-turn conversation
$ docker agent run --exec agent.yaml "question 1" "question 2" "question 3"

# Only the final answer (no transcript)
$ docker agent run --exec --last agent.yaml "Summarize this repository"

# Only the final answer as a JSON value
$ docker agent run --exec --last --json agent.yaml "Generate a report"
```

`--last` buffers the answer until all supplied messages have been processed, then prints only the final response from the last turn. It requires a message argument or piped input and does not prompt for tool approvals or elicitation: pending requests are declined, as in `--json` mode. Configure permissions or a safety mode for unattended tool use. Errors fail the command without printing a partial answer.

With `--last --json`, a valid JSON answer is emitted directly (not wrapped in a runtime event or double-encoded); a plain-text answer is encoded as a JSON string. Without `--json`, the answer is printed as text, including any structured JSON the agent produced. `--json` without `--last` still emits the full NDJSON event stream.

### `docker agent new`

Interactively generate a new agent configuration file.

```bash
$ docker agent new [flags]

# Examples
$ docker agent new
$ docker agent new --model openai/gpt-5
$ docker agent new --model dmr/ai/gemma3-qat:12B --max-iterations 15
```

### `docker agent getting-started`

Run a short (about 2 minutes), skippable interactive tour inside the chat UI: sending messages, approving tool calls, the command palette (<kbd>Ctrl</kbd>+<kbd>K</kbd>), slash commands, and how agents are configured. Aliased as `docker agent tour`. Requires an interactive terminal.

```bash
$ docker agent getting-started
```

Replay it anytime with this command, or with the `/getting-started` slash command inside a running TUI session.

### `docker agent models`

List models available for use with `--model`. By default only shows models for providers you have credentials for. Aliases: `docker agent models list`, `docker agent models ls`.

```bash
$ docker agent models [flags]
```

| Flag                   | Default | Description                                                                        |
| ---------------------- | ------- | ---------------------------------------------------------------------------------- |
| `-p, --provider <id>`  | (none)  | Filter models by provider name (e.g. `openai`, `anthropic`, `dmr`, `ollama`, …).   |
| `--format <fmt>`       | `table` | Output format: `table` or `json`.                                                  |
| `-a, --all`            | `false` | Include models from all providers, not just those you have credentials for.        |

```bash
# Examples
$ docker agent models                                 # only providers you can use
$ docker agent models --all                           # every provider the catalog knows about
$ docker agent models --provider openai
$ docker agent models --format json | jq
```

Provider filters are case-insensitive. For built-in providers, legacy and canonical names match the same models (`fireworks` / `fireworks-ai`, `together` / `togetherai`, `moonshot` / `moonshotai`, and `opencode-zen` / `opencode`), including gateway listings. Gateway model references retain the prefix returned by the gateway. A configured custom provider name takes precedence over a built-in alias and is matched by its own name without alias expansion.

When a models gateway is configured (`--models-gateway`, `DOCKER_AGENT_MODELS_GATEWAY`, or the user config), the command first queries the gateway's `/v1/models` endpoint. A non-empty response is authoritative for the models routed through the gateway: the listing shows the models the gateway serves (`--provider` filters within it), alongside any custom providers you have configured, which serve their models from their own endpoints rather than through the gateway. If the gateway cannot be queried or serves no usable model (endpoint not implemented, empty list, invalid response, timeout, missing authentication), the command falls back to the providers you have configured directly — provider API keys, provider aliases, and custom providers — plus the model catalog; a failure of one source never prevents the others from being listed. Docker Desktop authentication is required only for HTTPS `docker.com` gateways. An available Docker Desktop token may also be sent to trusted loopback gateways, but is never sent to third-party gateways.

### `docker agent toolsets`

List the built-in toolset types available for use in an agent configuration. Each type can be referenced under `toolsets:` in an agent YAML file. Use this to discover what's available without leaving the terminal.

```bash
$ docker agent toolsets [flags]
```

| Flag             | Default | Description                       |
| ---------------- | ------- | --------------------------------- |
| `--format <fmt>` | `table` | Output format: `table` or `json`. |

```bash
# Examples
$ docker agent toolsets                                # human-readable table
$ docker agent toolsets --format json | jq             # machine-readable (type, summary, docs URL)
```

### `docker agent setup`

Set up a model interactively. Four paths:

- **Built-in cloud provider**: pick a provider Docker Agent already knows (Anthropic, OpenAI, Google, Groq, Hugging Face, ...) and connect it. Credentials vary by provider: most take an API key or token, stored in the Docker Agent env file `~/.config/cagent/.env`, while `chatgpt` signs in with your ChatGPT account in the browser.
- **Local model**: check Docker Model Runner and pull a model. No API key needed.
- **Custom OpenAI-compatible endpoint**: register an endpoint that is not built in (vLLM, LiteLLM, a corporate gateway, ...) with its base URL, API format, and API key variable, saved to your [user configuration](/ai/docker-agent/providers/custom/#global-providers-user-configuration) so its models work everywhere via `--model <name>/<model>`.
- **Claude Code harness**: use a Claude subscription through the official `claude` CLI. The wizard checks that the CLI is installed and logged in, offers to run `claude auth login --claudeai` (only after you confirm), and writes a ready-to-run `claude-code-agent.yaml`. See [Coding Harnesses](/ai/docker-agent/features/harnesses/).

Ends with the exact command to start chatting. Secret values are never printed, and Docker Agent never reads or copies the Claude CLI's credentials.

The wizard is also offered automatically when an interactive run finds no usable model (decline-able; set `DOCKER_AGENT_NO_SETUP=1` to suppress the offer).

```bash
$ docker agent setup
```

### `docker agent doctor`

Diagnose the model and credential setup. Reports which model providers have credentials and where each credential comes from (shell environment, env file, Docker Desktop, …), whether Docker Model Runner is reachable and which models are pulled, and which model the `auto` selection would pick. Secret values are never printed. Exits with a non-zero status when an issue would prevent an agent from running, which makes it usable in scripts and CI.

```bash
$ docker agent doctor [agent-file|registry-ref] [flags]
```

With an agent file, also lists the environment variables that file requires (model credentials and tool secrets such as `GITHUB_PERSONAL_ACCESS_TOKEN`), whether each one is set, and from which source. When the file declares a [`claude-code` harness](/ai/docker-agent/features/harnesses/) agent, the doctor additionally checks that the official `claude` CLI is installed and logged in, reporting its version and safe login metadata (auth method, API provider, subscription type — never your email, organization, or tokens); a missing or logged-out CLI is reported as an issue with the `claude auth login --claudeai` remediation.

| Flag                     | Default | Description                                                    |
| ------------------------ | ------- | -------------------------------------------------------------- |
| `--json`                 | `false` | Output the full report in JSON format (for scripting).         |
| `--env-from-file <file>` | (none)  | Also check variables supplied by an env file.                  |
| `--models-gateway <url>` | (none)  | Diagnose against a models gateway (credentials come from it).  |

```bash
# Examples
$ docker agent doctor                        # credential, DMR, and auto-selection state
$ docker agent doctor ./agent.yaml           # also check that file's requirements
$ docker agent doctor --json | jq .issues
```

### `docker agent serve api`

Start the HTTP API server for programmatic access. The argument can be a single agent file, a registry reference, or a directory — when given a directory, every `.yaml`/`.yml`/`.hcl` file in it is exposed as a separate entry under `/api/agents`.

```bash
$ docker agent serve api <agent-file>|<agents-dir>|<registry-ref> [flags]
```

| Flag                       | Default            | Description                                                                                                |
| -------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------- |
| `-l, --listen <addr>`      | `127.0.0.1:8080`   | Address to listen on.                                                                                      |
| `--auth-token <token>`     | (none)             | Require `Authorization: Bearer <token>` for API requests. Mandatory for non-loopback TCP listeners; optional for loopback and local sockets. The `/health` and `/ready` probes are exempt. |
| `--max-request-size <bytes>` | `1048576` (1 MiB) | Maximum request body size. Requests exceeding this limit are rejected with HTTP 413 — see [Troubleshooting: HTTP 413](/ai/docker-agent/guides/troubleshooting/#http-413-request-body-too-large).                      |
| `--session-workingdir-root <path>` | (none)     | Confine the `working_dir` of sessions created via `POST /api/sessions` to this directory and its descendants (symlinks are resolved before the check). Unrestricted by default — any clean host directory is accepted (raw values containing `..` are rejected), as local single-user daemons rely on. Recommended for multi-user or network-exposed deployments. |
| `--stream-coalesce-window <duration>` | `50ms`  | Merge consecutive streaming deltas (text, reasoning, tool-call arguments, tool output) that arrive within this window into a single SSE event. The first delta after a quiet spell is sent at once. `0` sends one event per delta. See [Streaming Responses](/ai/docker-agent/features/api-server/#streaming-responses). |
| `-s, --session-db <path>`  | `session.db`       | Path to the SQLite session database (relative paths resolve against the working directory).                |
| `--pull-interval <minutes>`| `0`                | Periodically re-pull OCI/URL references and refresh the agent definition. `0` disables auto-pull.          |
| `--fake <path>`             | (none)             | Replay AI responses from a cassette file (for testing). Mutually exclusive with `--record`.               |
| `--record <path>`           | (none)             | Record AI API interactions to a cassette file. Routes through `--models-gateway` when one is configured; encrypted agent config and its digest are omitted from cassettes. |
| `--mcp-oauth-redirect-uri <url>` | (none)        | OAuth redirect URI for the unmanaged MCP OAuth flow in server mode. When set, the runtime drives PKCE and code exchange in-process and sends the full authorize URL to the client via elicitation. See [Remote MCP](/ai/docker-agent/features/remote-mcp/) for details. |

> **Diagnostics:** Set `DOCKER_AGENT_PPROF_ADDR=127.0.0.1:6060` (legacy `CAGENT_PPROF_ADDR` is also supported), or use `--pprof-addr`, a hidden flag, to start a live Go pprof server at `/debug/pprof/`. Use a loopback address; a non-loopback binding logs a security warning.

All [runtime configuration flags](#runtime-configuration-flags) (`--working-dir`, `--env-from-file`, `--models-gateway`, `--hook-*`, …) are also accepted.

```bash
# Examples
$ docker agent serve api agent.yaml
$ docker agent serve api agent.yaml --listen :8080 --auth-token "$AGENT_TOKEN"
$ docker agent serve api ./agents/                          # directory of agent YAML/HCL configs
$ docker agent serve api ociReference --pull-interval 10    # auto-refresh
```

See [API Server](/ai/docker-agent/features/api-server/) for the full HTTP API reference.

### `docker agent serve mcp`

Expose agents as MCP tools for use in Claude Desktop, Claude Code, or other MCP clients. Defaults to stdio transport; use `--http` to start a streaming HTTP server instead.

```bash
$ docker agent serve mcp <config> [flags]
```

| Flag                   | Default            | Description                                                                                       |
| ---------------------- | ------------------ | ------------------------------------------------------------------------------------------------- |
| `-a, --agent <name>`   | (all agents)       | Name of the agent to expose. If omitted, every agent in the config is exposed as a separate tool. |
| `--tool-name <name>`   | (agent name)       | Override the MCP tool identifier clients call; only valid when exposing a single agent.           |
| `--http`               | `false`            | Use streaming HTTP transport instead of stdio.                                                    |
| `--safety <policy>`    | `restricted`       | HTTP MCP safety policy; no effect on stdio or `--attach`.                                         |
| `--auth-token <token>` | (none)             | Required Bearer token for HTTP MCP requests.                                                       |
| `--insecure-no-auth`   | `false`            | Permit unauthenticated non-loopback HTTP MCP binding.                                              |
| `-l, --listen <addr>`  | `127.0.0.1:8081`   | Address to listen on (only used with `--http`).                                                   |
| `--mcp-keepalive <dur>` | `0` (disabled)    | Interval between MCP keep-alive pings (e.g. `30s`). Only when serving an agent over stdio — rejected with `--http` (the stateless HTTP transport, MCP `2026-07-28`, has no server-initiated ping) and with `--attach`. |
| `--attach [target]`    | (none)             | Attach to a running TUI run by pid, address, or session id; given without a value, selects the most recent run.   |

All [runtime configuration flags](#runtime-configuration-flags) are also accepted.

```bash
# Examples
$ docker agent serve mcp agent.yaml                                # stdio transport
$ docker agent serve mcp agent.yaml --http --listen 127.0.0.1:9090 # streaming HTTP
$ docker agent serve mcp agent.yaml --working-dir /path/to/project
$ docker agent serve mcp myorg/coder
```

See [MCP Mode](/ai/docker-agent/features/mcp-mode/) for detailed setup.

### `docker agent serve a2a`

Start an A2A (Agent-to-Agent) protocol server.

```bash
$ docker agent serve a2a <config> [flags]
```

| Flag                   | Default            | Description                                                                                |
| ---------------------- | ------------------ | ------------------------------------------------------------------------------------------ |
| `-a, --agent <name>`   | (team default)     | Name of the agent to run. Defaults to the team's first agent if not specified.             |
| `-l, --listen <addr>`  | `127.0.0.1:8082`   | Address to listen on.                                                                       |
| `--auth-token <token>` | (none)             | Bearer token required for agent-card and invocation requests.                              |
| `--cors-origin <origins>` | (none)          | Allowed browser origins, comma-separated; empty disables CORS.                             |
| `--insecure-no-auth`   | `false`            | Allow an unauthenticated non-loopback listener (unsafe).                                   |
| `--safety <policy>`    | `restricted`       | Tool safety policy; `autonomous` is permitted only through this explicit CLI flag.         |
| `-s, --session-db <path>` | `<data-dir>/session.db` | Path to the SQLite session database.                                                 |

All [runtime configuration flags](#runtime-configuration-flags) are also accepted.

```bash
# Examples
$ docker agent serve a2a agent.yaml
$ docker agent serve a2a agent.yaml --listen 127.0.0.1:9000
$ docker agent serve a2a myorg/agent:tag
```

### `docker agent serve acp`

Start an ACP (Agent Client Protocol) server over stdio. This allows external clients to interact with your agents using the ACP protocol.

```bash
$ docker agent serve acp <config> [flags]
```

| Flag                      | Default                     | Description                                       |
| ------------------------- | --------------------------- | ------------------------------------------------- |
| `-s, --session-db <path>` | `<data-dir>/session.db`     | Path to the SQLite session database.              |

All [runtime configuration flags](#runtime-configuration-flags) are also accepted.

```bash
# Examples
$ docker agent serve acp agent.yaml
$ docker agent serve acp ./team.yaml
$ docker agent serve acp myorg/agent:tag
```

See [ACP](/ai/docker-agent/features/acp/) for details on the Agent Client Protocol.

### `docker agent serve chat`

Start an HTTP server that exposes one or more agents through an **OpenAI-compatible Chat Completions API** at `/v1/chat/completions` and `/v1/models`. This lets any tool that already speaks the OpenAI protocol — for example [Open WebUI](https://github.com/open-webui/open-webui), `curl`, the OpenAI Python SDK, or LangChain — drive a Docker Agent agent without any custom integration.

```bash
$ docker agent serve chat <config> [flags]
```

| Flag                          | Default            | Description                                                                                                       |
| ----------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------- |
| `-a, --agent <name>`          | (all agents)       | Name of the agent to expose. If omitted, every agent in the config is exposed as a separate model.                |
| `-l, --listen <addr>`         | `127.0.0.1:8083`   | Address to listen on.                                                                                             |
| `--cors-origin <origin>`      | (none)             | Allowed CORS origin (e.g. `https://example.com`). Empty disables CORS.                                            |
| `--api-key <token>`           | (none)             | Required Bearer token clients must present (`Authorization: Bearer <token>`). Empty disables auth.                |
| `--api-key-env <name>`        | (none)             | Read the required API key from this non-empty environment variable.                                      |
| `--insecure-no-auth`           | `false`            | Permit unauthenticated non-loopback binding.                                                                  |
| `--safety <policy>`            | `restricted`       | Tool safety policy; CLI value overrides agent/runtime configuration.                                           |
| `--max-request-size <bytes>`  | `1048576` (1 MiB)  | Maximum request body size. Requests exceeding this limit are rejected with HTTP 413 — see [Troubleshooting: HTTP 413](/ai/docker-agent/guides/troubleshooting/#http-413-request-body-too-large).                                                                                        |
| `--request-timeout <dur>`     | `5m`               | Per-request timeout (covers model + tool calls + streaming).                                                      |
| `--conversations-max <n>`     | `0`                | Cache up to N conversations server-side, keyed by `X-Conversation-Id`. `0` disables — clients must resend history. |
| `--conversation-ttl <dur>`    | `30m`              | Idle TTL after which a cached conversation is evicted.                                                            |
| `--max-idle-runtimes <n>`     | `4`                | Maximum number of idle runtimes pooled per agent. `0` disables pooling.                                           |

```bash
# Examples
$ docker agent serve chat agent.yaml
$ docker agent serve chat ./team.yaml --agent reviewer
$ docker agent serve chat myorg/agent:tag --listen 127.0.0.1:9090
$ docker agent serve chat agent.yaml --api-key-env CHAT_BEARER_TOKEN

# Drive it from any OpenAI-compatible client
$ curl http://127.0.0.1:8083/v1/chat/completions \
    -H 'Content-Type: application/json' \
    -d '{"model": "root", "messages": [{"role": "user", "content": "hello"}]}'
```

See [Chat Server](/ai/docker-agent/features/chat-server/) for the full feature reference.

### `docker agent board`

Launch a full-screen Kanban TUI for orchestrating multiple agents at once. Each card runs an agent in its own tmux session on an isolated git worktree; moving a card forward through the pipeline (Dev → Review → Push → Done) delivers the destination column's prompt to that card's agent. Projects and column prompts are stored in the global config file (`~/.config/cagent/config.yaml`) and can be managed from the TUI.

```bash
$ docker agent board
```

Takes no arguments or flags. Requires `tmux` and `git` to be installed.

See [Kanban Board](/ai/docker-agent/features/board/) for key bindings, configuration, and workflow details.

### `docker agent share push` / `docker agent share pull`

Share agents via OCI registries.

```bash
# Push an agent
$ docker agent share push ./agent.yaml docker.io/username/my-agent:latest

# Pull an agent
$ docker agent share pull docker.io/username/my-agent:latest

# Force pull, overwriting the local copy
$ docker agent share pull docker.io/username/my-agent:latest --force

# Sign on push, verify on pull
$ docker agent share push ./agent.yaml docker.io/username/my-agent:latest --key file://~/.ssh/id_ed25519
$ docker agent share pull docker.io/username/my-agent:latest --key file://~/.ssh/id_ed25519.pub
```

| Flag        | Applies to | Description                                                                                       |
| ----------- | ---------- | ------------------------------------------------------------------------------------------------- |
| `--force`   | `pull`     | Force pull even if the configuration already exists locally                                       |
| `--key`     | both       | Key (inline, or `file://<path>`) used to sign/encrypt the agent on push, or verify it on pull     |
| `--encrypt` | `push`     | Also embed an encrypted copy of the agent in the manifest annotations (needs `--key`)             |

Signing records a DSSE envelope over an in-toto Statement v1 in the `io.docker.agent.attestation` annotation, so the attestation interoperates with cosign and in-toto tooling. On pull, the attested reference is checked against the one requested — a signed artifact copied to another repository or tag is rejected — and the verified metadata is printed:

```console
$ docker agent share pull docker.io/username/my-agent:latest --key file://~/.ssh/id_ed25519.pub
Verified signature (ed25519)
  image:   index.docker.io/username/my-agent:latest
  digest:  sha256:889871ef…
  created: 2026-09-11T08:30:00Z
```

See [Signing and encrypting agents](/ai/docker-agent/concepts/distribution/#signing-and-encrypting-agents) for key formats and the security model.

See [Agent Distribution](/ai/docker-agent/concepts/distribution/) for full registry workflow details.

### `docker agent sessions diff`

Compare two recorded sessions and report the first point where the agent behaved
differently — the triage answer when a task that worked yesterday does not work
today.

```bash
$ docker agent sessions diff <session-a> <session-b> [flags]
```

```console
$ docker agent sessions diff -1 -2
Comparing a1b2c3d4 (7 turns) against e5f6a7b8 (9 turns)

❌ First divergence at turn 3 (after 3 matching turn(s)).
   a1b2c3d4 called:
     read_file({"path":"pkg/cache/cache.go"})
   e5f6a7b8 called:
     search_files_content({"query":"persistToDisk","path":"."})

Everything after this point is downstream of the divergence and is not compared.
```

Session references accept a full ID, a unique ID prefix, or a relative form such
as `-1` for the most recent run.

| Flag                    | Default                 | Description                                    |
| ----------------------- | ----------------------- | ------------------------------------------------ |
| `-s, --session-db`      | `<data-dir>/session.db` | Path to the session database                   |
| `--json`                | `false`                 | Emit the comparison as JSON                    |
| `--fail-on-divergence`  | `false`                 | Exit non-zero when the two sessions diverge    |

Comparison is over the sequence of tool calls, not the assistant's prose: model
output is nondeterministic, so two runs of the same task almost always word
things differently while doing the same work. Turns taken by delegated
sub-agents are included in sequence. Reporting stops at the first divergence —
everything after it is downstream of that difference.

This locates *where* two runs diverged, not *why*. Re-running a session against
a different model while holding the environment fixed is a separate, unbuilt
feature.

### `docker agent eval`

Run agent evaluations against a directory of recorded sessions.

```bash
$ docker agent eval <agent-file>|<registry-ref> [<eval-dir>|./evals] [flags]
```

| Flag                | Default                              | Description                                                                |
| ------------------- | ------------------------------------ | -------------------------------------------------------------------------- |
| `-c, --concurrency` | num CPUs                             | Number of concurrent evaluation runs                                       |
| `--judge-model`     | Depends on `--judge-type` | Judge model (`provider/model`) or named evaluator; defaults to `openai/gpt-5.6-terra` for `llm`, `typesafe/jev-latest` for `evaluator`      |
| `--judge-type`      | `llm` | Judge backend: `llm` or `evaluator` |
| `--output <dir>`    | `<eval-dir>/results`                 | Directory for results, logs, and session databases                         |
| `--only <pattern>`  | (all)                                | Only run evals with file names matching these patterns (repeatable)        |
| `--base-image`      | (default)                            | Custom base image for eval containers                                      |
| `--agent-image`     | (this CLI's version)                 | docker-agent image injected into eval containers; `none` skips injection   |
| `--container-runtime` | `docker`                           | Container runtime executable for building and running evaluations (e.g. `podman`) |
| `--keep-containers` | `false`                              | Keep containers after evaluation (don't remove with `--rm`)                |
| `-e, --env`         | (none)                               | Environment variables to pass to container (`KEY` or `KEY=VALUE`, repeatable) |
| `--repeat <n>`      | `1`                                  | Number of times to repeat each evaluation (useful for computing baselines) |
| `--baseline <file>` | (none)                               | Compare against a previously saved run JSON (`<output>/<run>.json`) and exit non-zero on regression |
| `--regression-tolerance <n>` | `0`                         | How far an aggregate quality rate may fall before `--baseline` reports a regression (0–1) |

All [runtime configuration flags](#runtime-configuration-flags) are also accepted.

```bash
# Examples
$ docker agent eval agent.yaml                            # use ./evals
$ docker agent eval agent.yaml ./my-evals                 # custom directory
$ docker agent eval agent.yaml -c 8                       # 8 concurrent evaluations
$ docker agent eval agent.yaml --keep-containers          # keep containers for debugging
$ docker agent eval agent.yaml --only "auth*"             # only run matching evals
$ docker agent eval agent.yaml --repeat 5                 # repeat each eval 5 times
$ docker agent eval agent.yaml --container-runtime podman # use a Docker-compatible runtime such as Podman
```

See [Evaluation](/ai/docker-agent/features/evaluation/) for details on creating eval sessions and interpreting results.

### `docker agent version`

Print the version and commit hash for your `docker-agent` install.

```bash
$ docker agent version
docker agent version v1.54.0
Commit: 1737035c
```

### `docker agent alias`

Manage agent aliases for quick access.

```bash
# List aliases
$ docker agent alias ls

# List aliases as JSON
$ docker agent alias list --json

# Add an alias
$ docker agent alias add pirate /path/to/pirate.yaml
$ docker agent alias add other ociReference

# Add an alias with runtime options
$ docker agent alias add yolo-coder myorg/coder --yolo
$ docker agent alias add careful-coder myorg/coder --safety balanced
$ docker agent alias add fast-coder myorg/coder --model openai/gpt-4o-mini
$ docker agent alias add safe-coder myorg/coder --sandbox
$ docker agent alias add turbo myorg/coder --yolo --model anthropic/claude-sonnet-4-5

# Use an alias
$ docker agent run pirate
$ docker agent run yolo-coder
```

**Alias Options:** Aliases can include runtime options that apply automatically when used:

- `--yolo` — Auto-approve tool calls (unless explicitly denied) when running the alias. Legacy alias for `--safety autonomous`.
- `--safety <mode>` — Default [safety mode](/ai/docker-agent/configuration/permissions/#safety-modes) (`strict`, `balanced`, `restricted`, or `autonomous`) when running the alias. Wins over the alias's `yolo` option; both are stored declaratively in the user config (`aliases.<name>.safety` / `aliases.<name>.yolo`), so you can also edit them there by hand.
- `--model <ref>` — Override the model for the alias
- `--hide-tool-results` — Hide tool call results in the TUI when running the alias
- `--sandbox` — Always run the alias inside a [Docker sandbox](/ai/docker-agent/configuration/sandbox/)

Alias safety options are defaults for new sessions: an explicit `--safety`/`--yolo` on the command line wins over them, they win over `settings.safety`/`settings.YOLO` and over anything declared in the agent YAML, and they never change the mode of a resumed session.

When listing aliases, options are shown in brackets:

```bash
$ docker agent alias ls
Registered aliases (3):

  fast-coder  → myorg/coder [model=openai/gpt-4o-mini]
  turbo       → myorg/coder [yolo, model=anthropic/claude-sonnet-4-5]
  yolo-coder  → myorg/coder [yolo]

Run an alias with: docker agent run <alias>
```

Pass `--json` to output aliases as a JSON array instead of the formatted table. Each entry includes the alias `name` and its options:

```bash
$ docker agent alias list --json
[
  {
    "name": "fast-coder",
    "path": "myorg/coder",
    "model": "openai/gpt-4o-mini"
  },
  {
    "name": "turbo",
    "path": "myorg/coder",
    "yolo": true,
    "model": "anthropic/claude-sonnet-4-5"
  },
  {
    "name": "yolo-coder",
    "path": "myorg/coder",
    "yolo": true
  }
]
```

JSON output is sorted by name and omits false/zero-valued fields. This is useful for scripting and automation.

> [!TIP]
> **Override alias options**
>
> Command-line flags override alias options. For example, `docker agent run yolo-coder --yolo=false` disables yolo mode even though the alias has it enabled.

> [!TIP]
> **Set a default agent**
>
> Create a `default` alias to customize what `docker agent` starts with no arguments:
>
> ```console
> $ docker agent alias add default /my/default/agent.yaml
> ```
>
> Then simply run `docker agent` — it will launch that agent automatically.

### `docker agent sandbox`

Manage settings shared by every [`--sandbox`](/ai/docker-agent/configuration/sandbox/) run — today, the persistent network allowlist that turns a `Blocked by network policy` 403 into a one-line, durable fix:

```bash
# Allow a host on every subsequent --sandbox run.
$ docker agent sandbox allow api.example.com

# Or several at once.
$ docker agent sandbox allow api.example.com registry.npmjs.org:443

# See what's persisted in ~/.config/cagent/config.yaml.
$ docker agent sandbox list

# Drop a host you no longer need.
$ docker agent sandbox deny api.example.com
```

Entries are unioned with the gateway, the kit-resolved tool install hosts, and any `runtime.network_allowlist` declared by the agent. The launch summary lists every source separately so you can see which holes were punched by which layer.

### `docker agent plans`

Manage the plans agents collaborate on, from the host — without starting a session: the named, versioned documents of the [plan toolset](/ai/docker-agent/tools/plan/). Fully manageable: create, update, set status, export, delete.

```bash
$ docker agent plans <subcommand> [flags]
```

| Subcommand | Description |
| ---------- | ----------- |
| `list` | List plans with scope, name, status, version, updated time, and title. Plans that exist but cannot be read are reported as warnings on stderr (in the `warnings` field with `--json`), so they are never mistaken for missing. |
| `get <name>` | Print a plan. Content goes to stdout and a concise metadata line goes to stderr, so `> file` captures the content alone (use `export` for a byte-exact copy). |
| `create <name> --file <path>` | Create a new plan with content from `--file` (required — the CLI never prompts; `--file -` reads stdin). Create-only: an existing name fails with a version conflict instead of overwriting. `--title`, `--author`, and `--status` set metadata. |
| `update <name> --file <path>` | Replace the content of an existing plan (never creates). Omitted `--title`/`--author`/`--status` flags preserve the current values; passing them (even empty) overwrites. |
| `status <name> <status>` | Set a plan's free-form status without touching its body (bumps the version). |
| `export <name> --output <path>` | Write a plan's content, byte-exact, to a file (parents created, atomic write). An existing destination is refused (`invalid_argument`) and left untouched; add `--force` to replace an existing regular file atomically. |
| `delete <name>` | Delete a plan. A `--force` delete also recovers a corrupt plan. |

Plan content passed via `--file` (a regular file, or stdin with `--file -`) is capped at 10 MiB — the same limit the plan storage itself enforces — and a directory or non-regular file (device, named pipe) is rejected up front; violations fail with an `invalid_argument` error.

**Concurrency guard:** every mutation (`update`, `status`, `delete`) requires exactly one of two mutually exclusive flags — the CLI is headless and never prompts:

- `--expected-version <n>` — the version you last read (from `get` or `list`; must be ≥ 1). When the plan changed in the meantime the command fails with a version conflict, reports the current version, leaves the plan untouched, and exits with code **3** (all other failures exit with 1).
- `--force` — deliberately write without the optimistic-lock guard (last writer wins).

`create` takes no guard: it is inherently create-only and conflicts (exit code 3) when the name already exists.

**JSON output:** every subcommand accepts `--json`. Success documents go to stdout with a top-level `"schema_version": "1"` marker and stable service-model keys (`plans`, `plan`, `export`, `deleted`) whose fields are snake_case (`updated_at`, `bytes_written`; a zero/unknown `updated_at` is omitted); empty plan lists encode as `[]`, and no prose or ANSI is mixed in. Failures print a single JSON object to stderr:

```json
{"schema_version":"1","error":{"code":"conflict","message":"...","scope":"shared","name":"p","expected_version":1,"current_version":2}}
```

with `code` one of `conflict` (including `expected_version` and `current_version`), `not_found`, `invalid_argument`, `corrupt`, `storage`, or `error`; `scope`, `name`, and `op` are included where the failure carries them. Validation performed before a subcommand runs is covered too: a missing required flag, a violated `--expected-version`/`--force` group rule, and wrong positional arguments are reported as the same JSON object (code `invalid_argument`) whenever `--json` is present. One residual: flags are parsed left-to-right and parsing stops at the first unknown flag or invalid flag value, so such an error is reported as JSON only when `--json` appears before it on the command line; errors raised before a `plans` subcommand is resolved at all (e.g. an unknown subcommand) also remain plain text.

```bash
# Examples
$ docker agent plans list
$ docker agent plans list --json | jq '.plans[].name'
$ docker agent plans create release --file ./plan.md --title "Release plan" --status draft
$ cat plan.md | docker agent plans create release --file -
$ docker agent plans get release > plan.md            # content only; metadata on stderr
$ docker agent plans update release --file ./plan.md --expected-version 1
$ docker agent plans status release done --expected-version 2
$ docker agent plans export release --output ./plan.md
$ docker agent plans export release --output ./plan.md --force   # replace an existing file
$ docker agent plans delete release --expected-version 3
$ docker agent plans delete scratch --force
```

Plans live under the data directory (`~/.cagent/plans/` by default), so `--data-dir` selects which store the commands operate on.

### `docker agent debug`

Troubleshooting subcommands for inspecting how an agent config resolves and generating diagnostic output — useful when a config isn't behaving the way you expect. `debug` appears under **Advanced Commands** in `docker agent --help`; every subcommand below is stable and fully supported.

```bash
$ docker agent debug <subcommand> [flags]
```

| Subcommand | Description |
| ---------- | ----------- |
| `config <agent-file> [flavor...]` | Print the fully-resolved, canonical form of an agent's configuration (defaults applied, references resolved). When [flavors](/ai/docker-agent/configuration/flavors/) are given they are applied in order and the `flavors` section is dropped from the output. |
| `toolsets <agent-file>` | List every toolset each agent in the config exposes, with each tool's name and description. Add `--json` for machine-readable output including each tool's parameters, annotations, and output schema. Deferred tools are included. |
| `tool <agent-file> <tool-name> [parameters-json]` | Call a tool directly with a JSON object (defaults to `{}`), without an LLM turn. Select an agent with `-a` / `--agent`; otherwise the team's default agent is used. Add `--json` for the full result, including structured content and media. `tool_input_transform`, `tool_response_transform`, and `post_tool_use` hooks run in that order around the tool call, before output in both modes; add `--no-hook` to skip them. Deferred tools can be called without activation. |
| `skills <agent-file>` | List the skills discovered for each agent, marking forked skills. Add `--json` for machine-readable output; each skill includes a `path` field when it is backed by a file (omitted for inline skills). |
| `title <agent-file> <question>` | Generate a session title for `<question>` using the same title-generation path the TUI uses (including any configured `title_model`), without starting a session. See [Session Titles](/ai/docker-agent/features/sessions/#session-titles). |
| `auth` | Print parsed Docker authentication info from the token in use (source, subject, issuer, expiry, username/email). Add `--json` for machine-readable output. |
| `oauth list` | List stored MCP OAuth tokens (resource, scope, expiry, redacted access token). Add `--json` for machine-readable output. |
| `oauth remove <resource-url>` | Remove a stored MCP OAuth token. |
| `oauth login <agent-file> <mcp-name>` | Perform an interactive OAuth login for a remote MCP server declared in the config, by its name or URL. See [Remote MCP Servers](/ai/docker-agent/features/remote-mcp/). |

```bash
# Examples
$ docker agent debug config agent.yaml
$ docker agent debug config agent.yaml cheap with-shell
$ docker agent debug toolsets agent.yaml
$ docker agent debug toolsets agent.yaml --json
$ docker agent debug tool agent.yaml read_file '{"path":"README.md"}'
$ docker agent debug tool agent.yaml shell '{"cmd":"pwd"}' -a root --json
$ docker agent debug tool agent.yaml read_file '{"path":"README.md"}' --no-hook
$ docker agent debug skills agent.yaml
$ docker agent debug skills agent.yaml --json
$ docker agent debug title agent.yaml "How do I configure a fallback model?"
$ docker agent debug auth --json
$ docker agent debug oauth list
$ docker agent debug oauth login agent.yaml github
```

> [!WARNING]
> **`debug tool` executes real tool calls**
>
> Calls can modify files, run commands, or contact external services. They apply `tool_input_transform`, `tool_response_transform`, and `post_tool_use` hooks (including built-in secret redaction and large-result limiting) unless `--no-hook` is set, but bypass all other hooks and approval checks. Input transforms can rewrite arguments or block execution. Post-tool hooks see the transformed response and can cause a non-zero exit after the result is printed; they cannot undo tool side effects. Only the textual output is transformed; structured content and media are unchanged. Large-result spill files are retained in the system temporary directory so printed paths remain usable. Tools that require an agent runtime (such as delegation and handoff) are not supported. Built-in background jobs cannot be launched because toolsets are stopped when the command exits; use `shell` for synchronous commands instead. Tool errors print their result and exit with a non-zero status. Use `debug toolsets --json` to inspect parameter schemas before calling a tool.

> [!WARNING]
> **`debug auth --json` prints the full bearer token**
>
> The text output of `debug auth` truncates the token to a short preview, but `--json` includes the complete, unredacted JWT in its `token` field. Never paste `debug auth --json` output into logs, issue trackers, or bug reports — anyone with that token can act as you against Docker. Use the plain-text output (or redact the `token` field yourself) when sharing diagnostic output.

The `Source` field says where the token came from: `docker desktop`, or `minted from the stored access token` when it was obtained by exchanging the access token `docker login` stored. See [Docker authentication](/ai/docker-agent/guides/secrets/#docker-authentication).

The `config`, `toolsets`, `tool`, `skills`, and `title` subcommands also accept [runtime configuration flags](#runtime-configuration-flags) (`--working-dir`, `--models-gateway`, …); `title` additionally accepts `--model` to override the model used to resolve the config before generating the title.

### `docker-agent completion`

Generate a shell completion script for the standalone `docker-agent` binary for `bash`, `zsh`, `fish`, or `powershell`.

```bash
$ docker-agent completion <bash|zsh|fish|powershell>

# Examples
# Bash: load for the current session
$ source <(docker-agent completion bash)

# Zsh: install permanently (adjust the path for your $fpath)
$ docker-agent completion zsh > "${fpath[1]}/_docker-agent"
```

Run `docker-agent completion <shell> --help` for shell-specific installation instructions.

When using the `docker agent` CLI plugin, use Docker's completion instead. The plugin doesn't provide a `docker agent completion` command:

```bash
# Bash: load Docker CLI completion for the current session
$ source <(docker completion bash)

# Shell-specific installation instructions
$ docker completion <shell> --help
```

### Self-update

When installed from a standalone GitHub release binary, Docker Agent can opt in to updating itself. It's disabled by default; set `DOCKER_AGENT_AUTO_UPDATE` to a truthy value (`1`, `true`, `yes`, `on`) to enable it for a command or a shell session:

```bash
$ DOCKER_AGENT_AUTO_UPDATE=1 docker agent run
```

When enabled, every command checks the latest GitHub release before running. If a newer release exists, an interactive session asks whether to install it; a non-interactive session (CI, piped input) proceeds automatically. On yes, Docker Agent downloads the asset for your OS/architecture, verifies its checksum, replaces the current binary, and re-executes with the same arguments. The whole mechanism is fail-safe: any failure at any step falls back to running the current binary. Self-update never triggers for `version`, `help`, `--help`/`-h` (including per-subcommand help), `completion`, or the Docker CLI plugin metadata handshake.

See [Optional Self-Updates](/ai/docker-agent/getting-started/installation/#optional-self-updates) for the full walkthrough. Docker Desktop and Homebrew installs already manage updates and don't need this.

## Global Flags

These flags are available on every `docker agent` command:

| Flag                      | Description                                                                            |
| ------------------------- | -------------------------------------------------------------------------------------- |
| `-d, --debug`             | Enable debug logging (default location: `~/.cagent/cagent.debug.log`)                  |
| `--log-file <path>`       | Custom debug log location (only used with `--debug`)                                   |
| `-o, --otel`              | Enable OpenTelemetry observability: traces, metrics, and logs. Requires `OTEL_EXPORTER_OTLP_ENDPOINT` to export to a collector. |
| `--cache-dir <path>`      | Override the cache directory (default: `~/Library/Caches/cagent` on macOS)             |
| `--config-dir <path>`     | Override the config directory (default: `~/.config/cagent`). Also reads `DOCKER_AGENT_CONFIG_DIR` (legacy `CAGENT_CONFIG_DIR`) env var. |
| `--data-dir <path>`       | Override the data directory (default: `~/.cagent`; holds `session.db`, prompt `history`, worktrees, plans, …). Also reads `DOCKER_AGENT_DATA_DIR`; the flag takes precedence.            |
| `--help`                  | Show help for any command                                                              |

Data-directory overrides expand a leading `~` to your home directory. Other
characters, including `$`, are treated literally.

### OpenTelemetry environment variables

When `--otel` is enabled, the standard [OTel SDK env vars](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) are honored (`OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_RESOURCE_ATTRIBUTES`, etc.). Two additional Docker Agent-specific variables control GenAI instrumentation:

| Variable | Default | Description |
| -------- | ------- | ----------- |
| `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` | `false` | Set to `true` to capture prompt text, model responses, tool arguments, and tool results as span attributes. Off by default because these fields may contain PII. |
| `OTEL_SEMCONV_STABILITY_OPT_IN` | (dual-emit) | Set to `gen_ai_latest_experimental` to emit only the spec-defined `gen_ai.*` keys from the [GenAI semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/). The default dual-emit mode emits both `gen_ai.*` and legacy keys so existing dashboards continue working. |

## Runtime Configuration Flags

These flags are accepted by every command that loads an agent (`run`, `run --exec`, `new`, `eval`, `serve api`, `serve mcp`, `serve a2a`, `serve acp`, `serve chat`). They are listed once here to avoid repetition in the per-command tables above.

| Flag                            | Description                                                                                                              |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `--working-dir <path>`          | Set the working directory for the session (applies to tools and relative paths). In the full TUI, an explicitly supplied path also becomes the default directory for new sessions (`/new`, Ctrl+T, the `+` buttons); `/new <dir>` overrides it for one session. |
| `--env-from-file <path>`        | Load environment variables from file (repeatable).                                                                       |
| `--flavor <name>`               | Enable a config flavor, a YAML patch defined under the config's `flavors` section (repeatable, applied in order). See [Flavors](/ai/docker-agent/configuration/flavors/). |
| `--code-mode-tools`             | Provide a single tool to call other tools via JavaScript (forces code-mode tools globally).                              |
| `--models-gateway <addr>`       | Route model and evaluator traffic through a gateway. Reads `DOCKER_AGENT_MODELS_GATEWAY` (legacy `CAGENT_MODELS_GATEWAY`) env var.      |
| `--hook-pre-tool-use <cmd>`     | Add a pre-tool-use hook command (repeatable). See [Hooks](/ai/docker-agent/configuration/hooks/).                 |
| `--hook-post-tool-use <cmd>`    | Add a post-tool-use hook command (repeatable).                                                                           |
| `--hook-session-start <cmd>`    | Add a session-start hook command (repeatable).                                                                           |
| `--hook-session-end <cmd>`      | Add a session-end hook command (repeatable).                                                                             |
| `--hook-on-user-input <cmd>`    | Add an on-user-input hook command (repeatable).                                                                          |
| `--hook-stop <cmd>`             | Add a stop hook command, fired when the model finishes responding (repeatable).                                          |
| `--mcp-oauth-redirect-uri <url>` | Public HTTPS URL to advertise as the OAuth `redirect_uri` for MCP servers running in unmanaged OAuth mode. When set, docker-agent drives PKCE and the code exchange in-process instead of expecting the client to. See [Remote MCP](/ai/docker-agent/features/remote-mcp/) for details. |

## Agent References

Commands that accept a config support multiple reference types:

| Type          | Example                                     |
| ------------- | ------------------------------------------- |
| Local file    | `./agent.yaml`                              |
| OCI registry  | `docker.io/username/agent:latest`           |
| Hub shorthand | `myorg/agent:tag`                           |
| Alias         | `pirate` (after `docker agent alias add`)   |
| Default       | (no argument) — uses project config or built-in default agent |

> [!NOTE]
> **Debugging**
>
> Having issues? See [Troubleshooting](/ai/docker-agent/guides/troubleshooting/) for debug mode, log analysis, and common solutions.

