Skip to content

The agent that grows with you

test(agent): keep the auxiliary cache suite hermetic on hosts with an ambient Claude Code login

liuhao10243bc625066411
diff --git a/tests/agent/test_auxiliary_client_cache_follows_credential.py b/tests/agent/test_auxiliary_client_cache_follows_credential.py
index 6fe11964ce0..5dca89b814e 100644
--- a/tests/agent/test_auxiliary_client_cache_follows_credential.py
+++ b/tests/agent/test_auxiliary_client_cache_follows_credential.py
@@ -9,6 +9,7 @@ import time
import pytest
+import agent.anthropic_credentials as anth_cred
import agent.auxiliary_client as aux
from hermes_cli.auth import write_credential_pool
@@ -29,9 +30,23 @@ def _seed(provider: str, token: str, *, model_cooldown: str | None = None) -> No
def isolated_home(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hermes"))
monkeypatch.setattr(aux, "_client_cache", {})
+ # HERMES_HOME only redirects Hermes-owned state; the borrowed Claude Code
+ # reader still consults ~/.claude/.credentials.json and the macOS Keychain,
+ # so an ambient login on the host would seed a second un-cooled-down pool
+ # entry and break the cooldown assertions below (#114424).
+ monkeypatch.setattr(anth_cred, "read_claude_code_credentials", lambda: None)
return tmp_path / "hermes"
+def test_isolated_home_hides_ambient_borrowed_credentials(isolated_home):
+ """The suite stays hermetic on hosts with an ambient Claude Code login (#114424)."""
+ assert anth_cred.read_claude_code_credentials() is None
+ _seed("anthropic", "tok-old", model_cooldown=MODEL)
+ pool = aux._load_pool_with_credentials("anthropic")
+ assert [entry.source for entry in pool.entries()] == ["manual"]
+ assert aux._pool_cache_hint("anthropic").startswith("anthropic::")
+
+
@pytest.mark.parametrize("provider", ["anthropic", "openai-codex"])
def test_pool_token_rotation_changes_cache_key_and_hides_the_secret(isolated_home, provider):
"""Same entry id, new token -> different key; the token itself never enters the key."""