Skip to content

fix(gateway,cron): activate fallback_model when primary provider auth fails#7432

Closed
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/7230-fallback-on-auth-error
Closed

fix(gateway,cron): activate fallback_model when primary provider auth fails#7432
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/7230-fallback-on-auth-error

Conversation

@Tranquil-Flow

@Tranquil-Flow Tranquil-Flow commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Description

When the primary provider raises AuthError (expired OAuth token, revoked API key), the error was re-raised before AIAgent was created, so fallback_model was never consulted. Now both gateway/run.py and cron/scheduler.py catch AuthError specifically and attempt to resolve credentials from the fallback_providers/fallback_model config chain before propagating the error.

Related issue: #7230

Type of Change

  • Bug fix

Changes Made

  • gateway/run.py: Catch AuthError in _resolve_runtime_agent_kwargs(), try _try_resolve_fallback_provider() before raising.
  • cron/scheduler.py: Same pattern in run_job() — catch AuthError, iterate fallback chain.

How to Test

  1. Configure config.yaml with a primary provider and a fallback_model
  2. Let the primary provider's OAuth token expire (or revoke the API key)
  3. Send a message via gateway or trigger a cron job
  4. Agent should respond using the fallback model instead of returning an error

Checklist

  • All tests pass
  • Follows Conventional Commits
  • Tests added for this bug fix

Closes #7230

… fails

When the primary provider raises AuthError (expired OAuth token,
revoked API key), the error was re-raised before AIAgent was created,
so fallback_model was never consulted. Now both gateway/run.py and
cron/scheduler.py catch AuthError specifically and attempt to resolve
credentials from the fallback_providers/fallback_model config chain
before propagating the error.

Closes NousResearch#7230
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for this fix, @Tranquil-Flow — the change landed on main via the consolidated salvage PR #15134 (merged 2026-04-24).

This is an automated hermes-sweeper review.

Evidence:

The fix is live on main; closing as implemented.

@teknium1 teknium1 closed this Apr 27, 2026
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.

[Bug]: fallback_model not triggered when primary provider auth fails (AuthError at credential resolution)

2 participants