From ad764d351351ed1cd139e7a371b6956d84eed5f9 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 26 Mar 2026 18:21:59 -0700 Subject: [PATCH] fix(auxiliary): catch ImportError from build_anthropic_client in vision auto-detection (#3312) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _try_anthropic() caught ImportError on the module import (line 667-669) but not on the build_anthropic_client() call (line 696). When the anthropic_adapter module imports fine but the anthropic SDK is missing, build_anthropic_client() raises ImportError at call time. This escaped _try_anthropic() entirely, killing get_available_vision_backends() and cascading to 7 test failures: - 4 setup wizard tests hit unexpected 'Configure vision:' prompt - 3 codex-auth-as-vision tests failed check_vision_requirements() The fix wraps the build_anthropic_client call in try/except ImportError, returning (None, None) when the SDK is unavailable — consistent with the existing guard at the top of the function. --- agent/auxiliary_client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 6e01664ac..7c9763fc0 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -693,7 +693,13 @@ def _try_anthropic() -> Tuple[Optional[Any], Optional[str]]: is_oauth = _is_oauth_token(token) model = _API_KEY_PROVIDER_AUX_MODELS.get("anthropic", "claude-haiku-4-5-20251001") logger.debug("Auxiliary client: Anthropic native (%s) at %s (oauth=%s)", model, base_url, is_oauth) - real_client = build_anthropic_client(token, base_url) + try: + real_client = build_anthropic_client(token, base_url) + except ImportError: + # The anthropic_adapter module imports fine but the SDK itself is + # missing — build_anthropic_client raises ImportError at call time + # when _anthropic_sdk is None. Treat as unavailable. + return None, None return AnthropicAuxiliaryClient(real_client, model, token, base_url, is_oauth=is_oauth), model