docker-agent-config
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocker Agent Configuration
Docker Agent 配置
Overview
概述
Docker Agent (the CLI is , the open-source project is )
runs AI agents declared in a YAML file instead of application code. This
skill owns the artifact: the section (each entry's
, , and its own /), the top-level
/ sections referenced from agents, and a top-level
group agents can opt into with . It does not cover
invoking the CLI or serving/sharing the config — see Related
skills.
docker agentcagentagent.yamlagentsmodelinstructiontoolsetssub_agentsmodelsproviderscommandsuse_commandsDocker Agent(CLI 为 ,开源项目为 )运行在 YAML 文件中声明的 AI agent,而不是应用程序代码。此技能负责 工件: 部分(每个条目的 、,以及各自的 /)、agent 引用的顶级 / 部分,以及 agent 可通过 选择加入的顶级 组。它不涉及 CLI 的调用或配置的提供/共享——请参阅相关技能。
docker agentcagentagent.yamlagentsmodelinstructiontoolsetssub_agentsmodelsprovidersuse_commandscommandsWhen to use this skill
何时使用此技能
Activate this skill when:
- The user is creating, editing, or reviewing an /
agent.yaml/agent.ymlfile.agent.hcl - The user wants to add a tool/toolset, an MCP server, or a sub-agent to an agent config.
- The user wants to choose or configure a model/provider (OpenAI, Anthropic, Google, Bedrock, Docker Model Runner, custom endpoint) for an agent.
- The user wants a multi-agent "team" with a coordinator delegating to specialists.
在以下情况激活此技能:
- 用户正在创建、编辑或审查 /
agent.yaml/agent.yml文件。agent.hcl - 用户想要向 agent 配置添加工具/工具集、MCP 服务器或子 agent。
- 用户想要为 agent 选择或配置模型/provider(OpenAI、Anthropic、Google、Bedrock、Docker Model Runner、自定义端点)。
- 用户想要一个多 agent “团队”,由协调者将任务委派给专家。
Do not use this skill when
请勿在以下情况使用此技能
Do not use this skill when:
- The task is about running the CLI (flags,
docker agent run,--safety, aliases, worktrees) — use--sandbox.docker-agent-run - The task is about exposing an agent as a server (), distributing it (
serve mcp/api/a2a/acp/chat), or evaluating it (share push/pull) — usedocker agent eval.docker-agent-deploy - The task is about a generic Dockerfile or Compose service unrelated to Docker Agent — use or
docker-build-strategies.docker-compose-patterns
在以下情况请勿使用此技能:
- 任务涉及运行 CLI(标志、
docker agent run、--safety、别名、worktrees)——请使用--sandbox。docker-agent-run - 任务涉及将 agent 作为服务器暴露()、分发它(
serve mcp/api/a2a/acp/chat)或评估它(share push/pull)——请使用docker agent eval。docker-agent-deploy - 任务涉及与 Docker Agent 无关的通用 Dockerfile 或 Compose 服务——请使用 或
docker-build-strategies。docker-compose-patterns
Core guidance
核心指南
File structure
文件结构
- Every config needs at least one agent under top-level . The agent named
agents:, or the first agent defined, is the entry point that receives user messages.rootyamlagents: root: model: anthropic/claude-sonnet-4-5 description: A coding assistant instruction: | You are an expert developer. Help users write clean, efficient code. Explain your reasoning step by step. toolsets: - type: filesystem - type: shell - type: think - Required agent properties: ,
model,description(orinstruction).instruction_fileis not decoration — other agents read it to decide whether to delegate to this one, so keep it accurate.description - Use (a relative path, no
instruction_file) instead of an inline..for long prompts; this keeps diffs focused on behavior, not YAML escaping.instructionandinstructionare mutually exclusive.instruction_fileis not supported for agents loaded from an OCI reference or URL — inlineinstruction_filethere.instruction
- 每个配置在顶层 下至少需要一个 agent。名为
agents:的 agent,或第一个定义的 agent,是接收用户消息的入口点。root
yaml
agents:
root:
model: anthropic/claude-sonnet-4-5
description: A coding assistant
instruction: |
You are an expert developer. Help users write clean,
efficient code. Explain your reasoning step by step.
toolsets:
- type: filesystem
- type: shell
- type: think- 必需的 agent 属性:、
model、description(或instruction)。instruction_file不是装饰性的——其他 agent 会读取它来决定是否将任务委派给该 agent,因此请保持准确。description - 对于较长的提示,使用 (相对路径,不包含
instruction_file)而不是内联..;这样可以让 diff 聚焦于行为,而不是 YAML 转义。instruction和instruction互斥。从 OCI 引用或 URL 加载的 agent 不支持instruction_file——在那里使用内联instruction_file。instruction
Models and providers
模型与 provider
- Two ways to set a model: inline shorthand, or a named entry under top-level
provider/modelreferencing amodels:. Use the named form whenever you needprovider,temperature,max_tokens, or reuse across agents.thinking_budgetyamlmodels: claude: provider: anthropic model: claude-sonnet-4-5 max_tokens: 64000 agents: root: model: claude - Built-in provider keys: ,
openai,anthropic,google,amazon-bedrock(Docker Model Runner, local, no API key),dmr(local). Dozens of additional built-in aliases exist (ollama,mistral,groq,xai,together,azure,github-copilot, ...) — each needs its ownopenrouter-style env var; run<PROVIDER>_API_KEYto see what's resolvable, anddocker agent models --allto register credentials interactively instead of hand-editing env vars.docker agent setup - Never hardcode an API key in . Provider credentials come from environment variables (
agent.yamlfor custom providers) or fromtoken_keywritten by~/.config/cagent/.env.docker agent setup - Prefer for agents that must run offline or must not send data to a third party; it costs nothing and needs no credential. Use a paid cloud provider only when the task needs it.
dmr/<model> - Give resilience-critical agents a so a provider outage or rate limit does not stop the run:
fallbackyamlagents: root: model: anthropic/claude-sonnet-4-5 fallback: models: [openai/gpt-5, google/gemini-3.5-flash] retries: 2 # per model, for 5xx errors cooldown: 1m # stick with fallback after a 429 - For a self-hosted/OpenAI-compatible endpoint (vLLM, LiteLLM, a corporate
gateway), define a entry with
providers:andbase_urlrather than putting the URL inline on every model:token_keyyamlproviders: my_gateway: base_url: https://api.example.com/v1 token_key: MY_API_KEY models: my_model: provider: my_gateway model: gpt-4o
- 设置模型有两种方式:内联 简写,或顶层
provider/model下引用models:的命名条目。当你需要provider、temperature、max_tokens或在多个 agent 间复用时,请使用命名形式。thinking_budget
yaml
models:
claude:
provider: anthropic
model: claude-sonnet-4-5
max_tokens: 64000
agents:
root:
model: claude- 内置 provider 键:、
openai、anthropic、google、amazon-bedrock(Docker Model Runner,本地,无需 API key)、dmr(本地)。还有数十个额外的内置别名(ollama、mistral、groq、xai、together、azure、github-copilot,等等)——每个都需要自己的openrouter风格的环境变量;运行<PROVIDER>_API_KEY查看可解析的内容,运行docker agent models --all以交互方式注册凭据,而不是手工编辑环境变量。docker agent setup - 切勿在 中硬编码 API key。Provider 凭据来自环境变量(自定义 provider 使用
agent.yaml)或由token_key写入的docker agent setup。~/.config/cagent/.env - 对于必须在离线状态下运行或不得将数据发送给第三方的 agent,优先使用 ;它不需要成本,也不需要凭据。仅在任务需要时才使用付费云 provider。
dmr/<model> - 为对韧性要求较高的 agent 提供 ,这样 provider 故障或速率限制不会中断运行:
fallback
yaml
agents:
root:
model: anthropic/claude-sonnet-4-5
fallback:
models: [openai/gpt-5, google/gemini-3.5-flash]
retries: 2 # per model, for 5xx errors
cooldown: 1m # stick with fallback after a 429- 对于自托管/兼容 OpenAI 的端点(vLLM、LiteLLM、企业网关),定义带 和
base_url的token_key条目,而不是在每个模型上内联 URL:providers:
yaml
providers:
my_gateway:
base_url: https://api.example.com/v1
token_key: MY_API_KEY
models:
my_model:
provider: my_gateway
model: gpt-4oToolsets
工具集
- Built-in toolsets need no external dependency: ,
filesystem,shell,think,todo,tasks,memory,fetch,background-jobs,script,lsp. Add one per list entry:apiyamltoolsets: - type: filesystem - type: shell - If an agent only describes a plan but never executes it, add (or
type: todo) — a common symptom of an agent missing the tool it needs to act, not a model problem.shell - For external tools, prefer an MCP server from Docker's MCP catalog over a
bespoke integration — it runs containerized and is reusable across agents:
Local stdio and remote HTTP/SSE MCP servers are also supported; seeyaml
toolsets: - type: mcp ref: docker:duckduckgo.references/toolsets-and-providers.md - Use on a toolset (MCP or otherwise) to load its tools on-demand instead of at startup, when the agent has many toolsets and startup latency matters.
defer: true - Set on an agent to restrict every toolset it uses to read-only tools — use this for reviewer/analysis agents that must not mutate anything.
readonly: true
- 内置工具集不需要外部依赖:、
filesystem、shell、think、todo、tasks、memory、fetch、background-jobs、script、lsp。每个列表条目添加一个:api
yaml
toolsets:
- type: filesystem
- type: shell- 如果 agent 只描述计划但从不执行,请添加 (或
type: todo)——这通常是 agent 缺少行动所需工具的症状,而不是模型问题。shell - 对于外部工具,优先使用 Docker MCP 目录中的 MCP 服务器,而不是定制集成——它以容器化方式运行,并且可跨 agent 复用:
yaml
toolsets:
- type: mcp
ref: docker:duckduckgo本地 stdio 和远程 HTTP/SSE MCP 服务器也受支持;请参阅 。
references/toolsets-and-providers.md- 在工具集(MCP 或其他)上使用 ,以便在 agent 有许多工具集且启动延迟很重要时,按需加载其工具,而不是在启动时加载。
defer: true - 在 agent 上设置 ,将其使用的每个工具集限制为只读工具——用于不得更改任何内容的审查/分析 agent。
readonly: true
Multi-agent teams
多 agent 团队
- A coordinator delegates via ; listing sub-agents automatically enables the
sub_agents: [name, ...]tool on the parent.transfer_taskUseyaml# Fragment: coder and reviewer are defined separately in the full asset. agents: root: sub_agents: [coder, reviewer]for the complete runnable team, including the reviewer'sassets/team-agent.yamlrestriction. Keep that restriction when adapting the template; a filesystem toolset alone also exposes writes.readonly: true - also accepts external OCI references (
sub_agents). Pin external references to a digest (myorg/agent:tag) in production configs to skip the per-run registry lookup that a tag incurs.name@sha256:... - Use (via
transfer_task) for delegation with a clean, isolated result; use asub_agentsentry with ancommands:field only when you want the user to become that agent for the rest of the session.agent:
- 协调者通过 委派;列出子 agent 会自动在父级上启用
sub_agents: [name, ...]工具。transfer_task
yaml
# Fragment: coder and reviewer are defined separately in the full asset.
agents:
root:
sub_agents: [coder, reviewer]使用 获取完整可运行的团队,包括 reviewer 的 限制。在改编模板时保持该限制;单独的 filesystem 工具集也会暴露写入操作。
assets/team-agent.yamlreadonly: true- 也接受外部 OCI 引用(
sub_agents)。在生产配置中,将外部引用固定到摘要(myorg/agent:tag),以跳过标签带来的每次运行的注册表查找。name@sha256:... - 使用 (通过
transfer_task)进行委派,以获得干净、隔离的结果;仅当你希望用户在本会话剩余时间内成为该 agent 时,才使用带sub_agents字段的agent:条目。commands:
Safety and hygiene
安全与卫生
- Set on any agent that runs shell/fetch tools against untrusted input. It scrubs recognized secret patterns from tool arguments, outgoing messages, and tool output. This is defense in depth, not a guarantee: arbitrary passwords, tokens, or customer data may go undetected.
redact_secrets: true - Set on any agent that loops autonomously (default is unlimited) to bound cost and prevent runaway loops;
max_iterations(default 5) already guards against identical-call loops.max_consecutive_tool_calls - Keep credentials, tokens, and sensitive customer data out of ,
instruction, and command prompts, whether literal or interpolated.instruction_fileexpands values into prompt text sent to the model; storing a value in an env file does not prevent this disclosure. Use interpolation only for non-sensitive context.${env.VAR} - Supply provider credentials through or the provider's supported environment variables. For custom providers,
docker agent setupnames the environment variable, not its value; do not interpolate it. Configure tool/MCP credentials through that integration's authentication mechanism, not through prompts or model-supplied tool arguments. Prompts should describe the authenticated capability without containing its secret. Do not ask the agent to read or print credential files or environment values to check authentication.token_key: MY_API_KEY
- 在任何对不可信输入运行 shell/fetch 工具的 agent 上设置 。它会从工具参数、传出消息和工具输出中清除可识别的机密模式。这是纵深防御,而不是保证:任意密码、令牌或客户数据可能无法被发现。
redact_secrets: true - 在任何自主循环的 agent 上设置 (默认为无限),以限制成本并防止失控循环;
max_iterations(默认 5)已经可以防止相同调用循环。max_consecutive_tool_calls - 保持凭据、令牌和敏感客户数据远离 、
instruction和命令提示,无论是字面值还是插值。instruction_file会将值展开到发送给模型的提示文本中;将值存储在环境文件中并不能防止这种泄露。仅将插值用于非敏感上下文。${env.VAR} - 通过 或 provider 支持的环境变量提供 provider 凭据。对于自定义 provider,
docker agent setup指定的是环境变量的名称,而不是它的值;不要对它进行插值。通过该集成的认证机制配置工具/MCP 凭据,而不是通过提示或模型提供的工具参数。提示应描述已认证的能力,而不包含其机密。不要要求 agent 读取或打印凭据文件或环境值来检查认证。token_key: MY_API_KEY
Related skills
相关技能
- For running the agent (, safety modes, sandbox, aliases), use
docker agent run.docker-agent-run - For serving, sharing, or evaluating the agent, use .
docker-agent-deploy
- 如需运行 agent(、安全模式、沙箱、别名),请使用
docker agent run。docker-agent-run - 如需提供、共享或评估 agent,请使用 。
docker-agent-deploy
References
参考资料
- — full built-in toolset list, MCP connection modes, and the provider/env-var table.
references/toolsets-and-providers.md - — provenance of every rule in this skill.
references/sources.md
- —— 完整的内置工具集列表、MCP 连接模式以及 provider/环境变量表。
references/toolsets-and-providers.md - —— 此技能中每条规则的来源。
references/sources.md
Assets
资产
- — a runnable multi-agent team template (coordinator + coder + reviewer).
assets/team-agent.yaml
- —— 一个可运行的多 agent 团队模板(协调者 + 编码者 + 审查者)。
assets/team-agent.yaml
Checks
检查
- Before running an agent, follow to confirm its resolved config, exposed tools, and provider connectivity, then smoke-test it.
checks/verification.md
- 在运行 agent 之前,请遵循 确认其解析后的配置、暴露的工具和 provider 连接性,然后进行冒烟测试。
checks/verification.md