Skip to content

fix: stale OAuth credentials block OpenRouter users on auto-detect#5746

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-c1ef09e3
Apr 7, 2026
Merged

fix: stale OAuth credentials block OpenRouter users on auto-detect#5746
teknium1 merged 1 commit intomainfrom
hermes/hermes-c1ef09e3

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented Apr 7, 2026

Problem

When a user is on OpenRouter but has stale Nous Portal (or Codex) OAuth credentials in auth.json from a previous login, resolve_runtime_provider(requested='auto') picks the stale OAuth provider, tries to refresh the token, gets "Refresh session has been revoked", and shows a blocking bold-red error. The user's perfectly valid OPENROUTER_API_KEY is never checked.

Root Cause

resolve_provider('auto') checks auth.json for an active_provider before checking env vars. get_nous_auth_status() reports logged_in=True if any access_token exists (even expired), so the Nous path is taken. resolve_nous_runtime_credentials() then fails with a revoked refresh token, and the AuthError propagates all the way up.

Fix

In hermes_cli/runtime_provider.py: when requested_provider == 'auto' and OAuth credential resolution fails for the auto-detected provider, catch the AuthError and fall through to the next provider in the chain (OpenRouter via env vars). When the user explicitly requested the provider, the error still propagates normally.

Tests

3 new tests:

  • Nous auth failure falls through to OpenRouter on auto
  • Codex auth failure falls through to OpenRouter on auto
  • Explicit Nous request still raises AuthError

53/53 runtime provider tests pass. Zero regressions.

When resolve_runtime_provider is called with requested='auto' and
auth.json has a stale active_provider (nous or openai-codex) whose
OAuth refresh token has been revoked, the AuthError now falls through
to the next provider in the chain (e.g. OpenRouter via env vars)
instead of propagating to the user as a blocking error.

When the user explicitly requested the OAuth provider, the error
still propagates so they know to re-authenticate.

Root cause: resolve_provider('auto') checks auth.json for an active
OAuth provider before checking env vars. get_nous_auth_status()
reports logged_in=True if any access_token exists (even expired),
so the Nous path is taken. resolve_nous_runtime_credentials() then
tries to refresh the token, fails with 'Refresh session has been
revoked', and the AuthError bubbles up to the CLI bold-red display.

Adds 3 tests: Nous fallthrough, Codex fallthrough, explicit-request
still raises.
@teknium1 teknium1 merged commit 8e64f79 into main Apr 7, 2026
5 of 6 checks passed
DiscoStew6082 pushed a commit to DiscoStew6082/hermes-agent that referenced this pull request Apr 9, 2026
…ousResearch#5746)

When resolve_runtime_provider is called with requested='auto' and
auth.json has a stale active_provider (nous or openai-codex) whose
OAuth refresh token has been revoked, the AuthError now falls through
to the next provider in the chain (e.g. OpenRouter via env vars)
instead of propagating to the user as a blocking error.

When the user explicitly requested the OAuth provider, the error
still propagates so they know to re-authenticate.

Root cause: resolve_provider('auto') checks auth.json for an active
OAuth provider before checking env vars. get_nous_auth_status()
reports logged_in=True if any access_token exists (even expired),
so the Nous path is taken. resolve_nous_runtime_credentials() then
tries to refresh the token, fails with 'Refresh session has been
revoked', and the AuthError bubbles up to the CLI bold-red display.

Adds 3 tests: Nous fallthrough, Codex fallthrough, explicit-request
still raises.
dbmizrahi pushed a commit to dbmizrahi/hermes-agent that referenced this pull request Apr 10, 2026
…ousResearch#5746)

When resolve_runtime_provider is called with requested='auto' and
auth.json has a stale active_provider (nous or openai-codex) whose
OAuth refresh token has been revoked, the AuthError now falls through
to the next provider in the chain (e.g. OpenRouter via env vars)
instead of propagating to the user as a blocking error.

When the user explicitly requested the OAuth provider, the error
still propagates so they know to re-authenticate.

Root cause: resolve_provider('auto') checks auth.json for an active
OAuth provider before checking env vars. get_nous_auth_status()
reports logged_in=True if any access_token exists (even expired),
so the Nous path is taken. resolve_nous_runtime_credentials() then
tries to refresh the token, fails with 'Refresh session has been
revoked', and the AuthError bubbles up to the CLI bold-red display.

Adds 3 tests: Nous fallthrough, Codex fallthrough, explicit-request
still raises.
Tommyeds pushed a commit to Tommyeds/hermes-agent that referenced this pull request Apr 12, 2026
…ousResearch#5746)

When resolve_runtime_provider is called with requested='auto' and
auth.json has a stale active_provider (nous or openai-codex) whose
OAuth refresh token has been revoked, the AuthError now falls through
to the next provider in the chain (e.g. OpenRouter via env vars)
instead of propagating to the user as a blocking error.

When the user explicitly requested the OAuth provider, the error
still propagates so they know to re-authenticate.

Root cause: resolve_provider('auto') checks auth.json for an active
OAuth provider before checking env vars. get_nous_auth_status()
reports logged_in=True if any access_token exists (even expired),
so the Nous path is taken. resolve_nous_runtime_credentials() then
tries to refresh the token, fails with 'Refresh session has been
revoked', and the AuthError bubbles up to the CLI bold-red display.

Adds 3 tests: Nous fallthrough, Codex fallthrough, explicit-request
still raises.
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.

1 participant