You don’t need a config file to start. Run docker agent run with no arguments and docker-agent automatically selects the best available provider based on which API keys are set:
# Uses best available provider automaticallydocker agent run
Provider priority: OpenAI → Anthropic → Google → Mistral → DMR.The auto value also works inside config files:
agents: root: model: auto description: Adaptive assistant instruction: You are a helpful assistant.
Add a default model to ~/.config/cagent/config.yaml so you don’t have to specify it every time:
default_model: anthropic/claude-sonnet-4-0
The default_model field lives at the root of the config file (not nested under settings).You can also set it via environment variable: DOCKER_AGENT_DEFAULT_MODEL=anthropic/claude-sonnet-4-0.
docker-agent resolves model aliases to their latest stable version. This keeps behavior reproducible without you having to track version strings manually:
# You write:model: anthropic/claude-sonnet-4-5# docker-agent resolves to the latest available pinned version
To lock to a specific version, write it explicitly.
Large MCP toolsets can slow down agent startup because docker-agent must connect to each server and enumerate available tools. Use defer: true to load tools only when they are first used:
agents: root: model: openai/gpt-4o description: Multi-tool assistant instruction: You have many tools available. toolsets: - type: mcp ref: docker:github-official defer: true - type: mcp ref: docker:slack defer: true
You can also defer individual tools within a toolset:
Many MCP servers expose dozens of tools. Limit the exposed set to only what the agent needs — fewer tools means faster tool selection and less token usage in the system prompt:
Always set max_iterations on agents that have access to powerful or destructive tools. This prevents runaway loops and gives you a predictable cost ceiling:
agents: developer: model: anthropic/claude-sonnet-4-0 description: Development assistant instruction: You are a developer. max_iterations: 30 toolsets: - type: filesystem - type: shell
Typical values: 20–30 for development agents, 10–15 for simple tasks.
Configure fallback models to keep agents running during provider outages or rate limit events:
agents: root: model: anthropic/claude-sonnet-4-0 description: Reliable assistant instruction: You are a helpful assistant. fallback: models: - openai/gpt-4o # Different provider for resilience - openai/gpt-4o-mini # Cheaper model as last resort retries: 2 # Retry 5xx errors before falling back cooldown: 1m # Stay on fallback for 1 minute after rate limit
Best practices for fallback chains:
Use different providers for true redundancy
Order by preference, best first
Include a cheaper or faster model as a last resort
The think tool gives the agent an internal reasoning scratchpad. It adds minimal overhead but significantly improves output quality for multi-step tasks:
The --yolo flag auto-approves all tool calls without asking for confirmation:
# Useful in CI or with read-only toolsdocker agent run agent.yaml --yolo
Avoid --yolo in interactive sessions when the agent has shell or filesystem write access and you haven’t reviewed the agent’s instructions carefully. It is safest in CI/CD pipelines or with agents that only call read-only tools.
Selective tool approval is the safer default for interactive use:
Approve once — allow this specific call
Always allow — approve this tool pattern for the rest of the session
Choose the right delegation model for your use case:
sub_agents (transfer_task)
Delegates a task to a child agent, waits for the result, then the parent continues. Use when the root agent needs to coordinate and synthesize results.
sub_agents: [researcher, writer]
handoffs (A2A)
Transfers control entirely to another agent — possibly remote. The handoff is one-way and the original agent is no longer involved.
The --debug flag writes a detailed log of all API calls, tool executions, and internal events:
# Logs to ~/.cagent/cagent.debug.log by defaultdocker agent run agent.yaml --debug# Write to a custom locationdocker agent run agent.yaml --debug --log-file ./debug.log
Always attach the debug log when filing a bug report.