Skip to content

docs(codex): add Hermes-aware recovery branch for refresh_token_reused (#1542) - #1595

Closed
0xDevNinja wants to merge 2 commits into
garrytan:mainfrom
0xDevNinja:fix/1542-codex-refresh-token-hermes
Closed

0xDevNinja wants to merge 2 commits into
garrytan:mainfrom
0xDevNinja:fix/1542-codex-refresh-token-hermes

Conversation

@0xDevNinja

Copy link
Copy Markdown
Contributor

Summary

  • /codex Error Handling currently funnels every auth error to codex login. refresh_token_reused is the one case where that's actively destructive: Hermes' openai-codex provider can still be serving valid tokens while ~/.codex/auth.json has gone stale (split-brain auth), and codex login wipes the working Hermes session.
  • This PR adds a sub-bullet under Error Handling > Auth that branches on a Hermes smoke test before suggesting any auth repair, mirroring the runbook the reporter is using downstream.

Fixes #1542.

Behavior

The new bullet adds three steps in order:

  1. Smoke-test the Hermes openai-codex provider (if Hermes is installed) before doing anything else.
  2. If Hermes works, repair ~/.codex/auth.json from the Hermes-side tokens, chmod 600, retest codex exec — no codex login needed.
  3. If Hermes is absent or also down, the OpenAI session itself is gone and codex login is the right next step.

The skill is also told to tell the user which branch it took before acting, so the user knows whether they're about to nuke a working Hermes session.

Scope

Doc-only: edit to codex/SKILL.md.tmpl Error Handling section, plus the regenerated codex/SKILL.md (via bun run gen:skill-docs). No code, no auth surface, no tests added — same shape as bun run gen:skill-docs template-only doc PRs that have shipped before. The reporter's notes call this out explicitly: "This is documentation/runbook guidance only; it does not change Codex or Hermes auth behavior."

bun test test/skill-validation.test.ts test/gen-skill-docs.test.ts
# 707 pass, 7 fail

The 7 failures are the pre-existing --dry-run freshness check cases on non-Claude hosts (Kiro/OpenCode/Slate/Cursor/OpenClaw/Hermes/GBrain) that reproduce on upstream/main with this branch's changes stashed — unrelated to this patch.

Out of scope

  • Wiring an actual Hermes-side codex-auth-sync helper into gstack. The reporter notes the exact helper script varies by Hermes version; bundling one here would lock us to a specific Hermes layout. Pointing at the helper in prose keeps both sides flexible.
  • Auto-detecting Hermes install state. The skill prose says "if Hermes is installed" and lets Claude probe; a hard command -v hermes check could move into Step 0 in a follow-up if maintainers prefer.

- Codex `refresh_token_reused` is split-brain by default: Hermes
  `openai-codex` can still serve valid tokens while `~/.codex/auth.json`
  goes stale, so running `codex login` first wipes a working session
- Add a sub-bullet under Error Handling > Auth that branches on a
  Hermes smoke test, repairs `~/.codex/auth.json` from Hermes tokens
  when the provider still works, falls back to `codex login` only
  when both routes are dead
- Doc-only; no Codex or Hermes auth behavior changes

Fixes garrytan#1542.
@time-attack

time-attack commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

@0xDevNinja Please rewrite the recovery guidance to use documented commands and exact supported helper syntax. The current text names undocumented hermes ask and unclear codex-auth-sync/hermes-export forms.

The recovery text named speculative command forms — `hermes ask
--provider openai-codex` and `codex-auth-sync` / `hermes export
codex-auth` helper scripts — none of which exist in any documented
Hermes install. An agent following the skill verbatim would run
nonexistent commands.

Rewrite both steps capability-level: smoke-test via whatever invocation
the local Hermes install documents (`hermes --help`), and repair
`~/.codex/auth.json` by locating the openai-codex provider's token
store in Hermes' own state directory, explicitly noting there is no
standard gstack helper. The diagnostic order and the split-brain
explanation are unchanged.

Refs garrytan#1542.
@0xDevNinja

Copy link
Copy Markdown
Contributor Author

fair point on the command forms. hermes ask and the codex-auth-sync/hermes-export helpers aren't in any documented hermes install, i wrote them as plausible shapes and that's not good enough for a skill doc an agent follows verbatim. rewrote both steps to stay capability-level: smoke-test via whatever the local hermes install documents (hermes --help), and repair ~/.codex/auth.json by locating the openai-codex provider's token store in hermes' own state dir, with an explicit note that no standard gstack helper exists. diagnostic order and the split-brain explanation unchanged.

@capy-ai

capy-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for writing this up, @0xDevNinja, and for revising it after review. We'd rather not have /codex walk an agent through copying OAuth tokens between credential stores, especially out of another tool's undocumented state directory. /codex only tells the user to run codex login; it never runs it, so a working Hermes session isn't wiped automatically. Closing. If Hermes ships a documented export command, a one-line pointer to it in the error message would be welcome as a fresh PR.

@capy-ai capy-ai Bot closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document Codex refresh_token_reused recovery when Hermes auth still works

2 participants