Agents

Agents are the core building blocks of docker-agent. Each agent is an AI-powered entity with a model, instructions, tools, and optional sub-agents.

What is an Agent?

An agent in docker-agent is defined by:

agents:
  root:
    model: anthropic/claude-sonnet-4-0
    description: Expert software developer
    instruction: |
      You are an expert developer. Write clean, efficient code
      and explain your reasoning step by step.
    toolsets:
      - type: filesystem
      - type: shell
      - type: think

The Root Agent

Every docker-agent configuration has a root agent — the entry point that receives user messages. In a single-agent setup, this is the only agent. In a multi-agent setup, the root agent acts as a coordinator, delegating tasks to specialized sub-agents.

ℹ️ Naming

The first agent defined in your YAML (or the one named root) is the root agent by default. You can also specify which agent to start with using docker agent run config.yaml -a agent_name.

Agent Properties

Property Type Required Description
model string Model reference (inline like openai/gpt-4o or a named model)
description string What the agent does — used by other agents for delegation
instruction string System prompt defining behavior
toolsets array List of tool configurations
sub_agents array Names of agents this agent can delegate to
fallback object Fallback model configuration for resilience
add_date boolean Include current date in context
add_environment_info boolean Include OS, working directory, git info in context
max_iterations int Max tool-calling loops (default: unlimited)
commands object Named prompts callable via /command
skills boolean Enable skill discovery and loading

Model Fallbacks

Agents can automatically fail over to alternative models when the primary model is unavailable:

agents:
  root:
    model: anthropic/claude-sonnet-4-0
    fallback:
      models:
        - openai/gpt-4o
        - google/gemini-2.5-flash
      retries: 2 # retries per model for 5xx errors
      cooldown: 1m # stick with fallback after 429

Named Commands

Define reusable prompts that can be invoked as commands:

agents:
  root:
    model: openai/gpt-4o
    instruction: You are a helpful assistant.
    commands:
      df: "Check how much free space I have on my disk"
      greet: "Say hello to ${env.USER}"
# Run a named command
$ docker agent run agent.yaml /df
$ docker agent run agent.yaml /greet

Commands support environment variable interpolation using JavaScript template literal syntax. Undefined variables expand to empty strings.

Default Agent

Running docker agent run without a config file uses a built-in default agent. This is a capable general-purpose agent for quick tasks without needing any configuration.

# Use the default agent
$ docker agent run

# Override the default with an alias
$ docker agent alias add default /path/to/my-agent.yaml
$ docker agent run  # now runs your custom agent
💡 See also

For reusable task-specific instructions, see Skills. For multi-agent patterns, see Multi-Agent. For full config reference, see Agent Config.