Skip to content

fix(auth): add credential_pool fallback when env var is absent - #15944

Closed
jjjojoj wants to merge 5 commits into
NousResearch:mainfrom
jjjojoj:fix/credential-pool-env-fallback
Closed

fix(auth): add credential_pool fallback when env var is absent#15944
jjjojoj wants to merge 5 commits into
NousResearch:mainfrom
jjjojoj:fix/credential-pool-env-fallback

Conversation

@jjjojoj

@jjjojoj jjjojoj commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

What

Fixes HTTP 401 errors in fallback chain when API keys are stored in ~/.hermes/.env or auth.json but not in os.environ.

Why

_resolve_api_key_provider_secret() only checked os.environ for API keys. When env vars were absent (e.g. key added after session start, or ACP entry point not loading project .env), it returned "" and broke the fallback_providers chain with HTTP 401.

How

auth.py: Add credential pool as fallback source after env var checks, using read_credential_pool() to find valid access_token entries. Preserves env var priority — pool is only consulted when env vars are empty.

acp_adapter/entry.py: Now passes project_env to load_hermes_dotenv(), consistent with all other entry points (main.py, run_agent.py, cli.py).

Test

Added tests/hermes_cli/test_credential_pool_fallback.py (5 cases) and tests/acp_adapter/test_entry_env_loading.py (1 case).

Fixes #15914
Fixes #15932 (duplicate)

jjjojoj and others added 5 commits April 18, 2026 22:51
…esearch#12175)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…2294)

build_skills_system_prompt() loaded disabled set AFTER the cache check,
so config changes to skills.disabled silently had no effect until restart.
Move get_disabled_skill_names() before cache check and add sorted disabled
tuple to cache key so any change invalidates the cache.
NousResearch#12064)

Background task media delivery unpacked the (path, is_voice) tuple but
discarded the is_voice flag, sending all audio via send_document. Now
routes voice files through send_voice() when the adapter supports it.
When API keys are stored in ~/.hermes/.env or auth.json but never
loaded into os.environ (e.g. post-session-start addition, or ACP
entry point missing project_env), _resolve_api_key_provider_secret()
returned empty string and broke fallback_providers chains.

Fix: add credential_pool (auth.json) as a fallback source after env var
checks, using read_credential_pool() to find valid access_token entries.
Mirrors the pool.select() path in runtime_provider.py while preserving
env var priority.

Secondary fix: acp_adapter/entry.py now passes project_env to
load_hermes_dotenv(), consistent with all other entry points
(main.py, run_agent.py, cli.py).

Tests added:
- test_credential_pool_fallback.py: 5 cases covering env→pool priority,
  provider-specific fallback, empty token filtering
- test_entry_env_loading.py: verifies project_env is passed to dotenv loader

Fixes NousResearch#15914
Fixes NousResearch#15932 (duplicate)
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard comp/acp Agent Communication Protocol adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #15920 — same root cause in _resolve_api_key_provider_secret() missing credential_pool fallback. Both fix #15914.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #15920 — same root cause in _resolve_api_key_provider_secret() missing credential_pool fallback. Both fix #15914.

@jjjojoj

jjjojoj commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing as duplicate — #16101 (salvage of #15920) has already merged the credential_pool fallback fix for #15914. Thanks for the review!

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 comp/acp Agent Communication Protocol adapter comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

2 participants