Skip to content

fix(auxiliary): fallback to OPENROUTER_API_KEY env var when credential pool is exhausted#24720

Open
ambition0802 wants to merge 1 commit into
NousResearch:mainfrom
ambition0802:fix/openrouter-pool-exhausted-fallback-to-env-var
Open

fix(auxiliary): fallback to OPENROUTER_API_KEY env var when credential pool is exhausted#24720
ambition0802 wants to merge 1 commit into
NousResearch:mainfrom
ambition0802:fix/openrouter-pool-exhausted-fallback-to-env-var

Conversation

@ambition0802

Copy link
Copy Markdown
Contributor

Problem

When the OpenRouter credential pool has entries but all of them are exhausted/rate-limited (e.g. HTTP 429), _try_openrouter() returns (None, None) without falling back to the OPENROUTER_API_KEY environment variable, even when that env var is valid and usable.

This causes auxiliary tasks (title_generation, compression, session_search, vision, etc.) to fail with:

No LLM provider configured for task=<task> provider=auto

Meanwhile the main agent continues to work fine because it uses a different code path.

Root Cause

In agent/auxiliary_client.py, _try_openrouter():

  • _select_pool_entry("openrouter") returns (True, None) when the pool exists but all entries are in cooldown
  • Since pool_present=True, the function bailed out immediately with return None, None without ever checking os.getenv("OPENROUTER_API_KEY")

Fix

When pool_present=True but no usable entry is found, fall through to the env var check instead of returning early. Added an info log line to make this fallback visible in logs.

Testing

  • Verified the code path change matches the expected behavior described in the issue
  • The change is minimal and only affects the exhausted pool case; normal pool usage behavior remains unchanged

Fixes #23452

…l pool is exhausted

When the OpenRouter credential pool has entries but all are exhausted/rate-limited,
previously the function returned (None, None) immediately without checking the
OPENROUTER_API_KEY environment variable. This caused auxiliary tasks (compression,
title generation, etc.) to fail with 'No LLM provider configured' even when a
valid env var was present.

Fixes NousResearch#23452
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/openrouter OpenRouter aggregator labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/openrouter OpenRouter aggregator type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: _try_openrouter() returns (None,None) when credential pool is exhausted, blocking env var fallback

2 participants