Skip to content

fix(auth): resolve Codex usage credentials from auth fallbacks - #17480

Closed
NoxsMedia wants to merge 1 commit into
NousResearch:mainfrom
NoxsMedia:fix/codex-account-usage-pool
Closed

fix(auth): resolve Codex usage credentials from auth fallbacks#17480
NoxsMedia wants to merge 1 commit into
NousResearch:mainfrom
NoxsMedia:fix/codex-account-usage-pool

Conversation

@NoxsMedia

@NoxsMedia NoxsMedia commented Apr 29, 2026

Copy link
Copy Markdown

Summary

  • allows Codex token readers used by /usage to resolve OAuth credentials from credential_pool.openai-codex when the legacy providers.openai-codex block is absent
  • keeps profile-local auth authoritative, with the global root auth store as a read-only fallback only when no local provider/pool credentials are present
  • preserves Codex pool base_url and source provenance metadata during runtime credential resolution
  • lets gateway /usage probe account-usage-capable credential pools when no live/cached agent or billing row has identified a provider yet

Fixes #15167.
Related: #15173.

Latest main refresh

  • Base: 355af2c20 (origin/main)
  • Head: 4962d8477e69f5c0b4408da0bcef91f19cbba736
  • Rebuilt as one clean commit on latest main.
  • Semantic conflict resolved: latest main had moved Codex pool fallback into the shared token reader, so this refresh preserves latest-main reader behavior while carrying source provenance forward, avoiding global auth fallback shadowing of local pool credentials, and skipping pool entries still in an exhaustion cooldown.

Test Plan

  • git diff --check
  • /home/ubuntu/.hermes/hermes-agent/.venv/bin/python -m pytest -o addopts='' tests/hermes_cli/test_auth_codex_provider.py tests/hermes_cli/test_auth_profile_fallback.py tests/gateway/test_usage_command.py -q

Focused result: 53 passed in 0.57s.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery area/auth Authentication, OAuth, credential pools labels Apr 29, 2026
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch from 774a3d9 to 1ed8dba Compare May 11, 2026 12:36
@NoxsMedia NoxsMedia changed the title fix(auth): read Codex usage credentials from pool fix(auth): resolve Codex usage credentials from auth fallbacks May 11, 2026
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch 2 times, most recently from eba1fb7 to c56ac8a Compare May 21, 2026 12:16
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch from c56ac8a to 4962d84 Compare May 31, 2026 03:16
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch 5 times, most recently from f5541b9 to ced5de5 Compare June 21, 2026 02:31
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch 3 times, most recently from cf91ed8 to 9220515 Compare June 25, 2026 13:07
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch 3 times, most recently from 519bc6a to 459ee4c Compare July 2, 2026 03:07
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch 2 times, most recently from b95a772 to 1f1b1ab Compare July 10, 2026 00:45
Teach legacy Codex token readers to use the same auth resolution paths as runtime credentials: provider state first, credential_pool next, then the global root store for profile processes without local Codex credentials.

This lets /usage render Codex Account limits in fresh gateway/profile sessions that inherit global auth, while preserving pool base_url metadata for runtime credential resolution.
@NoxsMedia
NoxsMedia force-pushed the fix/codex-account-usage-pool branch from 1f1b1ab to 9584558 Compare July 12, 2026 13:40
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for refreshing the focused /usage fix. The current main checkout still has the no-agent/provider-resolution gap: gateway/slash_commands.py:3960-3984 only fetches account usage when a live/cached agent or persisted billing row supplies a provider.

Problems

  • The pool projection in the proposed _read_codex_tokens() changes a pool credential into singleton refresh state. resolve_codex_runtime_credentials() force-refreshes through _refresh_codex_auth_tokens() and _save_codex_tokens() (hermes_cli/auth.py:3539-3580, 3361-3386), while _sync_codex_pool_entries() deliberately does not rewrite independent manual:device_code entries (hermes_cli/auth.py:3279-3307, 3334-3346). A refreshed independent pool account can therefore leave its original pool entry stale while a separate singleton copy is written.

Suggested changes

  • Keep the no-provider /usage probe, but resolve/refresh pool-backed Codex credentials through the selected CredentialPool entry rather than the singleton reader path.
  • Add a forced-refresh regression for a pool-only independent manual:device_code account, asserting its selected entry is updated and other accounts remain unchanged.

This is an automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data label Jul 12, 2026
@teknium1 teknium1 added 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
@NoxsMedia

Copy link
Copy Markdown
Author

Closing at the author’s request. We no longer plan to carry this patch. Official main already renders Codex limits once the provider is known, and we are not continuing the additional cold-start credential-pool path in its current form.

@NoxsMedia NoxsMedia closed this Jul 13, 2026
@NoxsMedia
NoxsMedia deleted the fix/codex-account-usage-pool branch July 13, 2026 14:51
@teknium1 teknium1 added the area/usage-cost Token accounting, usage reporting, billing, cost tracking label Jul 19, 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/usage-cost Token accounting, usage reporting, billing, cost tracking comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists 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.

/usage shows no Codex account quota; _read_codex_tokens() ignores credential_pool

3 participants