fix(worker): 支持 Codex 单 bot 独立鉴权 - #906
Open
xiongz-c wants to merge 2 commits into
Open
Conversation
xiongz-c
force-pushed
the
codex/codex-auth-sync
branch
from
August 18, 2026 02:32
b172d82 to
65353fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景与根因
Codex bot 使用 per-bot CODEX_HOME 时,worker 此前会在每次冷启动无条件把全局 ~/.codex/auth.json 刷新到该目录,覆盖 bot 自己通过 codex login --with-api-key 写入的 API-key auth。
对 requires_openai_auth = true 的 OpenAI-compatible provider,Codex 会使用登录凭证并忽略 provider env_key,因此即使 OPENAI_API_KEY 已通过 per-bot env 正确传入,请求仍可能拿到错误的全局 ChatGPT 凭证并返回 401 INVALID_API_KEY。
改动
默认值与迁移
无需迁移即可升级:未配置 codexAuthSync 时按 shared 处理。
需要单 bot key 时设置 isolated,然后执行:
sandbox: false 不再意味着必须共享登录态:shared 仍使用全局登录态;isolated 仍使用独立 CODEX_HOME,但不会提供 OS 文件访问隔离。
Dashboard
测试覆盖
验证
本地 daemon restart 因当前环境不存在 botmux 配置而在启动前退出,未创建配置或改动进程。未连接真实自定义 Responses endpoint,因此真实 provider 请求仍需在部署环境完成 isolated 登录后手动验收。
影响范围