Skip to content

fix(tests): isolate credential pool routing tests from real ~/.claude/.credentials.json - #75265

Closed
JonthanaHanh wants to merge 1 commit into
NousResearch:mainfrom
JonthanaHanh:fix/75230-credential-pool-test-isolation
Closed

JonthanaHanh wants to merge 1 commit into
NousResearch:mainfrom
JonthanaHanh:fix/75230-credential-pool-test-isolation

Conversation

@JonthanaHanh

Copy link
Copy Markdown
Contributor

Summary

TestFailureAttribution._make_pool() calls load_pool("anthropic") which triggers auto-discovery of real Claude Code credentials from ~/.claude/.credentials.json on the developer's machine. This changes the fixture from the intended single-entry pool to a two-entry pool and makes test_unmatched_key_does_not_retry_only_pool_entry fail with assert True is False.

Root Cause

The _make_pool helper only overrides HERMES_HOME via monkeypatch, but load_pool("anthropic") still runs the auto-discovery path at agent/credential_pool.py:2245 which reads ~/.claude/.credentials.json from the real home directory. When a developer has usable Claude Code OAuth credentials, the auto-discovery inserts a second claude_code entry into the pool, turning a single-entry test into a multi-entry test.

Fix

Monkeypatch read_claude_code_credentials and read_hermes_oauth_credentials to return None before calling load_pool(). This matches the isolation pattern already used in tests/agent/test_anthropic_adapter.py (lines 235, 256, 278, 298, 318, 359, 367, 403).

Test Plan

  • pytest tests/agent/test_credential_pool_routing.py -q -> 15 passed
  • Verified fix isolates from real ~/.claude/.credentials.json

Fixes #75230

…/.credentials.json

TestFailureAttribution._make_pool() calls load_pool("anthropic") which
triggers auto-discovery of real Claude Code credentials from
~/.claude/.credentials.json on the developer's machine. This changes the
fixture from the intended single-entry pool to a two-entry pool and makes
test_unmatched_key_does_not_retry_only_pool_entry fail.

Monkeypatch read_claude_code_credentials and read_hermes_oauth_credentials
to return None before load_pool(), matching the isolation pattern already
used in test_anthropic_adapter.py.

Fixes NousResearch#75230
@teknium1

Copy link
Copy Markdown
Collaborator

Closing with credit: this exact host-credential leak in the _make_pool fixture was fixed on main via PR #82500 (merged in c28114a). Your PR was submitted first (Jul 31) and correctly identified the load_pool auto-seeding problem — thank you! #82500 was merged as the wider variant since it also blanks the Anthropic env vars, stubs is_provider_explicitly_configured, asserts exact pool contents, and removes a stale sys.path override in a sibling test file. Both contributions acknowledged.

@teknium1 teknium1 closed this Aug 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 runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Credential pool routing test reads real Claude Code credentials

4 participants