hermes - ✅(Solved) Fix Auxiliary client returns 502 when Windows system proxy is configured (httpx trust_env picks up proxy for localhost) [3 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#25319Fetched 2026-05-14 03:47:19
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3labeled ×3

When a system-level HTTP proxy is configured on Windows, all auxiliary LLM calls (title generation, context compression, session search, etc.) fail with Error code: 502. The main agent conversation works fine — only auxiliary/background tasks are affected.

Error Message

When a system-level HTTP proxy is configured on Windows, all auxiliary LLM calls (title generation, context compression, session search, etc.) fail with Error code: 502. The main agent conversation works fine — only auxiliary/background tasks are affected. WARNING agent.title_generator: Title generation failed: Error code: 502

Root Cause

The OpenAI Python SDK (openai>=2.x) creates its internal httpx.Client with trust_env=True by default. This causes httpx to detect and use the Windows system proxy for all requests, including those to localhost.

The proxy cannot correctly handle requests to localhost → returns 502 Bad Gateway.

Evidence from debugging:

# OpenAI SDK default client mounts show HTTPProxy for ALL patterns:
Pattern: <httpx._utils.URLPattern> -> HTTPProxy: <HTTPProxy [Requests: 0 active, 0 idle]>
Pattern: <httpx._utils.URLPattern> -> HTTPProxy: <HTTPProxy [Requests: 0 active, 0 idle]>

Fix Action

Fixed

PR fix notes

PR #25324: fix(auxiliary): bypass proxies for local OpenAI endpoints

Description (problem / solution / changelog)

Summary

  • detect loopback OpenAI-compatible auxiliary base URLs and pass a direct httpx client with trust_env=False
  • preserve the SDK/default proxy handling for remote auxiliary endpoints
  • carry the same direct-client behavior into AsyncOpenAI clients used by async auxiliary tasks

Fixes #25319.

Validation

  • python3 -m pytest tests/agent/test_auxiliary_client.py -q
  • python3 -m py_compile agent/auxiliary_client.py tests/agent/test_auxiliary_client.py

Duplicate check

  • searched open PRs for auxiliary_client/trust_env/localhost proxy/502; no direct duplicate found
  • existing proxy PRs #11733 and #12010 target run_agent.py and restore proxy use for remote main-agent traffic, while this change only bypasses proxies for loopback auxiliary endpoints

Changed files

  • agent/auxiliary_client.py (modified, +72/-18)
  • tests/agent/test_auxiliary_client.py (modified, +44/-0)

PR #25326: [Bug]: Avoid system proxy on localhost auxiliary OpenAI clients

Description (problem / solution / changelog)

Summary

This patch fixes auxiliary client calls (including title generation/compression/search side tasks) failing with Error code: 502 on Windows systems where HTTP proxy is enabled.

The OpenAI Python SDK defaults to trust_env=True, which causes localhost auxiliary endpoints (e.g. localhost / 127.0.0.1) to route through system proxy settings. This can produce bad gateway errors for local providers.

Changes

  • In agent/auxiliary_client.py:
    • Added _is_localhost_base_url(...) helper for hostname checks.
    • Kept sync localhost handling via _build_openai_client_kwargs(...).
    • Added _build_async_openai_client_kwargs(...) and applied it in _to_async_client(...).
    • Ensured async auxiliary clients also use httpx.AsyncClient(trust_env=False) for localhost base URLs.

Testing

  • Not run in this pass (per your requested flow).

Why this is correct

  • Only localhost targets are affected.
  • External providers keep existing proxy behavior.
  • Fixes both sync and async auxiliary call paths consistently.

Closes #25319

Changed files

  • agent/auxiliary_client.py (modified, +37/-2)
  • cron/jobs.py (modified, +58/-12)
  • cron/scheduler.py (modified, +2/-2)
  • tests/agent/test_auxiliary_client.py (modified, +35/-3)
  • tests/cron/test_cron_runtime_profile_paths.py (added, +38/-0)

PR #25334: fix(agent): bypass system proxy for localhost auxiliary clients

Description (problem / solution / changelog)

Summary

Auxiliary OpenAI client construction currently inherits system proxy settings ( rust_env=True) for localhost-based endpoints, which can force loopback calls through a system proxy and fail (for example on Windows with a configured system proxy).

This change makes localhost auxiliary clients consistently bypass env proxy resolution by injecting an explicit HTTPX client with rust_env=False and proxy-disabled transport when the target base URL is loopback (localhost, 127.0.0.1, ::1).

What changed

  • Add _build_local_httpx_client() to build explicit sync/async HTTPX clients for localhost targets.
  • Route both sync and async OpenAI kwargs helpers through this function.
  • Keep fallback behavior when explicit http_client is already supplied.
  • Add regression test coverage for localhost URL forms in ests/agent/test_auxiliary_client.py (localhost and loopback IP forms).

Validation

  • Unit coverage updated: regression tests in TestOpenAIProxyClientConstruction for localhost proxy bypass behavior on auxiliary OpenAI client construction.
  • No full test suite run in this step (per current workflow preference).

Closes #25319

Changed files

  • agent/auxiliary_client.py (modified, +62/-2)
  • cron/jobs.py (modified, +58/-12)
  • cron/scheduler.py (modified, +2/-2)
  • gateway/run.py (modified, +39/-1)
  • model_tools.py (modified, +3/-0)
  • run_agent.py (modified, +28/-1)
  • tests/agent/test_auxiliary_client.py (modified, +51/-3)
  • tests/cron/test_cron_runtime_profile_paths.py (added, +38/-0)
  • tests/gateway/test_agent_cache.py (modified, +48/-0)
  • tests/gateway/test_session_boundary_hooks.py (modified, +64/-0)
  • tests/run_agent/test_background_review.py (modified, +36/-0)
  • tests/run_agent/test_background_review_toolset_restriction.py (modified, +8/-0)
  • tests/run_agent/test_switch_model_fallback_prune.py (modified, +49/-0)
  • tests/test_get_tool_definitions_cache_isolation.py (modified, +20/-6)

Code Example

# OpenAI SDK default client mounts show HTTPProxy for ALL patterns:
Pattern: <httpx._utils.URLPattern> -> HTTPProxy: <HTTPProxy [Requests: 0 active, 0 idle]>
Pattern: <httpx._utils.URLPattern> -> HTTPProxy: <HTTPProxy [Requests: 0 active, 0 idle]>

---

WARNING agent.title_generator: Title generation failed: Error code: 502

---

import httpx

# When base_url points to localhost, bypass system proxy
base_url_str = str(base_url or "")
if "localhost" in base_url_str or "127.0.0.1" in base_url_str:
    http_client = httpx.Client(trust_env=False)
    client = OpenAI(api_key=api_key, base_url=base_url, http_client=http_client)
else:
    client = OpenAI(api_key=api_key, base_url=base_url)
RAW_BUFFERClick to expand / collapse

Bug: Auxiliary client (title generation etc.) returns 502 when Windows system proxy is configured

Summary

When a system-level HTTP proxy is configured on Windows, all auxiliary LLM calls (title generation, context compression, session search, etc.) fail with Error code: 502. The main agent conversation works fine — only auxiliary/background tasks are affected.

Root Cause

The OpenAI Python SDK (openai>=2.x) creates its internal httpx.Client with trust_env=True by default. This causes httpx to detect and use the Windows system proxy for all requests, including those to localhost.

The proxy cannot correctly handle requests to localhost → returns 502 Bad Gateway.

Evidence from debugging:

# OpenAI SDK default client mounts show HTTPProxy for ALL patterns:
Pattern: <httpx._utils.URLPattern> -> HTTPProxy: <HTTPProxy [Requests: 0 active, 0 idle]>
Pattern: <httpx._utils.URLPattern> -> HTTPProxy: <HTTPProxy [Requests: 0 active, 0 idle]>

Reproduction

  1. Configure a Windows system proxy (Settings → Network → Proxy)
  2. Use a custom provider pointing to http://localhost:<port>/v1
  3. Start Hermes — main conversation works, but title generation fails:
WARNING agent.title_generator: Title generation failed: Error code: 502

Verification

Methodtrust_envTransportResult
OpenAI SDK defaultTrueHTTPProxy502
OpenAI SDK + httpx.Client(trust_env=False)FalseDirect200
OpenAI SDK + httpx.Client(transport=HTTPTransport())Direct200
requests library (default)Direct200
curlDirect200

Suggested Fix

In _get_cached_client() (agent/auxiliary_client.py), when creating an OpenAI client for a localhost/127.0.0.1 base URL, pass a custom httpx.Client with trust_env=False:

import httpx

# When base_url points to localhost, bypass system proxy
base_url_str = str(base_url or "")
if "localhost" in base_url_str or "127.0.0.1" in base_url_str:
    http_client = httpx.Client(trust_env=False)
    client = OpenAI(api_key=api_key, base_url=base_url, http_client=http_client)
else:
    client = OpenAI(api_key=api_key, base_url=base_url)

Alternatively, set trust_env=False universally for auxiliary clients since they should connect directly to the configured endpoint.

Environment

  • OS: Windows 11
  • Hermes version: Latest (from git, 2026-05-13)
  • openai SDK: 2.24.0
  • httpx: 0.28.1
  • Provider: Custom provider at http://localhost:20128/v1
  • Proxy: Windows system HTTP proxy enabled

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix Auxiliary client returns 502 when Windows system proxy is configured (httpx trust_env picks up proxy for localhost) [3 pull requests, 1 participants]