fix(auxiliary): widen effective provider to relay, logging, and endpoint detection

Thread request_provider through the sibling callsites that the
original PR left on resolved_provider: _set_relay_auxiliary_route
(observability metadata), the 'using X' log line, _is_anthropic_compat_endpoint
(Anthropic image conversion), _provider_requires_stream (streaming
detection), and the initial _relay_sync/async_completion calls.

These are NOT regressions (they passed 'auto' before), but widening
them ensures auto-routed calls to MiniMax get correct image conversion,
streaming-only providers are detected, and observability metadata
records the concrete backend instead of 'auto'.
This commit is contained in:
kshitij
2026-08-07 15:39:21 +05:30
parent 293e67328c
commit c95a1b7171
+15 -15
View File
@@ -8823,7 +8823,7 @@ def _call_llm_impl(
effective_timeout = _effective_aux_timeout(task, timeout)
request_provider = effective_provider or resolved_provider
_set_relay_auxiliary_route(
resolved_provider,
request_provider,
final_model,
resolved_api_mode,
)
@@ -8832,7 +8832,7 @@ def _call_llm_impl(
_base_info = str(getattr(client, "base_url", resolved_base_url) or "")
if task:
logger.info("Auxiliary %s: using %s (%s)%s",
task, resolved_provider or "auto", final_model or "default",
task, request_provider or "auto", final_model or "default",
f" at {_base_info}" if _base_info and "openrouter" not in _base_info else "")
# Pass the client's actual base_url (not just resolved_base_url) so
@@ -8849,7 +8849,7 @@ def _call_llm_impl(
# Convert image blocks for Anthropic-compatible endpoints (e.g. MiniMax)
_client_base = str(getattr(client, "base_url", "") or "")
if _is_anthropic_compat_endpoint(resolved_provider, _client_base):
if _is_anthropic_compat_endpoint(request_provider, _client_base):
kwargs["messages"] = _convert_openai_images_to_anthropic(kwargs["messages"])
# Streaming path: return the raw SDK Stream iterator directly. This is used by
@@ -8877,7 +8877,7 @@ def _call_llm_impl(
return _relay_sync_stream(
client,
kwargs,
provider=resolved_provider,
provider=request_provider,
api_mode=resolved_api_mode,
)
@@ -8905,19 +8905,19 @@ def _call_llm_impl(
_relay_sync_completion(
client,
kwargs,
provider=resolved_provider,
provider=request_provider,
api_mode=resolved_api_mode,
create=lambda request: _create_with_progress(
client,
request,
task,
force_stream=_provider_requires_stream(
resolved_provider, _base_info or resolved_base_url,
request_provider, _base_info or resolved_base_url,
),
),
),
task,
provider=resolved_provider, base_url=_base_info)
provider=request_provider, base_url=_base_info)
except Exception as transient_err:
if not _is_transient_transport_error(transient_err):
raise
@@ -8952,14 +8952,14 @@ def _call_llm_impl(
_relay_sync_completion(
client,
kwargs,
provider=resolved_provider,
provider=request_provider,
api_mode=resolved_api_mode,
create=lambda request: _create_with_progress(
client,
request,
task,
force_stream=_provider_requires_stream(
resolved_provider,
request_provider,
_base_info or resolved_base_url,
),
),
@@ -9596,7 +9596,7 @@ async def _async_call_llm_impl(
effective_timeout = _effective_aux_timeout(task, timeout)
request_provider = effective_provider or resolved_provider
_set_relay_auxiliary_route(
resolved_provider,
request_provider,
final_model,
resolved_api_mode,
)
@@ -9613,7 +9613,7 @@ async def _async_call_llm_impl(
base_url=_client_base or resolved_base_url, task=task)
# Convert image blocks for Anthropic-compatible endpoints (e.g. MiniMax)
if _is_anthropic_compat_endpoint(resolved_provider, _client_base):
if _is_anthropic_compat_endpoint(request_provider, _client_base):
kwargs["messages"] = _convert_openai_images_to_anthropic(kwargs["messages"])
try:
@@ -9622,7 +9622,7 @@ async def _async_call_llm_impl(
# for the rationale. (PR #16587)
_force_stream_async = (
_provider_requires_stream(
resolved_provider, _client_base or resolved_base_url,
request_provider, _client_base or resolved_base_url,
)
and not isinstance(client, (
AsyncCodexAuxiliaryClient,
@@ -9641,12 +9641,12 @@ async def _async_call_llm_impl(
await _relay_async_completion(
client,
kwargs,
provider=resolved_provider,
provider=request_provider,
api_mode=resolved_api_mode,
create=_acreate,
),
task,
provider=resolved_provider, base_url=_client_base)
provider=request_provider, base_url=_client_base)
except Exception as transient_err:
if not _is_transient_transport_error(transient_err):
raise
@@ -9669,7 +9669,7 @@ async def _async_call_llm_impl(
await _relay_async_completion(
client,
kwargs,
provider=resolved_provider,
provider=request_provider,
api_mode=resolved_api_mode,
create=_acreate,
),