Repository navigation
fix: honor system proxy env vars for Anthropic online requests - #725
Merged
Merged
Conversation
…kelabsai#699) aiohttp.ClientSession ignores HTTP_PROXY/HTTPS_PROXY/ALL_PROXY unless trust_env=True is set explicitly, unlike requests/httpx. Since the shared online request path posts directly via aiohttp rather than the anthropic SDK client, proxy env vars were silently ignored, causing timeouts or direct connections in proxied environments. Sets trust_env=True on the shared aiohttp session used by all online request processors, and adds a regression test asserting the session created by aiohttp_connector trusts the environment.
madiator
self-requested a review
July 12, 2026 23:03
madiator
approved these changes
Jul 13, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #699 — Anthropic client fails to use system proxy.
Curator's online (non-batch) request path doesn't actually call the
anthropicSDK client —AnthropicOnlineRequestProcessor.call_single_requestposts directly to the Anthropic REST endpoint using the sharedaiohttp.ClientSessioncreated inBaseOnlineRequestProcessor.aiohttp_connector. That session was constructed withouttrust_env=True.Unlike
requests/httpx,aiohttp.ClientSessiondoes not readHTTP_PROXY/HTTPS_PROXY/ALL_PROXY/NO_PROXYenv vars unlesstrust_env=Trueis explicitly passed. Without it, aiohttp always connects directly, bypassing any configured system/corporate proxy — exactly what's reported in #699.This PR sets
trust_env=Trueon that shared session. Sinceaiohttp_connectoris used by all online request processors (not just Anthropic), this also fixes the same class of bug for other providers that go through the same path.Why not just bump the
anthropicdependency (as proposed in #698)?#698 proposed both
trust_env=Trueand bumpinganthropicto>=0.54.0. I checked currentmainand the dependency is already on^0.84.0, well past0.54.0, so that half is already moot. It also wouldn't have fixed this bug on its own: the online path never calls theanthropicSDK client, so an SDK version bump has no effect here. The batch path (anthropic_batch_request_processor.py) does use the realAsyncAnthropic/httpx-based client, which defaultstrust_env=Truealready, so it was never actually affected by this bug.Verification
Added a unit test (
tests/unittests/test_base_online_request_processor.py) asserting the session returned byaiohttp_connectorhastrust_env=True. Confirmed it fails onmainand passes with this change.I also verified the fix end-to-end with a local fake proxy: pointed
HTTPS_PROXYat a local TCP listener and made a request toapi.anthropic.comthrough anaiohttp.ClientSession.trust_env=False): request went straight to the real API, completely bypassing the local proxy.trust_env=True): the local proxy receivedCONNECT api.anthropic.com:443 HTTP/1.1— aiohttp correctly tunneled through the configured proxy.Test plan
pytest tests/unittests/test_base_online_request_processor.pypasses with the fix, fails without ittests/unittests/suite — no regressions (pre-existing failures needing live network/API-key access are unrelated to this change and present identically onmain)