The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(aux): bare-custom AuthError yields no custom endpoint instead of a stale env OPENAI_BASE_URL
teknium1f55d4f674748
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex b01b764098c..91b4fd5d208 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -2646,8 +2646,15 @@ def clear_runtime_main() -> None:def _resolve_custom_runtime() -> Tuple[Optional[str], Optional[str], Optional[str]]:"""Resolve the active custom/main endpoint like the main CLI (env OPENAI_BASE_URL or config-saved)."""try:+ from hermes_cli.auth import AuthErrorfrom hermes_cli.runtime_provider import resolve_runtime_providerruntime = resolve_runtime_provider(requested="custom")+ except AuthError as exc:+ # Bare 'custom' with nothing configured fails fast in the main resolver: there is no+ # custom endpoint, so do NOT fall through to a stale env OPENAI_BASE_URL that the main+ # resolver deliberately never consults.+ logger.debug("Auxiliary client: no custom endpoint configured: %s", exc)+ return None, None, Noneexcept Exception as exc:logger.debug("Auxiliary client: custom runtime resolution failed: %s", exc)runtime = Nonediff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.pyindex 8f53381a99c..0d11dfe2d58 100644--- a/tests/agent/test_auxiliary_client.py+++ b/tests/agent/test_auxiliary_client.py@@ -2667,6 +2667,17 @@ class TestAuxiliaryTaskExtraBody:assert not any("OPENAI_BASE_URL is set" in rec.message for rec in caplog.records), \"Should NOT warn when provider is 'custom'"+ def test_bare_custom_auth_error_does_not_fall_back_to_env_base_url(self, monkeypatch):+ """Bare 'custom' with nothing configured: the main resolver raises AuthError; aux must+ return no endpoint rather than route to a stale env OPENAI_BASE_URL with a placeholder key."""+ from hermes_cli.auth import AuthError+ from agent.auxiliary_client import _resolve_custom_runtime+ monkeypatch.setenv("OPENAI_BASE_URL", "https://old-proxy.example/v1")+ monkeypatch.delenv("OPENAI_API_KEY", raising=False)+ with patch("hermes_cli.runtime_provider.resolve_runtime_provider",+ side_effect=AuthError("no creds", provider="custom", code="missing_api_key")):+ assert _resolve_custom_runtime() == (None, None, None)+# ---------------------------------------------------------------------------