Skip to content

fix(agent): respect HTTP_PROXY/HTTPS_PROXY when using custom httpx transport#12657

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-cbf1f93f
Apr 19, 2026
Merged

fix(agent): respect HTTP_PROXY/HTTPS_PROXY when using custom httpx transport#12657
teknium1 merged 2 commits into
mainfrom
hermes/hermes-cbf1f93f

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Proxy env vars (HTTPS_PROXY / HTTP_PROXY / ALL_PROXY) are honored again for the primary chat client, unblocking the Codex/Cloudflare cf-mitigated: challenge 403 reported by @lulu on WSL2 + Clash TUN.

Root cause: #11277 re-landed TCP keepalives by passing a custom transport=httpx.HTTPTransport(...) to httpx.Client. httpx only auto-reads proxy env vars when transport is None (Client.__init__: allow_env_proxies = trust_env and transport is None). Requests silently bypassed the local proxy → raw WSL interface → Cloudflare flagged as bot and 403'd.

Changes

  • run_agent.py: _create_openai_client reads proxy from env and forwards it to httpx.Client(proxy=...) alongside the keepalive transport. New helper _get_proxy_from_env() centralizes the lookup order.
  • tests/run_agent/test_create_openai_client_proxy_env.py: pins that an HTTPProxy pool is mounted when HTTPS_PROXY is set, that the keepalive transport is still installed on both paths, and that no proxy mount appears without env.
  • scripts/release.py: AUTHOR_MAP entry for zhurongcheng@rcrai.comheykb.

Salvage notes

Cherry-picked the proxy commit (42b394c) from @heykb's PR #12540 preserving original authorship. The kimi-k2.5 temperature changes in that PR were intentionally left out — separate behavioral contract change, will be triaged on its own.

Three other open PRs targeted the same regression:

All three will be closed with credit pointing here.

Validation

Before After
HTTPS_PROXY set, primary client mounts no HTTPProxy pool (env ignored) HTTPProxy pool mounted
No proxy env, mounts empty empty (keepalive transport still installed)
Adjacent regression guards kwargs-isolation + transport-reuse + proxy-url-validation all pass (17/17)

Closes the regression reported in hermes-agent community report from @lulu.

heykb and others added 2 commits April 19, 2026 11:36
…ansport

When creating httpx.Client with a custom transport for TCP keepalive,
proxy environment variables (HTTP_PROXY, HTTPS_PROXY) were ignored because
httpx only auto-reads them when transport=None.

Add _get_proxy_from_env() to explicitly read proxy settings and pass them
to httpx.Client, ensuring providers like kimi-coding-cn work correctly
when behind a proxy.

Fixes connection errors when HTTP_PROXY/HTTPS_PROXY are set.
Adds a regression guard for the #11277 → proxy-bypass regression fixed in
42b394c. With HTTPS_PROXY / HTTP_PROXY / ALL_PROXY set, the custom httpx
transport used for TCP keepalives must still route requests through an
HTTPProxy pool; without proxy env, no HTTPProxy mount should exist.

Also maps zrc <zhurongcheng@rcrai.com> → heykb in scripts/release.py
AUTHOR_MAP so the salvage PR passes the author-attribution CI check.
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