Description
resolve_provider_client() in agent/auxiliary_client.py handles named custom providers (from custom_providers list in config.yaml) by unconditionally creating an OpenAI(...) client, even when the provider's api_mode is anthropic_messages.
# Line ~1460 in v0.9.0
client = OpenAI(api_key=custom_key, base_url=custom_base)
This means custom providers pointing to Anthropic-compatible endpoints (corporate proxies, self-hosted deployments) send requests in OpenAI format, causing ChatCompletion.choices = None crashes.
Context
This is the third layer of the bug reported in #8857. PR #8871 (merged in v0.9.0) correctly fixed:
_normalize_aux_provider() stripping named provider identity for vision tasks
resolve_vision_provider_client() not propagating api_mode downstream
But the underlying issue remains: even with api_mode correctly propagated, the named custom provider code path never checks it.
Expected Behavior
When a named custom provider has api_mode: anthropic_messages (either in config or passed as parameter), resolve_provider_client() should create an AnthropicAuxiliaryClient wrapping the native Anthropic SDK — mirroring how _try_anthropic() already handles the built-in anthropic provider.
Suggested Fix
In the named custom provider block of resolve_provider_client():
effective_api_mode = api_mode or custom_entry.get("api_mode", "")
if effective_api_mode == "anthropic_messages":
try:
from agent.anthropic_adapter import build_anthropic_client
real_client = build_anthropic_client(custom_key, custom_base)
client = AnthropicAuxiliaryClient(
real_client, final_model, custom_key, custom_base)
except ImportError:
logger.warning(
"resolve_provider_client: anthropic SDK not available "
"for custom provider %r, falling back to OpenAI client",
provider)
client = OpenAI(api_key=custom_key, base_url=custom_base)
else:
client = OpenAI(api_key=custom_key, base_url=custom_base)
Environment
- Hermes v0.9.0 (v2026.4.13), macOS
- Custom provider: corporate Anthropic proxy with
api_mode: anthropic_messages
- Patched locally and working in production
Related
Description
resolve_provider_client()inagent/auxiliary_client.pyhandles named custom providers (fromcustom_providerslist in config.yaml) by unconditionally creating anOpenAI(...)client, even when the provider'sapi_modeisanthropic_messages.This means custom providers pointing to Anthropic-compatible endpoints (corporate proxies, self-hosted deployments) send requests in OpenAI format, causing
ChatCompletion.choices = Nonecrashes.Context
This is the third layer of the bug reported in #8857. PR #8871 (merged in v0.9.0) correctly fixed:
_normalize_aux_provider()stripping named provider identity for vision tasksresolve_vision_provider_client()not propagatingapi_modedownstreamBut the underlying issue remains: even with
api_modecorrectly propagated, the named custom provider code path never checks it.Expected Behavior
When a named custom provider has
api_mode: anthropic_messages(either in config or passed as parameter),resolve_provider_client()should create anAnthropicAuxiliaryClientwrapping the native Anthropic SDK — mirroring how_try_anthropic()already handles the built-in anthropic provider.Suggested Fix
In the named custom provider block of
resolve_provider_client():Environment
api_mode: anthropic_messagesRelated