fix(providers): disable proxy for local endpoints, respect env proxy for cloud

When the host has HTTP_PROXY / HTTPS_PROXY / ALL_PROXY set, httpx routes
all traffic through the proxy — including requests to localhost or LAN
addresses that the proxy typically cannot reach.  This breaks local model
servers (Ollama, llama.cpp, vLLM) silently.

- Local endpoints: pass transport=httpx.AsyncHTTPTransport(proxy=None)
  so proxy env vars are ignored for local traffic.
- Cloud endpoints: pass trust_env=True so corporate/VPN proxies work
  without explicit configuration.

Fixes #4366
This commit is contained in:
michaelxer
2026-06-18 00:03:03 +08:00
committed by Xubin Ren
parent bfe5b64022
commit 72b8fc806f
3 changed files with 76 additions and 2 deletions
@@ -16,7 +16,10 @@ async def test_openai_compat_provider_defers_sdk_client_until_first_use() -> Non
kwargs = mock_async_openai.call_args.kwargs
_assert_openai_compat_timeout(kwargs["timeout"])
assert kwargs["http_client"] is None
# Cloud endpoints get an httpx client with trust_env=True to respect
# proxy environment variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY).
assert kwargs["http_client"] is not None
assert kwargs["http_client"]._trust_env is True
async def test_openai_compat_provider_sets_timeout_on_local_http_client() -> None: