OpenAI Codex Multi OAuth
Support and debug more than one openai-codex OAuth login inside OpenClaw.
Human-facing overview
This skill is also meant to help a human operator understand the setup, not only help an agent patch code.
What humans usually want to know:
- - which Codex profile the current chat is using
- whether the current chat has its own pinned profile override
- whether OpenClaw auto-switched after rate limits
- whether
/status usage matches the profile they expected - why two profiles may look similar even when they should stay distinct
Common user-facing surfaces in real deployments:
- -
/status — confirm the current chat's selected model, profile semantics, and usage summary - INLINECODE3 — an optional helper command in some setups for viewing or switching the current Codex profile
- INLINECODE4 — an optional helper command in some setups for comparing live usage across profiles
Treat /codex_profile and /codex_usage as common patterns, not guaranteed OpenClaw built-ins.
Start here
- 1. Run
python3 scripts/summarize_codex_profiles.py. - If usage is involved, also run
python3 scripts/codex_usage_report.py. - Classify the bug before patching anything.
- Change the smallest wrong layer.
- Re-test after every change.
If the target setup includes a local helper command or router script, reproduce through that real entrypoint at least once. Synthetic env-injected tests can miss session-sync bugs.
Mental model
Treat these as separate layers:
- - stored preference — any saved local pointer such as INLINECODE9
- auth order —
order.openai-codex in the auth store - session override —
authProfileOverride for the current chat/session - effective runtime profile — the profile that actually handled the request after selection or failover
- usage source — the token/accountId used by usage-fetch logic
- display metadata — the label shown to the user, such as email/workspace
- optional external profile repo — a separate file or store that keeps multiple Codex OAuth identities while runtime uses one active slot
Do not assume these layers always match.
Common architectures
A. Native auth-store setup
OpenClaw stores multiple openai-codex:* profiles directly in auth-profiles.json, and runtime resolves selection from auth order plus session override.
B. External-router setup
A local repo of Codex OAuth identities exists outside normal runtime selection, and a helper/router copies one selected profile into an active slot such as openai-codex:default.
In that design, verify all of these separately:
- - repo profile selected by the router
- active slot content after routing
- current session INLINECODE15
- INLINECODE16 oauth label
- INLINECODE17 usage source
Decision tree
1) The wrong account is selected
Check in this order:
- 1. stored preference or helper-selected profile
- INLINECODE18
- session INLINECODE19
- effective runtime profile
- whether failover is expected or a bug
2) /codex_profile-style helper switches profile, but /status does not follow
Check:
- 1. whether the helper changed only the active slot or also the current session override
- whether the current chat/session was correctly identified
- whether the environment that invokes the helper is missing chat/session metadata
- whether the platform keeps companion session entries that also need syncing
If the helper is real, re-test through the real command path, not only manual edits.
3) /status oauth changes, but usage does not
Check:
- 1. current session INLINECODE23
- the effective runtime profile for the current chat
- whether the usage loader resolves auth from generic provider order instead of the current session profile
- whether the UI is mixing preferred-profile and effective-profile semantics
- whether the usage fetch hard-pins the exact inspected profile or only passes a soft preference
4) Two profiles show the same usage unexpectedly
Check:
- 1. whether they share the same
accountId because they are in the same team workspace - whether
user_id is still different in the live wham/usage response - whether the local code accidentally fetched usage with the wrong token because provider-order fallback overrode the intended profile
- whether the same-looking result was intermittent, which usually points to local selection/fallback bugs rather than backend quota semantics
5) A profile works sometimes but not always
Check:
- 1. cooldown / last-good logic
- token expiry
- soft-pin vs hard-pin semantics
- whether failover is expected behavior or a bug
5) A token or profile entry is broken
Check:
- 1. whether the same
accountId exists in another store or backup - whether only one profile entry can be restored surgically
- whether local token parsing fails before request dispatch
6) /status, display labels, and runtime truth disagree
Decide which semantic each surface should represent:
- - preferred profile
- effective runtime profile
- usage source profile
- display metadata label
Then verify every layer against that semantic before patching.
Stable design rules
- - Prefer profile identity by
accountId before email when possible. - Preserve different workspaces/accounts as separate profiles even when email matches.
- Keep profile ids stable, for example:
-
openai-codex:default
-
openai-codex:secondary
-
openai-codex:tertiary
-
openai-codex:account-N
- - Do not blur preferred profile, effective runtime profile, and usage source profile.
- Hard-pin the exact profile credential when implementing per-profile usage inspection; a provider-level preference is not always a guarantee.
- A Telegram menu entry alone does not create a real executable command. Wire any
/codex_usage-style surface into the actual command handler path. - If an external repo exists, treat it as a separate layer instead of silently merging it into runtime state.
Validation checklist
After each change, verify all of these:
- 1. stored preference or helper-selected profile is what you expect
- auth order is what you expect
- current session
authProfileOverride is what you expect - runtime actually uses the intended profile
- INLINECODE36 shows the intended semantic
- usage matches the intended semantic, or the difference is explicitly understood
- any helper command resolves the same profile id the runtime is using
Common operator examples
Use examples like these when explaining the setup to a human:
- - "Use
/codex_profile to inspect or switch the profile for this chat if your deployment exposes that helper." - "Use
/status to confirm which profile the current chat prefers and whether usage looks aligned." - "If a
/codex_usage helper exists, compare profiles directly when usage looks suspicious." - "If OpenClaw auto-rotated after rate limits, explain that the runtime may have switched profiles even if the user did not do it manually."
When documenting commands, always say whether they are:
- - built into OpenClaw
- local helper commands added by a specific deployment
- examples that another operator may need to adapt
Bundled resources
- - Read
references/runtime-files.md for the file families that usually matter. - Read
references/workflows.md for concrete repair workflows and rollback points. - Read
references/usage-debugging.md when the bug involves usage mismatches, same-workspace confusion, or a new /codex_usage-style command. - Run
scripts/summarize_codex_profiles.py before and after changes. - Run
scripts/codex_usage_report.py when you need exact per-profile live usage evidence.
Guardrails
- - Back up auth files or runtime bundles before editing them.
- Prefer surgical patches over broad rewrites.
- Keep version-specific assumptions explicit.
- Do not restart the gateway unless the user asked.
- Commit workspace skill changes after edits.
OpenAI Codex 多OAuth登录
在OpenClaw中支持并调试多个openai-codex OAuth登录。
面向用户的概述
此技能不仅帮助智能体修补代码,也旨在帮助人类操作员理解设置。
人类通常想知道的内容:
- - 当前聊天使用的是哪个Codex配置文件
- 当前聊天是否有自己的固定配置文件覆盖
- OpenClaw是否在速率限制后自动切换
- /status的使用情况是否匹配他们预期的配置文件
- 为什么两个配置文件在应该保持不同时看起来相似
实际部署中常见的用户界面:
- - /status — 确认当前聊天选择的模型、配置文件语义和使用摘要
- /codexprofile — 某些设置中用于查看或切换当前Codex配置文件的可选辅助命令
- /codexusage — 某些设置中用于比较各配置文件实时使用情况的可选辅助命令
将/codexprofile和/codexusage视为常见模式,而非OpenClaw内置的保证功能。
从这里开始
- 1. 运行python3 scripts/summarizecodexprofiles.py。
- 如果涉及使用情况,同时运行python3 scripts/codexusagereport.py。
- 在修补任何内容之前先对错误进行分类。
- 修改最小的错误层。
- 每次修改后重新测试。
如果目标设置包含本地辅助命令或路由器脚本,至少通过该真实入口点重现一次。合成环境注入的测试可能会遗漏会话同步错误。
思维模型
将这些视为独立的层:
- - 存储的偏好 — 任何保存的本地指针,如codexprofileid
- 认证顺序 — 认证存储中的order.openai-codex
- 会话覆盖 — 当前聊天/会话的authProfileOverride
- 有效的运行时配置文件 — 在选择或故障转移后实际处理请求的配置文件
- 使用来源 — 使用情况获取逻辑使用的令牌/账户ID
- 显示元数据 — 向用户显示的标签,如邮箱/工作空间
- 可选的外部配置文件仓库 — 一个单独的文件或存储,保存多个Codex OAuth身份,而运行时使用一个活动槽位
不要假设这些层始终匹配。
常见架构
A. 原生认证存储设置
OpenClaw直接在auth-profiles.json中存储多个openai-codex:*配置文件,运行时从认证顺序加上会话覆盖解析选择。
B. 外部路由器设置
Codex OAuth身份的本地仓库存在于正常运行时选择之外,辅助程序/路由器将一个选定的配置文件复制到活动槽位,如openai-codex:default。
在这种设计中,分别验证所有这些内容:
- - 路由器选择的仓库配置文件
- 路由后的活动槽位内容
- 当前会话authProfileOverride
- /status OAuth标签
- /status使用来源
决策树
1) 选择了错误的账户
按此顺序检查:
- 1. 存储的偏好或辅助程序选择的配置文件
- order.openai-codex
- 会话authProfileOverride
- 有效的运行时配置文件
- 故障转移是预期行为还是错误
2) /codex_profile风格的辅助程序切换了配置文件,但/status没有跟随
检查:
- 1. 辅助程序是否只更改了活动槽位,还是也更改了当前会话覆盖
- 当前聊天/会话是否被正确识别
- 调用辅助程序的环境是否缺少聊天/会话元数据
- 平台是否保留了也需要同步的配套会话条目
如果辅助程序是真实的,通过真实的命令路径重新测试,而不仅仅是手动编辑。
3) /status的OAuth更改了,但使用情况没有
检查:
- 1. 当前会话authProfileOverride
- 当前聊天的有效运行时配置文件
- 使用情况加载器是否从通用提供程序顺序而不是当前会话配置文件解析认证
- UI是否混合了首选配置文件和有效配置文件的语义
- 使用情况获取是硬固定了确切检查的配置文件,还是只传递了软偏好
4) 两个配置文件意外显示相同的使用情况
检查:
- 1. 它们是否共享相同的accountId,因为它们在同一个团队工作空间中
- 实时wham/usage响应中的user_id是否仍然不同
- 本地代码是否意外使用了错误的令牌获取使用情况,因为提供程序顺序回退覆盖了预期的配置文件
- 相同的结果是否是间歇性的,这通常指向本地选择/回退错误,而不是后端配额语义
5) 配置文件有时有效,但并非总是有效
检查:
- 1. 冷却/最后良好逻辑
- 令牌过期
- 软固定与硬固定语义
- 故障转移是预期行为还是错误
5) 令牌或配置文件条目损坏
检查:
- 1. 相同的accountId是否存在于另一个存储或备份中
- 是否只能通过手术恢复一个配置文件条目
- 本地令牌解析是否在请求分发前失败
6) /status、显示标签和运行时真相不一致
决定每个界面应代表哪种语义:
- - 首选配置文件
- 有效的运行时配置文件
- 使用来源配置文件
- 显示元数据标签
然后在修补前根据该语义验证每一层。
稳定的设计规则
- - 尽可能优先使用accountId而非邮箱来标识配置文件。
- 即使邮箱匹配,也将不同的工作空间/账户保留为单独的配置文件。
- 保持配置文件ID稳定,例如:
- openai-codex:default
- openai-codex:secondary
- openai-codex:tertiary
- openai-codex:account-N
- - 不要模糊首选配置文件、有效的运行时配置文件和使用来源配置文件。
- 在实现按配置文件使用情况检查时,硬固定确切的配置文件凭据;提供程序级别的偏好并不总是保证。
- 仅Telegram菜单条目不会创建真正的可执行命令。将任何/codex_usage风格的界面连接到实际的命令处理程序路径。
- 如果存在外部仓库,将其视为一个单独的层,而不是静默合并到运行时状态中。
验证清单
每次更改后,验证所有这些内容:
- 1. 存储的偏好或辅助程序选择的配置文件是否符合预期
- 认证顺序是否符合预期
- 当前会话authProfileOverride是否符合预期
- 运行时实际使用了预期的配置文件
- /status显示预期的语义
- 使用情况匹配预期的语义,或者差异被明确理解
- 任何辅助命令解析的配置文件ID与运行时使用的相同
常见操作员示例
在向人类解释设置时使用这些示例:
- - 如果您的部署暴露了该辅助程序,使用/codexprofile检查或切换此聊天的配置文件。
- 使用/status确认当前聊天偏好的配置文件以及使用情况是否看起来一致。
- 如果存在/codexusage辅助程序,在使用情况看起来可疑时直接比较配置文件。
- 如果OpenClaw在速率限制后自动轮换,解释运行时可能已切换配置文件,即使用户没有手动操作。
在记录命令时,始终说明它们是:
- - OpenClaw内置的
- 特定部署添加的本地辅助命令
- 其他操作员可能需要调整的示例
捆绑资源
- - 阅读references/runtime-files.md了解通常重要的文件系列。
- 阅读references/workflows.md了解具体的修复工作流程和回滚点。
- 当错误涉及使用情况不匹配、相同工作空间混淆或新的/codexusage风格命令时,阅读references/usage-debugging.md。
- 在更改前后运行scripts/summarizecodexprofiles.py。
- 当需要确切的每个配置文件实时使用情况证据时,运行scripts/codexusage_report.py。
防护措施
- - 在编辑前备份认证文件或运行时包。
- 优先使用手术式修补而非大规模重写。
- 明确说明版本特定的假设。
- 除非用户要求,否则不要重启网关。
- 编辑后提交工作空间技能更改。