From f55d4f674748ca7ccf8a0610bf121f711301253c Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:27:56 -0700 Subject: [PATCH] fix(aux): bare-custom AuthError yields no custom endpoint instead of a stale env OPENAI_BASE_URL --- agent/auxiliary_client.py | 7 +++++++ tests/agent/test_auxiliary_client.py | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index b01b764098..91b4fd5d20 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 AuthError from hermes_cli.runtime_provider import resolve_runtime_provider runtime = 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, None except Exception as exc: logger.debug("Auxiliary client: custom runtime resolution failed: %s", exc) runtime = None diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py index 8f53381a99..0d11dfe2d5 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) + # ---------------------------------------------------------------------------