Skip to content

fix: reload Codex OAuth credentials on auth failures#1714

Open
nicha16 wants to merge 1 commit into
vectorize-io:mainfrom
nicha16:fix/codex-oauth-reload-on-401
Open

fix: reload Codex OAuth credentials on auth failures#1714
nicha16 wants to merge 1 commit into
vectorize-io:mainfrom
nicha16:fix/codex-oauth-reload-on-401

Conversation

@nicha16
Copy link
Copy Markdown

@nicha16 nicha16 commented May 23, 2026

Summary

  • Reload Codex OAuth credentials from auth.json before using a cached refresh token after backend auth failures.
  • Support shared auth-store documents that nest Codex credentials under providers.openai-codex.
  • Avoid logging Codex account IDs during startup/verification.
  • Add regression coverage for normal calls, tool-call requests, wrapped auth parsing, and wrapped auth persistence.

Why

Long-running Hindsight services can keep a stale in-memory Codex access token while another process has already rotated the shared auth file. On a backend 401, spending the cached refresh token can fail or race even though fresh credentials are already available on disk. Reloading the auth file first lets the provider adopt externally rotated credentials before attempting OAuth refresh.

Test plan

  • uv run pytest tests/test_codex_oauth_refresh.py tests/test_codex_tool_choice.py -q — 30 passed
  • uv run ruff check hindsight_api/engine/providers/codex_llm.py tests/test_codex_oauth_refresh.py tests/test_codex_tool_choice.py — passed
  • git diff --check — passed
  • Independent pre-commit review — passed

- support wrapped openai-codex auth store shape
- reload rotated auth.json before spending cached refresh tokens
- avoid logging Codex account IDs
- add regression coverage for call and tool-call paths
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.

2 participants