Skip to content

feat: add Codex browser OAuth fallback - #17647

Open
mikkelchokolate wants to merge 7 commits into
NousResearch:mainfrom
mikkelchokolate:feat/codex-browser-oauth
Open

feat: add Codex browser OAuth fallback#17647
mikkelchokolate wants to merge 7 commits into
NousResearch:mainfrom
mikkelchokolate:feat/codex-browser-oauth

Conversation

@mikkelchokolate

@mikkelchokolate mikkelchokolate commented Apr 29, 2026

Copy link
Copy Markdown

Summary

  • Adds a browser-based PKCE OAuth fallback for OpenAI Codex authentication
  • Preserves credential metadata across auth store and credential pool refresh paths
  • Updates Codex auth/model tests and provider docs for the new flow

Test Plan

  • venv/bin/python -m py_compile agent/credential_pool.py hermes_cli/auth.py hermes_cli/main.py
  • venv/bin/python -m pytest tests/hermes_cli/test_auth_codex_provider.py tests/hermes_cli/test_auth_commands.py tests/hermes_cli/test_codex_models.py -o 'addopts=' -q

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard area/auth Authentication, OAuth, credential pools provider/openai OpenAI / Codex Responses API labels Apr 29, 2026
@mikkelchokolate
mikkelchokolate force-pushed the feat/codex-browser-oauth branch from 4f80168 to 2a41969 Compare May 16, 2026 19:16

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a concrete PKCE fallback for Codex accounts where device code is unavailable. Current main still routes fresh Codex logins directly to device code (hermes_cli/auth.py:6930-6939), so the feature remains relevant.

Problems

  • agent/credential_pool.py:619 and :644 call _save_provider_state during pool refresh. That helper always updates active_provider (hermes_cli/auth.py:1222-1228), so a token refresh can silently switch the user's selected provider. Keep the non-activating write path.
  • The branch predates current Codex refresh serialization. Main holds _auth_store_lock across sync, refresh POST, and write-back (agent/credential_pool.py:968-990), added by da6d5fcd to prevent reuse of single-use refresh tokens. Preserve that behavior when salvaging the Codex changes.
  • hermes_cli/auth.py:2219, :2225, and :2227 add behavioral HERMES_* overrides. AGENTS.md:102-107 requires behavioral settings to use config.yaml.

Suggested changes

  • Carry the browser-PKCE implementation onto current auth/pool code without replacing current refresh and provider-selection safeguards.
  • Add focused tests for the resulting current-main browser login and refresh path.

Automated hermes-sweeper review.

Comment thread agent/credential_pool.py
@@ -704,7 +619,7 @@ def _sync_device_code_entry_to_auth_store(self, entry: PooledCredential) -> None
state[extra_key] = val

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_save_provider_state sets auth_store["active_provider"] unconditionally (hermes_cli/auth.py:1222-1228). A pool refresh is token rotation, not an explicit provider selection; retain _store_provider_state(..., set_active=False) here so it cannot switch the user's active provider.

Comment thread hermes_cli/auth.py
"response_type": "code",
"client_id": CODEX_OAUTH_CLIENT_ID,
"redirect_uri": CODEX_OAUTH_REDIRECT_URI,
"scope": os.getenv("HERMES_CODEX_OAUTH_SCOPE", CODEX_OAUTH_SCOPE).strip() or CODEX_OAUTH_SCOPE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add a new non-secret HERMES_* configuration surface for OAuth scope. Per AGENTS.md:102-107, behavioral settings belong in config.yaml; remove this override unless a supported config.yaml setting is added through the normal configuration flow.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants