Skip to content

[PR] fix(hermes): route a plain-http provider base_url through the proxy (#5116) - #5117

Closed
elight wants to merge 4 commits into
ranxianglei:masterfrom
elight:hermes-native-route-plain-http
Closed

elight wants to merge 4 commits into
ranxianglei:masterfrom
elight:hermes-native-route-plain-http

Conversation

@elight

@elight elight commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #5116.

The native Hermes plugin set only HTTPS_PROXY/https_proxy, so a provider base_url over plain http (a LAN llama.cpp, vLLM or ollama server) went straight to the server. bili never saw those turns and nothing was compressed.

apply_env now also sets HTTP_PROXY/http_proxy to the origin and defaults NO_PROXY/no_proxy to loopback (127.0.0.1,localhost,::1). That is the same split the launcher uses for its own plain-http routes. A NO_PROXY the user has already set is left alone.

All four keys are added to _ENV_ROUTED_KEYS, so the #4644 watchdog unroutes and restores them along with the HTTPS pair when the origin dies. Without that, a dead proxy would strand plain-http traffic exactly as #2714 described for https.

Tests: tests/hermes-native.test.ts

  • attach: the HTTP pair equals the origin and NO_PROXY is the loopback default.
  • origin-death: HTTP_PROXY leaves the dead origin during the gap and comes back with the recovered one.

With the change, 51/51 pass. With only the plugin change reverted, both new assertions fail (49 pass, 2 fail).

Field note: we have run the equivalent change on a Hermes v0.22.5 host since 2026-10-25, with a plain-http LAN gateway as the main provider, and bili forwards the absolute-form requests correctly.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MMUmTHLFoNYr4iAsprTFfk

…anxianglei#5116)

The native plugin set only HTTPS_PROXY, so a plain-http base_url (a LAN
llama.cpp, vLLM or ollama server) bypassed the proxy and its sessions were
never compressed. apply_env now sets the HTTP pair too and defaults NO_PROXY
to loopback, matching the launcher's own plain-http routes. All of them sit
in _ENV_ROUTED_KEYS, so the ranxianglei#4644 watchdog unroutes and restores them along
with the HTTPS pair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMUmTHLFoNYr4iAsprTFfk
@ranxianglei ranxianglei changed the title fix(hermes): route a plain-http provider base_url through the proxy (#5116) [PR] fix(hermes): route a plain-http provider base_url through the proxy (#5116) Oct 29, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重结论:不重复(本 PR 是首个修复),但审出撞车——同一 bug 有两个在途 PR。

标签:bug / hermes / scope/wiring / p2(能用但静默零压缩,有绕行——https provider 或手动 /bili/ 前缀;镜像 labels API 未实现,无法经 API 打标,在此声明判定)。

验证证据(本地,当前 master 5594c13 上应用本 PR diff,两文件自 base 885b948 以来无变动、干净套用):

  • 定向套件 tests/hermes-native.test.ts:51/51 过(与 PR 声称一致);
  • 负控制:只回退插件改动重跑 → 49 过 / 2 挂(恰为两条新断言)——测试有牙,能抓回该 bug;
  • typecheck 干净;
  • CI(head 461504c):47 项检查全完成,35 success + 12 skipped,0 失败。

结构化八问(针对本 PR 现状):

  1. 是什么问题:hermes 原生插件只导出 HTTPS_PROXY,plain-http 的 provider(LAN llama.cpp/vLLM/ollama)流量直连模型服务器,bili 完全看不到,零压缩、acp_status 空。
  2. 什么原因导致的:httpx 按 scheme 解析代理变量——http:// 目标只读 HTTP_PROXY,从不读 HTTPS_PROXY;插件只导出了 HTTPS 一对。
  3. 影响范围与严重程度:所有用原生插件且主 provider 走 plain-http 的 hermes 用户(本地推理场景很常见)。宿主照常可用,但核心承诺(压缩)静默失效,上下文无界增长直到窗口压力——p2(有绕行,非不可用)。
  4. 怎么修复的:apply_env 补导 HTTP_PROXY/http_proxy=;NO_PROXY/no_proxy 默认设回环(保持 bili 自身管理流量直连);四键并入 _ENV_ROUTED_KEYS,bug(hermes): No self-healing after bootstrap failure/agent death; silent direct connection can persist for the entire ho | bug(hermes): 引导失败/代理死亡后无自愈,静默直连可持续整个宿主生命周期 #4644 看门狗在 origin 死亡时一并解除路由并还原(否则死代理会把 plain-http 流量永久搁浅,[feat][plugin] hermes native lane always spawns on an ephemeral port → long-lived hosts strand on a dead HTTPS_PROXY (opencode got #1664) #2714 同类)。与 launcher 对 dsh/kimi/mcode 车道的既有拆分一致。
  5. 是否有回归问题:审过以下既有行为——
    • ⚠️ 一处未披露的行为变更:默认 NO_PROXY=回环后,hermes 车道的回环 https provider 从「CONNECT MITM(被压缩)」变为「直连(不压缩)」。这与其它车道的回环直连契约一致(dsh/kimi/jcode/zed,支持kimi code #757 谱系),方向正确,但按政策必须披露旧值→新值+原因,PR 正文没写([PR] fix(hermes launcher): route plain-http providers through the proxy (#5116) #5121 的披露表里写了这一条);
    • 用户已设的 NO_PROXY(不含回环)被 setdefault 原样保留:此时回环模型流量会绕道代理而非直连、插件管理流量会 hairpin 过代理(无害,自寻址管理请求由代理本地应答)——边缘情形,可接受,与 launcher 的「合并保留」姿态略有差异,仅记录;
    • 看门狗路径逐一核过:env_backup 在 lifecycle 锁内一次性快照、_unroute_env 逐键还原或删键、死亡→重建循环中 8 键语义正确,restore-not-delete 契约保持;
    • 无线格式变更、无 kernel 触碰、无配置面新增;hermes 原生是 pluginMode 车道,proxy 模式客户端不受影响。
  6. 是否破坏缓存:不涉及(无身份/ref/缓存键变化,只是改变了哪些流量到达代理)。
  7. 是否改了设计方向:不涉及——是把 hermes 原生车道对齐到既有的按-scheme 代理变量契约。遗留同族实例:bili hermes launcher 分支同样只设 HTTPS_PROXY(同症状、另一入口),本 PR 未覆盖,[PR] fix(hermes launcher): route plain-http providers through the proxy (#5116) #5121 已覆盖。
  8. 是否引入新配置:不涉及(纯进程内 env 路由,无新 BILI_*/配置字段)。

处置请求(需 owner 拍板)——一个 bug 收敛为一个合入 PR:

判定:本 PR 本身正确、最小、测试有牙、CI 全绿,技术上可合;但建议先做上述收敛再合,避免同 bug 两个 PR 各自合入造成 diff 重叠与关闭引用混乱。我未向任何分支推送提交(验证全部通过本地套用 diff + 定向测试完成)。

ranxianglei pushed a commit that referenced this pull request Nov 5, 2026
…5116)

Companion to PR #5117 (reporter's fork PR), which fixes the same
mechanism in the native plugin lane and stays there untouched — this
branch is a fork, so this PR covers only the complementary part:
the 'bili hermes' LAUNCHER lane + docs + launcher test.

hermes' httpx stack resolves proxy envs per scheme (field-verified on
Hermes v0.22.5): https upstreams read HTTPS_PROXY, plain-http upstreams
read HTTP_PROXY. The launcher exported only the HTTPS pair, so plain-http
providers went straight out and bili never saw them (#5116). Same defect
class as the plugin lane; same fix shape as the dsh/kimi/mcode/jcode/zed/
qwen house pattern (HTTP_PROXY = origin + loopback NO_PROXY). The child
env is stripped of inherited proxy vars first, so the static loopback
constant is the whole NO_PROXY value here.

Behavior changes (disclosed per policy):
- plain-http provider traffic: direct to server -> routed through bili
  (absolute-form forward-proxy requests) — the intended fix.
- child env gains HTTP_PROXY/http_proxy=<origin> and
  NO_PROXY/no_proxy=localhost,127.0.0.1,::1.
- loopback https providers now go DIRECT instead of CONNECT-MITM'd
  through bili — consistent with the loopback-direct contract every
  other env-routing lane already keeps for its own proxy origin.
- non-model http egress of the spawned hermes process rides bili
  instead of going direct.

Together with #5117 this completes #5116; the two PRs touch disjoint
files and merge cleanly in either order.
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: vllm-qwen/qwen3.8-27b)

@elight thanks for the PR — triaged and kept as-is (first-filed, it owns the plugin-lane fix). Two notes from reviewing the full surface:

  1. The same mechanism gap exists in the launcher lane (bili hermes, src/launcher.ts): it exported only HTTPS_PROXY, so plain-http providers were invisible to bili there too. Your branch lives in a fork so I can't push into it — covered instead by companion PR [PR] fix(hermes launcher): route plain-http providers through the proxy (#5116) #5121 (launcher lane + docs + launcher test only; disjoint files from yours, merges cleanly in either order). Both PRs together close [bug][plugin] hermes native lane never routes a plain-http provider base_url (only HTTPS_PROXY is set) #5116.
  2. NO_PROXY semantics differ by lane, deliberately: your plugin code leaves a user-set NO_PROXY untouched (defaulting to loopback when unset) — correct there, since the plugin runs inside the user's live process. The launcher uses the static localhost,127.0.0.1,::1 because the child env is stripped of ALL inherited proxy vars before export (stripInheritedProxy), so nothing user-set survives to preserve.

CI verdict on this head comes from remote CI; no changes needed from you unless review asks for something.

@elight

elight commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@ranxianglei SGTM! I'm glad either way so long as it's fixed!

@elight

elight commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

So shall we close this one in favor of yours?

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

@elight Short answer: nothing needs closing — per @ranxianglei's review above, this PR is kept as-is: it owns the plugin-lane fix, and companion PR #5121 covers only the launcher lane + docs (disjoint files); the two together close bug #5116. Which PRs stay open / get merged is the repo owner's call, so there's no action for you here.

One status note on this thread's open item: CI is now fully green on head 05db6ed7c (the sync commit that merged the repo's ci-fixes branch into your branch, clearing the four inherited test-shard failures that were unrelated to your diff) — 11/11 test shards pass, 0 failures across all 30 checks. The one remaining procedural step before a merge is possible: the branch is currently behind master, so it needs a final sync + CI re-run (that's the repo's merge-guard lane), after which the owner can merge.

ranxianglei pushed a commit that referenced this pull request Nov 9, 2026
…hips it (#5116)

Review fix on this branch: the plugin-lane sentence claimed HTTP_PROXY /
NO_PROXY routing that this PR does not ship for the native plugin. The
plugin's apply_env still sets only the HTTPS pair + CA bundles; the plain-http
half lives in open PR #5117 (adds the HTTP pair + NO_PROXY setdefault to
apply_env). Reword so each claim matches code on master: the launcher lane
(this PR) routes both schemes; the plugin lane gets them via #5117.
@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6482 (merged) — closing as superseded.

@ranxianglei ranxianglei reopened this Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Confirmed against current master (36a04a7986): both lanes of the fix are present — the plugin lane (hermes-plugin/__init__.py: HTTP_PROXY/http_proxy set to the origin, NO_PROXY/no_proxy loopback default, all four proxy keys + the NO_PROXY pair in _ENV_ROUTED_KEYS so the #4644 watchdog unroutes them on origin death) and the launcher lane (src/launcher.ts: HTTP_PROXY routing for plaintext-http upstreams). Consistent with the batch PR having landed; nothing pending from this thread's CI side (its last head 05db6ed7c was fully green before being superseded). No further action needed here.

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.

[bug][plugin] hermes native lane never routes a plain-http provider base_url (only HTTPS_PROXY is set)

2 participants