Skip to content

Respect proxy env when constructing injected OpenAI clients#11943

Closed
wanghao-SunSky wants to merge 1 commit into
NousResearch:mainfrom
wanghao-SunSky:codex/respect-proxy-env-openai-client
Closed

Respect proxy env when constructing injected OpenAI clients#11943
wanghao-SunSky wants to merge 1 commit into
NousResearch:mainfrom
wanghao-SunSky:codex/respect-proxy-env-openai-client

Conversation

@wanghao-SunSky

Copy link
Copy Markdown

Summary

  • skip injected custom httpx.Client creation when standard proxy env vars are present
  • preserve the existing keepalive transport path when no proxy env is configured
  • add a regression test to lock the proxy-aware behavior

Problem

_create_openai_client() injects a custom httpx.Client(transport=HTTPTransport(...)) to set TCP keepalive socket options. That transport path does not inherit environment proxy settings, so providers that rely on HTTP(S)_PROXY or ALL_PROXY silently bypass the user's proxy path.

In practice this broke openai-codex for local proxy setups: Codex CLI requests succeeded, but Hermes requests to chatgpt.com/backend-api/codex timed out because Hermes was effectively direct-connecting.

Validation

  • python -m pytest -q tests/run_agent/test_create_openai_client_kwargs_isolation.py tests/run_agent/test_create_openai_client_reuse.py
  • live repro with proxy env configured: hermes -p memecoinscout chat -q "只回复 ok" -Q --provider openai-codex -m gpt-5.4 now returns ok

@teknium1

Copy link
Copy Markdown
Contributor

Thanks @wanghao-SunSky for the report and the diagnosis — you correctly identified that the custom httpx transport from #11277 was suppressing env-proxy handling.

Fixed on main via #12657 using an alternative approach: the keepalive-enabled transport is preserved, and the proxy env is forwarded explicitly to httpx.Client(proxy=...). This keeps the dead-connection detection from #10324 working for proxy users too — skipping the custom transport entirely (as in this PR) would silently opt them out of it.

Closing as superseded. Thanks again for the well-scoped fix and test — your PR was the first to surface this on our end.

@teknium1 teknium1 closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants