Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Read DOCKER_AGENT_ENV_-prefixed secret variables before the plain names

未关闭
#4,702 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@aheritier 已经在做这个了。

开始于 2026年10月22日。

  • #4708 来自 @aheritier —— 未关闭
  • #4709 来自 @aheritier —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

area/cli area/config area/security kind/feat
Overview

Let docker-agent read DOCKER_AGENT_ENV_<NAME> in preference to <NAME> for every secret it resolves (e.g. DOCKER_AGENT_ENV_ANTHROPIC_API_KEY before ANTHROPIC_API_KEY).

Motivation

docker-agent resolves op:// 1Password references, which is a nice way to avoid plain-text keys. But the variable names are shared with other tools: exporting ANTHROPIC_API_KEY="op://…" in the shell breaks Claude Code, Codex and provider SDKs, which do not resolve op://. Today the workarounds are the docker-agent env file (~/.config/cagent/.env) or a per-model token_key, which must be repeated in every model of every config and does not apply to --model provider/model.

Use cases
export DOCKER_AGENT_ENV_ANTHROPIC_API_KEY="op://Personal/Anthropic/api-key"
export ANTHROPIC_API_KEY=sk-ant-...   # or unset; used by other tools
docker agent run agent.yaml          # uses the op:// reference

Also lets a user point docker-agent at a different key (separate billing/project) without touching other tools.

Proposed solution

A PrefixedProvider decorator in pkg/environment, wired through a single chain constructor as OnePassword(Prefixed(Multi(sources...))), so a prefixed value can itself be an op:// reference.

Decisions (revised after code review, see the comment below):

  1. Prefix DOCKER_AGENT_ENV_. DOCKER_AGENT_ is docker-agent's settings namespace; names already in it are never looked up as overrides.
  2. Precedence: DOCKER_AGENT_ENV_<NAME> wins across the whole chain, --env-from-file included.
  3. Empty values: an empty override is ignored and <NAME> is used.

Doctor and follow-ups:

  • docker agent doctor (findSource) queries sources directly and would report the key as missing; teach it the prefix and show which name supplied the value.
  • The TUI transcriber reads OPENAI_API_KEY with os.Getenv (bypassing both op:// and the prefix); fixing it needs lazy resolution, so it is deferred to a separate PR.

Known limitation: in --sandbox, keys Docker Desktop proxies itself (OPENAI_API_KEY, ANTHROPIC_API_KEY, …) never go through our chain, so neither op:// nor the prefix applies to them there. Documented, not changed.

Alternatives
  • Per-model token_key: works, but verbose and not available for --model shorthand.
  • Docker Agent env file: works, but a plain shell export of the same name still wins, which is the common setup for users of several AI tools.
Related issues
  • #4701: docs fix for the credential helper scope and an op:// isolation tip.
  • #4703: credential helper for all secrets.
  • #4708: implementation.
主要语言
Go
星标
4.6k
派生
522
平均合并
10 小时 33 分钟
30 天内合并 PR
231

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/docker-agent 的其他 Issue

查看 docker/docker-agent 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。