fix(providers): remove custom cloud httpx client, let SDK handle proxy defaults

chengyongru reviewed #4367 and identified that the cloud  branch
created a bare httpx.AsyncClient that lacked the SDK's default settings
(follow_redirects, connection pool limits). Since the SDK's
DefaultAsyncHttpxClient already has trust_env=True and proper defaults,
the simplest fix is to let http_client stay None for cloud endpoints.

Also updated the test to match the new behavior (http_client is None).
This commit is contained in:
michaelxer
2026-06-18 00:03:03 +08:00
committed by Xubin Ren
parent 72b8fc806f
commit 0023f6d998
2 changed files with 7 additions and 12 deletions
+3 -8
View File
@@ -417,14 +417,9 @@ class OpenAICompatProvider(LLMProvider):
timeout=timeout_s,
transport=httpx.AsyncHTTPTransport(proxy=None, limits=_local_limits),
)
else:
# Cloud endpoints: respect proxy environment variables
# (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY) so corporate
# or VPN proxies work without explicit configuration.
http_client = httpx.AsyncClient(
timeout=timeout_s,
trust_env=True,
)
# else: http_client stays None → SDK creates DefaultAsyncHttpxClient
# which already reads proxy env vars via trust_env=True, has proper
# connection limits, and follows redirects.
self._client = AsyncOpenAI(
api_key=self._api_key_for_client,
base_url=self._effective_base,