Skip to content

fix(weixin,api_server): proxy support, content normalization, HermesClaw docs - #8680

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-f37b1d3f
Apr 13, 2026
Merged

fix(weixin,api_server): proxy support, content normalization, HermesClaw docs#8680
teknium1 merged 3 commits into
mainfrom
hermes/hermes-f37b1d3f

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Three changes salvaged from community PRs, each independent and clean.

1. Proxy support for aiohttp sessions (cherry-pick from #8280)

Adds trust_env=True to all aiohttp.ClientSession() calls in weixin.py, wecom.py, and matrix.py. This makes aiohttp respect HTTP_PROXY/HTTPS_PROXY env vars — critical for Chinese users behind proxies (Clash fake-IP mode) who can't connect to WeChat/WeCom APIs at all without it. No-op for non-proxy users.

Author: Sicheng Li (@MaybeRichard)

2. HermesClaw community docs (cherry-pick from #7375)

One-line README addition linking HermesClaw (community WeChat bridge) in the Community section.

Author: AaronWong1999 (@AaronWong1999)

3. Normalize array-based content parts in API server (salvaged from #7980)

Some OpenAI-compatible clients send content as typed arrays ([{type: 'text', text: 'hello'}]) instead of strings. The Chat Completions endpoint had no normalization, causing silent failures. Adds _normalize_chat_content() with defensive limits (recursion depth, list size, 64KB output cap) and applies it to both Chat Completions and Responses API endpoints. The Responses path had inline normalization that only handled input_text/output_text — the shared function also handles the standard text type.

Only the content normalization from #7980 was taken. The SSE changes (reverted #6972 tool progress fix, removed keepalive pings) and Weixin changes (conflicted with #8665, removed retry logic, removed blank-message guards) were regressions and are excluded.

Author: ikelvingo (@ikelvingo) — co-authored

Files changed

  • gateway/platforms/weixin.py — trust_env=True (3 locations)
  • gateway/platforms/wecom.py — trust_env=True (1 location)
  • gateway/platforms/matrix.py — trust_env=True (1 location)
  • gateway/platforms/api_server.py — _normalize_chat_content function + applied in 2 endpoints
  • tests/gateway/test_api_server_normalize.py — 17 new tests
  • README.md — 1 line added

Test plan

python -m pytest tests/gateway/test_api_server_normalize.py -v  # 17 passed
python -m pytest tests/gateway/test_api_server*.py -v            # 188 passed
python -m pytest tests/gateway/test_weixin.py -v                 # 34 passed

PRs to close after merge

MaybeRichard and others added 3 commits April 12, 2026 17:14
aiohttp.ClientSession defaults to trust_env=False, ignoring HTTP_PROXY/
HTTPS_PROXY env vars. This causes QR login and all API calls to fail for
users behind a proxy (e.g. Clash in fake-ip mode), which is common in
China where Weixin and WeCom are primarily used.

Added trust_env=True to all aiohttp.ClientSession instantiations that
connect to external hosts (weixin: 3 places, wecom: 1, matrix: 1).
WhatsApp sessions are excluded as they only connect to localhost.

httpx-based adapters (dingtalk, signal, wecom_callback) are unaffected
as httpx defaults to trust_env=True.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a one-line entry for HermesClaw (community WeChat bridge) to the Community section. It lets users run Hermes Agent and OpenClaw on the same WeChat account.
Some OpenAI-compatible clients (Open WebUI, LobeChat, etc.) send
message content as an array of typed parts instead of a plain string:

    [{"type": "text", "text": "hello"}]

The agent pipeline expects strings, so these array payloads caused
silent failures or empty messages.

Add _normalize_chat_content() with defensive limits (recursion depth,
list size, output length) and apply it to both the Chat Completions
and Responses API endpoints. The Responses path had inline
normalization that only handled input_text/output_text — the shared
function also handles the standard 'text' type.

Salvaged from PR #7980 (ikelvingo) — only the content normalization;
the SSE and Weixin changes in that PR were regressions and are not
included.

Co-authored-by: ikelvingo <ikelvingo@users.noreply.github.com>
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.

3 participants