Skip to content

fix(auth): fall back from empty codex profile state - #38273

Open
sweetcornna wants to merge 1 commit into
NousResearch:mainfrom
sweetcornna:codex/fix-38261-codex-profile-auth-fallback
Open

fix(auth): fall back from empty codex profile state#38273
sweetcornna wants to merge 1 commit into
NousResearch:mainfrom
sweetcornna:codex/fix-38261-codex-profile-auth-fallback

Conversation

@sweetcornna

@sweetcornna sweetcornna commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • let profile-mode openai-codex provider state fall back to global auth when local tokens are empty or unusable
  • reuse credential-pool profile/global fallback when resolving Codex runtime pool credentials
  • add profile fallback regressions for empty Codex singleton state and global pool fallback

Scope

This addresses the credential-store shadowing part of #38261. The stale worker credential lifecycle described there is a separate launchd/gateway worker restart problem and is intentionally left for a follow-up lifecycle/docs change.

Addresses #38261.

Verification

  • /Users/cornna/project/hermes-agent/.venv/bin/python -m pytest tests/hermes_cli/test_auth_profile_fallback.py::test_load_provider_state_codex_empty_tokens_falls_back_to_global tests/hermes_cli/test_auth_profile_fallback.py::test_load_provider_state_codex_profile_valid_tokens_shadow_global tests/hermes_cli/test_auth_profile_fallback.py::test_resolve_codex_runtime_credentials_profile_empty_provider_uses_global_pool -q
  • /Users/cornna/project/hermes-agent/.venv/bin/python -m pytest tests/hermes_cli/test_auth_profile_fallback.py tests/hermes_cli/test_auth_codex_provider.py tests/hermes_cli/test_runtime_provider_resolution.py -q
  • /Users/cornna/project/hermes-agent/.venv/bin/python -m ruff check hermes_cli/auth.py tests/hermes_cli/test_auth_profile_fallback.py
  • git diff --check

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard codex labels Jun 3, 2026
@sweetcornna
sweetcornna marked this pull request as ready for review June 3, 2026 15:15

@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 narrowing this to the credential-store shadowing path. The current-main inspection confirms the reported gap: an empty profile singleton shadows global state, while the Codex pool fallback reads only the profile pool.

Problems

  • hermes_cli/auth.py:1157 returns a global Codex state without preserving its source store. A later refresh reaches _save_codex_tokens, which reloads and writes the active profile store (hermes_cli/auth.py:3386-3407), leaving the global source stale. Current main’s Nous path uses _load_provider_state_with_source / _save_provider_state_to_source for this cross-store rotation case (hermes_cli/auth.py:1177-1252).
  • The added tests do not force a refresh of a global fallback state, so they do not cover that persistence invariant.

Suggested changes

  • Salvage this against the source-aware helper on current main and write refreshed Codex grants back to the store they were read from.
  • Add a profile/global forced-refresh regression asserting global rotation and no unintended profile shadowing.

Automated hermes-sweeper review.

Comment thread hermes_cli/auth.py
@@ -1143,6 +1157,18 @@ def _load_provider_state(auth_store: Dict[str, Any], provider_id: str) -> Option
if isinstance(providers, dict):

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.

This fallback loses the auth-store source. If the returned global token is expiring, the Codex refresh path later saves via _save_codex_tokens to the active profile store, leaving the global grant stale. Please carry the selected source path through refresh and persist back to that source, following current main’s _load_provider_state_with_source / _save_provider_state_to_source pattern.

@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 area/profiles Multi-profile isolation, HERMES_HOME scoping labels Jul 14, 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 area/profiles Multi-profile isolation, HERMES_HOME scoping codex comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have 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/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants