✅ Maintained path: use codex-profiler for all Codex profile operations.
Standalone codex-usage and codex-auth skills are deprecated.
This skill consolidates both scripts:
- -
scripts/codex_usage.py (usage/limits) - INLINECODE4 (OAuth helper for start/status)
For auth/profile mutation, this skill now standardizes on gateway-native openclaw models auth ... commands.
Safe defaults
- - Usage checks are read-only by default.
- Auth state is runtime-managed; one-shot direct file edits are unreliable and can be overwritten by in-memory/cooldown state.
- Treat
auth-profiles.json as gateway-managed state. Never mutate it directly in normal operations. - Prefer gateway-native auth mutation commands (
openclaw models auth ..., openclaw models auth order ...) over script-level file writes. - Use dry-run/read-only preflight first, then apply, then verify (strict anti-drift flow below).
- See
RISK.md for allowed/denied operation boundaries.
Commands
Usage
- -
/codex_usage → selector (default / all / discovered profiles) - INLINECODE11
Auth
- -
/codex_auth → selector (profiles) - INLINECODE13
- INLINECODE14 (helper only; profile/order mutation must use gateway-native commands)
UX requirements (cross-channel)
For
/codex_usage, send immediate progress message first as a separate message:
- - "Running Codex usage checks now…"
Delivery rule:
- - If progress is sent through channel message tool path, send final result through the same path (same target/session), then return
NO_REPLY. - Avoid mixed delivery (tool progress + plain reply final).
For auth/profile/order mutation, warn that writes are gateway-managed and enforce verify-after-apply:
- - "I will apply this via
openclaw models auth ... and then verify with models status + auth order get." - "I won’t hand-edit auth files directly because runtime state can drift/overwrite one-shot edits."
Interaction adapter
- - If inline buttons are supported: use selector buttons.
- If inline buttons are not supported: use text fallback prompts.
- Apply duplicate-request suppression per user for ~20s.
- Never echo full callback URLs in responses.
Profile removal policy (MANDATORY)
- 1. Best method (default): operational retire, not hard delete
- Remove the target profile from active provider order (
openclaw models auth order set ...) so it is never selected.
- Keep profile data intact unless the user explicitly requests permanent deletion.
- 2. Hard delete only on explicit user instruction
- Perform permanent profile deletion only when the user clearly asks to hard delete/remove permanently.
- If gateway-native delete is unavailable in the installed OpenClaw version, do not improvise risky live edits; use a controlled maintenance window flow.
Strict anti-drift auth mutation flow (MANDATORY)
For auth/profile/order changes, use this exact 3-step flow:
1) Preflight (read-only)
CODEBLOCK0
2) Apply (gateway-native command)
CODEBLOCK1
3) Verify (post-apply, no assumptions)
CODEBLOCK2
Never skip verification. If results mismatch expectation, do not hand-edit files; diagnose and re-apply via gateway-native commands.
How to run
CODEBLOCK3
Safety posture
- - No remote shell execution (
curl|bash, wget|sh) is allowed by this skill. - No
sudo/SSH/system-level host mutation commands are part of this skill path. - Usage checks are restricted to trusted HTTPS endpoint host allowlist (
chatgpt.com). - Callback URLs and token material must be treated as sensitive and never echoed in full.
Multi-account rotation guidance
When asked about running multiple Codex accounts/profiles, rotation policy, or fallback strategy, read:
Use the short template for quick chat answers and the deep-dive template for setup/troubleshooting requests.
Notes
- - Uses auth profiles at
~/.openclaw/agents/main/agent/auth-profiles.json by default. - Current source of truth is
auth-profiles.json; auth.json is legacy compatibility and should not be used as primary state. - If profile routing behaves unexpectedly, check for mixed state (missing/stale
auth-profiles.json, leftover legacy files, or stale runtime cooldown) before assuming model fallback bugs. - Same
accountId across two profile labels is not automatically a defect. In this environment, multiple labels can map to the same workspace/account identity while still operating correctly. Treat it as healthy when both profiles are auth-valid and usable in /codex_usage; investigate only when auth failures or routing failures appear. - Codex usage endpoint:
https://chatgpt.com/backend-api/wham/usage. - Usage script now surfaces
401 as auth_not_accepted_by_usage_endpoint with a clear hint, while still returning local profile health. - Usage output now includes top-level
summary, formatted_profiles, and suggested_user_message for cleaner slash-command formatting. - Preferred strict output format for
/codex_usage (single line per profile):
-
🟢 \%profile%\
— 5h **%5h_left%** | week **%week_left%** | r5 **%5h_reset%** | rw **%week_reset%**
- Use
🟠 when limited and
🔴 when unusable/auth-invalid.
- No preface, no table, no trailing summary unless explicitly requested.
- - OAuth flow: OpenAI auth endpoints + localhost callback on port 1455.
- Preferred mutation path is gateway-native (
openclaw models auth ... / openclaw models auth order ...) with mandatory preflight + verify. - INLINECODE45 remains useful for per-profile helper status checks.
- Keep temporary payload/token artifacts only until verification succeeds, then clean them up.
- Codex CLI installation is not required for usage endpoint reads in this skill path.
✅ 维护路径: 所有 Codex 配置文件操作均使用 codex-profiler。
独立的 codex-usage 和 codex-auth 技能已弃用。
此技能整合了两个脚本:
- - scripts/codexusage.py(使用量/限制)
- scripts/codexauth.py(用于启动/状态的 OAuth 辅助工具)
对于认证/配置文件的变更操作,此技能现已标准化为使用网关原生命令 openclaw models auth ...。
安全默认值
- - 使用量检查默认为只读。
- 认证状态由运行时管理;一次性直接编辑文件不可靠,可能被内存/冷却状态覆盖。
- 将 auth-profiles.json 视为网关管理的状态。在常规操作中切勿直接修改它。
- 优先使用网关原生认证变更命令(openclaw models auth ...、openclaw models auth order ...),而非脚本级别的文件写入。
- 先进行试运行/只读预检,然后应用,最后验证(遵循下方严格的防漂移流程)。
- 参见 RISK.md 了解允许/禁止的操作边界。
命令
使用量
- - /codexusage → 选择器(默认 / 全部 / 已发现的配置文件)
- /codexusage
认证
- - /codexauth → 选择器(配置文件)
- /codexauth
- /codexauth finish url>(仅辅助工具;配置文件/订单变更必须使用网关原生命令)
用户体验要求(跨渠道)
对于 /codex_usage,首先以单独消息的形式发送即时进度消息:
投递规则:
- - 如果通过渠道消息工具路径发送进度,则通过相同路径(相同目标/会话)发送最终结果,然后返回 NO_REPLY。
- 避免混合投递(工具进度 + 纯文本回复最终结果)。
对于认证/配置文件/订单变更,警告写入操作由网关管理,并强制应用后验证:
- - 我将通过 openclaw models auth ... 应用此操作,然后使用 models status + auth order get 进行验证。
- 我不会直接手动编辑认证文件,因为运行时状态可能会漂移或覆盖一次性编辑。
交互适配器
- - 如果支持内联按钮:使用选择器按钮。
- 如果不支持内联按钮:使用文本回退提示。
- 对每个用户应用约 20 秒的重复请求抑制。
- 切勿在回复中完整回显回调 URL。
配置文件移除策略(强制)
- 1. 最佳方法(默认):操作退役,而非硬删除
- 将目标配置文件从活跃的提供商订单中移除(openclaw models auth order set ...),使其永远不会被选中。
- 除非用户明确要求永久删除,否则保持配置文件数据完整。
- 2. 仅在用户明确指示时进行硬删除
- 仅当用户明确要求硬删除/永久移除时,才执行永久配置文件删除。
- 如果已安装的 OpenClaw 版本中无法使用网关原生删除功能,不要即兴进行有风险的实时编辑;使用受控的维护窗口流程。
严格的防漂移认证变更流程(强制)
对于认证/配置文件/订单更改,请使用以下精确的三步流程:
1) 预检(只读)
bash
openclaw models status --json
openclaw models auth order get --provider openai-codex --agent
2) 应用(网关原生命令)
bash
openclaw models auth order set --provider openai-codex --agent
或
openclaw models auth order clear --provider openai-codex --agent
或提供商登录流程
openclaw models auth login --provider openai-codex
3) 验证(应用后,不做任何假设)
bash
openclaw models status --json
openclaw models auth order get --provider openai-codex --agent
切勿跳过验证。如果结果与预期不符,不要手动编辑文件;通过网关原生命令进行诊断并重新应用。
如何运行
bash
使用量检查(只读)
python3 skills/codex-profiler/scripts/codex_usage.py --profile all --timeout-sec 25 --retries 1 --debug
python3 skills/codex-profiler/scripts/codex_usage.py --profile all --format text
OAuth 辅助工具(仅回调解析/状态)
python3 skills/codex-profiler/scripts/codex_auth.py start --profile default
python3 skills/codex-profiler/scripts/codex_auth.py status
安全态势
- - 此技能不允许远程 shell 执行(curl|bash、wget|sh)。
- 此技能路径中不包含 sudo/SSH/系统级主机变更命令。
- 使用量检查仅限于受信任的 HTTPS 端点主机白名单(chatgpt.com)。
- 回调 URL 和令牌材料必须视为敏感信息,切勿完整回显。
多账户轮换指南
当被问及运行多个 Codex 账户/配置文件、轮换策略或回退策略时,请阅读:
- - references/multi-account-rotation.md
对于快速聊天回答,使用简短模板;对于设置/故障排除请求,使用深入模板。
备注
- - 默认使用位于 ~/.openclaw/agents/main/agent/auth-profiles.json 的认证配置文件。
- 当前事实来源是 auth-profiles.json;auth.json 是遗留兼容文件,不应作为主要状态使用。
- 如果配置文件路由行为异常,在假设模型回退错误之前,请检查是否存在混合状态(缺失/过时的 auth-profiles.json、遗留的残留文件或过时的运行时冷却状态)。
- 两个配置文件标签使用相同的 accountId 并不自动视为缺陷。在此环境中,多个标签可以映射到同一个工作区/账户身份,同时仍能正常运行。当两个配置文件都通过认证验证且可在 /codexusage 中使用时,将其视为正常状态;仅在出现认证失败或路由故障时进行调查。
- Codex 使用量端点:https://chatgpt.com/backend-api/wham/usage。
- 使用量脚本现在将 401 错误显示为 authnotacceptedbyusageendpoint,并附有清晰提示,同时仍返回本地配置文件健康状态。
- 使用量输出现在包含顶层的 summary、formattedprofiles 和 suggestedusermessage,以实现更清晰的斜杠命令格式化。
- /codexusage 的首选严格输出格式(每个配置文件一行):
- 🟢 \%profile%\ — 5小时
%5hleft% | 周
%weekleft% | r5
%5hreset% | rw
%weekreset%
- 当受限时使用 🟠,当不可用/认证无效时使用 🔴。
- 除非明确要求,否则不添加前言、表格或尾部摘要。
- - OAuth 流程:OpenAI 认证端点 + localhost 回调,端口 1455。
- 首选的变更路径是网关原生命令(openclaw models auth ... / openclaw models auth order ...),并强制进行预检 + 验证。
- codex_auth.py status --profile 对于按配置文件的辅助状态检查仍然有用。
- 仅在验证成功前保留临时负载/令牌工件,之后进行清理。
- 在此技能路径中,读取使用量端点不需要安装 Codex CLI。