Expand description
Container management for container-type agent panes (Phase 1).
Manages persistent Docker containers — one per container agent. Each
container runs the configured image (e.g. ghcr.io/agentmuxai/agent-claude)
with tini as PID 1 and is kept alive between turns. Individual turns are
executed via docker exec -i (no -t — avoids CR/LF corruption of NDJSON).
Platform support (cross-platform, matches SPEC_CONTAINER_PANE_SUPPORT_2026_06_11.md):
DOCKER_HOSTwhen set (unix, tcp with or without TLS, https, npipe), else the sockets Docker, Podman, Colima and OrbStack leave in their usual places; the first that answers a ping is used (container/runtime.rs).- Windows: named pipe
//./pipe/docker_engine
Independence boundary: this module has no dependency on any other project’s container code. Docker best practices here were researched independently.
Re-exports§
pub use self::pull::StartEvent;pub use self::pull::StartObserver;pub use crate::backend::container::runtime::ContainerRuntimeHandle;
Modules§
- argv
- A container turn’s CLI arguments: the one-shot shape a
docker execturn runs with. - cli
- Installing the provider CLI inside a container agent’s container.
- cli_
release - The container route for the agent CLIs that are not on npm: grok and muse (a pinned release file). The same
registry as the host’s own copy (
backend::cli_download::SPECS) gives the URL, the SHA-256 and the size, so one pin covers both. No vendor script is run, and nothing a caller sends decides what is fetched: the script gets its values from the registry as positional parameters, never spliced into the script text. - credential
- A scoped credential for container agents, in place of the instance auth key.
- drift
- A container made from an older agent image than this AgentMux: noticing it, and updating it.
- gateway_
fwd - The gateway forwarder: how a container agent’s model-gateway request is tied to its own container where srv cannot see which container it comes from (Docker Desktop: every container arrives from one address).
- image
- Which container image an agent runs, and what happens when it can’t be had.
- key_
route - A container turn on the model gateway: a model route, or an API-key account (
model_gateway::catalog::KEY_ROUTE_ID). The container is given only the gateway’s address and a token for that one agent (and account); a key stays in the keychain. At the start of each turn this module makes that token current (a changed address or account, or a container made again, gets a new one and the earlier ends; a turn that overlaps another on the same grant shares its token) and ties it to the container’s own address on the agents network, so the gateway accepts it from that container and no other: - keychain_
credentials - A container agent’s login for a Claude account whose credentials are in the macOS Keychain.
- limits
- CPU, memory and process limits of a container agent’s container.
docs/specs/SPEC_CONTAINER_AGENT_RESOURCE_LIMITS_2026_10_29.md. - listener
- How a container agent’s
agentmux-mcpand hooks reach srv on Linux (P9 of the container-parity work). - mount_
source - Comparing a bind mount’s source as Docker reports it with the host path it was asked for.
- mounts
- The mounts of a container agent’s home: the per-agent volume, the bound account’s credentials, and the agent’s Personal Memory folder.
- oneshot
- A one-shot, locked-down container: a command that runs once, with nothing but what it is given, and whose output comes back (a Drone Run step, docs/specs/SPEC_DRONE_GENERAL_AUTOMATION_2026_11_11.md §3.6).
- oom
- Telling a container agent’s user that something in the container was stopped for going over its memory limit,
instead of a bare exit 137.
docs/specs/SPEC_CONTAINER_AGENT_RESOURCE_LIMITS_2026_10_29.md§5. - pull
- Pulling a container agent’s image: the progress the pane shows, and the limits that end a pull which has stopped (spec docs/specs/SPEC_CONTAINER_AGENTS_AT_PARITY_2026_10_27.md, P1 and P2).
- reap
- Stopping a provider-CLI install whose turn was cancelled.
- routes
- What a container agent is told when it calls a route it may not. Which routes those are is in
route_audience(a route srv serves is for everyone unless an entry there says otherwise; a path that is neither is refused), so there is one list to read. This module is the container listener’s view of it.servedsays whether srv serves a route at a path; srv answers it from its route table. - runtime
- Which container runtime this srv talks to (P11 of the container-parity work).
- runtime_
socket - No container runtime socket, pipe or control folder, and no AgentMux data folder (the root
~/.agentmux, its shared folder, every channel’s and dev build’s data, config, logs and runtime folders), is reachable through any mount of a container agent, or a folder that holds one (a home folder, the AgentMux root), whichever field the mount comes from (its volumes list, its workspace folder) and whoever wrote it (the definition, a template, a block’s launch settings, another channel’s registry). Sources are compared case-insensitively, with\as/,.and..resolved, and a link followed where the path exists.refused_mountis asked once, before an existing container is reused or a new one made; definitions that come in from outside (the shared registry, an old template) have the entries dropped (without_refused), and a definition saved with one is refused (refused_in_json). - session_
files - A container agent’s provider session files, reached through its container
(
SPEC_HISTORY_COMPACT_FORM_ONLY_2026_11_23.mdsection 5.4). - status_
source - What
backend::container_statusreads from the runtime: the list of agent containers and the stream of their events. Names, states and images only: nothing from inside a container. - upload
- Writing a small file into a container’s
/tmp.
Structs§
- Container
Manager - Shared container manager. Clone-on-Arc; cheap to pass around.
- Container
Mount Spec - Host directories a container agent needs mounted to be able to work.
- Exec
Session - Exec session handle for a single turn.
Enums§
- CliProvision
- Whether
provision_clifound the CLI in place or had to install it. - Container
Error - Errors from container operations.
Constants§
- AGENTMUX_
DOCKER_ NETWORK - Shared user-defined Docker bridge network every agent container is
attached to, ADDITIVE to whatever
network_mode/extra_hostsalready set up (container→host reachability, unaffected — see the doc comment onnetwork_modebelow). Unlike the default bridge network, a user-defined one gives per-container DNS resolution and lets the native dev-proxy (backend::dev_proxy) route to a container by its internal IP. See docs/specs/SPEC_NATIVE_CONTAINER_DEV_PROXY_2026_09_19.md §3.1. - CLAUDE_
CREDENTIALS_ FILE - The credentials file inside the account’s config dir, and inside the image.
- CONTAINER_
CLAUDE_ DIR - Where the agent CLI’s config dir lives inside the image (
CLAUDE_CONFIG_DIR). - CONTAINER_
MCP_ CONFIG_ DIR - Where the folder holding an agent’s MCP config is bind-mounted when it lives outside the
working directory, so a container launch never has to write it into a user’s project (#3680).
The folder, not the file: a single-file bind would keep the old inode across an atomic rewrite.
Shared with
agentmux-mcp doctor, which looks for the config here inside a container. Where a container agent’s relocated config folder is mounted. - CONTAINER_
WORKSPACE_ DIR - Where the agent’s working directory is bind-mounted inside the image.
Functions§
- container_
name_ for_ slug - Derive the stable container name for an agent from its slug.
Format:
agentmux-<slug>. Deterministic so restarts reuse the same container. - container_
of_ meta - The container a container agent’s pane (its block
meta:agentMode=container) runs in, named from itsagentIdas the launch path names it.Nonefor any other pane. - credentials_
dir_ if_ file_ backed - The account config dir to hand to
ContainerMountSpec::claude_config_host_dir, orNonewhen this account has no file-backed credential to mount. - rewrite_
local_ url_ for_ container - Rewrite a host-loopback
AGENTMUX_LOCAL_URL(e.g.http://127.0.0.1:PORT) into something a container’s network namespace can actually reach.