fix: drop isinstance(str) guard so client.base_url fallback works with httpx.URL

The OpenAI SDK exposes client.base_url as an httpx.URL object, not str.
The isinstance(live_raw, str) guard made this branch dead code in
production. Use _normalized_runtime_url (which coerces via str()) so
the fallback actually fires.
This commit is contained in:
kshitijk4poor 2026-06-27 03:52:36 +05:30 committed by kshitij
parent 2608f78b93
commit a67ddf5983

View file

@ -1013,15 +1013,15 @@ def _inherit_parent_base_url(parent_agent, fallback_base_url: Optional[str]) ->
client = getattr(parent_agent, "client", None)
if client is not None:
live_raw = getattr(client, "base_url", "")
if isinstance(live_raw, str):
live_url = _normalized_runtime_url(live_raw)
if (
live_url
and live_url != surface_url
and live_url.startswith(("http://", "https://"))
):
return live_url
# OpenAI SDK exposes ``base_url`` as an ``httpx.URL``, not ``str`` —
# coerce so the comparison works regardless of the client's type.
live_url = _normalized_runtime_url(getattr(client, "base_url", ""))
if (
live_url
and live_url != surface_url
and live_url.startswith(("http://", "https://"))
):
return live_url
return fallback_base_url or None