Skip to content

[PR] fix(#2645/#2649/#2583): wire-conformant prompt_cache_key on every egress lane + Cowork lane routing - #3556

Closed
askl56 wants to merge 5 commits into
ranxianglei:masterfrom
askl56:fork/pck-wire-conformance
Closed

askl56 wants to merge 5 commits into
ranxianglei:masterfrom
askl56:fork/pck-wire-conformance

Conversation

@askl56

@askl56 askl56 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Summary

prompt_cache_key currently reaches upstream bodies on lanes where either (a) the wire schema doesn't define it, or (b) bili never owns the bytes. Two independent classes:

  1. Chat wire (openai wire: prompt_cache_key stamped unconditionally — breaks strict-schema upstreams (NVIDIA NIM 400), no config escape #2645 / [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649). shouldStampRelayAffinityPck short-circuits return true whenever routeRewrittenUrl !== undefined. The /bili/ tunnel lane rewrites the user's own remote destination, so the loopback check is dead there — strict remote APIs get an unknown body param and 400 (reported on NVIDIA NIM in openai wire: prompt_cache_key stamped unconditionally — breaks strict-schema upstreams (NVIDIA NIM 400), no config escape #2645). PR [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 already gates the stamp to loopback for the Responses path; this PR adopts the same semantics and closes the remaining hole: a client-supplied prompt_cache_key passed through verbatim on the chat wire (prepare-openai.ts documents it as deliberate passthrough) — the same 400 class on strict chat upstreams.

  2. Agent extension ([Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 / [Bug] bili omp 扩展 stampPromptCacheKey 无条件注入顶层 prompt_cache_key —— 严格 schema 上游(opencode zen anthropic 端点)全量 400 #1403). stampPromptCacheKey stamps any messages-shaped payload whose baseUrl "routes through the proxy". On the launcher cert-MITM lane (HTTPS_PROXY + BILI_MITM_HOSTS) destinationRoutedThroughProxy() is true, but omp's Cowork transport (anthropic OAuth) sends node:https direct and ignores env proxies entirely — the stamped body reaches Anthropic verbatim and 400s (Extra inputs are not permitted, live repro: Anthropic req_011Cg7ZKRAu1VTco9UPZGZZ7). The existing [Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 withhold was nested inside if (!destinationRoutedThroughProxy(...)), so the MITM lane skipped it entirely.

Changes

  • src/session-id.ts — shouldStampRelayAffinityPck drops the rewritten-URL leg ([PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 semantics: loopback is the only destination-shape relay evidence). New exported relayAffinityDestined(upstreamOrigin) shared with the chat egress site.
  • src/server/prepare-openai.ts — client-supplied prompt_cache_key survives only on relay (loopback) destinations; stripped on all other chat egress. Body-stamp of session.id unchanged (loopback-only now).
  • src/agent/pi.ts — the [Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 Cowork withhold is hoisted above the routed-check so it gates every stamp path.
  • src/launcher.ts — omp branch fills PI_PROXY_ANTHROPIC = <proxy origin> when (and only when) neither PI_PROXY_ANTHROPIC nor PI_PROXY is user-set. This pushes Cowork onto Bun's own fetch, where the interceptor's /bili/ rewrite carries it through the proxy as plain loopback HTTP — no MITM CA involved, anthropic pck scrub applies, and the lane becomes compressed/session-visible instead of direct and invisible.

Verification

  • tests/issue2218-relay-affinity-signal.test.ts matrix flipped to [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 expectations (rewritten route → remote dest = no stamp); loopback integration cases unchanged and green.
  • tests/omp-native-identity.test.ts: new cases — MITM-lane withhold (BILI_MITM_HOSTS), HTTPS_PROXY postures, predicate matrix.
  • Targeted 26/26, tsc --noEmit clean, full suite unchanged vs master (one pre-existing env-related dsh failure reproduces identically on clean master).
  • Live: bili omp -p --model claude-sonnet-5-5 — previously a hard 400 on every delegation; now forward POST → api.anthropic.com/v1/messages, 200, pck absent from egress.

Relation to #2649

#2649 gates the proxy-side Responses stamp but explicitly keeps client-pck verbatim passthrough; this PR strips it on non-relay chat egress and additionally fixes the extension-side Cowork hole, which #2649 does not touch.

Draft bug report with repro details: kept locally during validation; happy to attach anything maintainers need.

@askl56

askl56 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

以下为同一内容的中文说明。

概述

目前 prompt_cache_key 会在两类路径上到达上游请求体:(a) 该线路的 wire 协议并未定义此字段,或 (b) bili 根本没有接管这段流量。两个相互独立的问题:

  1. Chat 线路(openai wire: prompt_cache_key stamped unconditionally — breaks strict-schema upstreams (NVIDIA NIM 400), no config escape #2645 / [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649)。 shouldStampRelayAffinityPck 在 routeRewrittenUrl !== undefined 时直接 return true。/bili/ 隧道线路会重写用户自己的远程目标地址,因此回环检查在该路径上形同虚设 —— 严格的远程 API 会收到未知请求体参数并返回 400(openai wire: prompt_cache_key stamped unconditionally — breaks strict-schema upstreams (NVIDIA NIM 400), no config escape #2645 中在 NVIDIA NIM 上的报告)。PR [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 已在 Responses 路径上把 stamp 限制为回环;本 PR 采用相同语义,并补上剩余漏洞:客户端自带的 prompt_cache_key 在 chat 线路上原样透传(prepare-openai.ts 中注释说明这是有意为之的 passthrough)—— 这在严格的 chat 上游上属于同一类 400。

  2. Agent 扩展([Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 / [Bug] bili omp 扩展 stampPromptCacheKey 无条件注入顶层 prompt_cache_key —— 严格 schema 上游(opencode zen anthropic 端点)全量 400 #1403)。 stampPromptCacheKey 会对所有 baseUrl "经由代理路由" 的 messages 形负载打标。在启动器 cert-MITM 线路(HTTPS_PROXY + BILI_MITM_HOSTS)上 destinationRoutedThroughProxy() 为 true,但 omp 的 Cowork 传输(anthropic OAuth)直接走 node:https,完全忽略环境代理 —— 打标后的请求体原样到达 Anthropic 并 400(Extra inputs are not permitted,线上复现:Anthropic req_011Cg7ZKRAu1VTco9UPZGZZ7)。既有的 [Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 withhold 被嵌套在 if (!destinationRoutedThroughProxy(...)) 内部,因此 MITM 线路完全绕过了它。

改动内容

  • src/session-id.ts —— shouldStampRelayAffinityPck 移除了重写 URL 分支([PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 语义:回环是唯一基于目标形态的中继证据)。新增导出的 relayAffinityDestined(upstreamOrigin),与 chat 出口站点共用。
  • src/server/prepare-openai.ts —— 客户端自带的 prompt_cache_key 仅在中继(回环)目标上保留;在其余所有 chat 出口上剥离。session.id 的请求体打标不变(现在仅限回环)。
  • src/agent/pi.ts —— [Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 的 Cowork withhold 上提到 routed 检查之前,使其约束所有打标路径。
  • src/launcher.ts —— omp 分支在 PI_PROXY_ANTHROPIC 与 PI_PROXY 均未被用户设置时(且仅此时)填充 PI_PROXY_ANTHROPIC = <代理 origin>。这会把 Cowork 推回 Bun 自身的 fetch,由拦截器的 /bili/ 重写以普通回环 HTTP 送入代理 —— 无需 MITM CA,anthropic 的 pck 剥离逻辑生效,该线路从"直连且不可见"变为"经过压缩、会话可见"。

验证

  • tests/issue2218-relay-affinity-signal.test.ts 矩阵翻转为 [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 语义(重写路由 → 远程目标 = 不打标);回环集成用例不变且全部通过。
  • tests/omp-native-identity.test.ts:新增用例 —— MITM 线路 withhold(BILI_MITM_HOSTS)、各种 HTTPS_PROXY 形态、谓词矩阵。
  • 定向测试 26/26,tsc --noEmit 无错误,完整测试套件与 master 持平(一个预先存在的 dsh 相关环境失败在干净 master 上同样复现)。
  • 线上验证:bili omp -p --model claude-sonnet-5-5 —— 之前每次委派必然 400;现在为 forward POST → api.anthropic.com/v1/messages,200,出站请求体中无 pck。

与 #2649 的关系

#2649 约束了代理侧的 Responses 打标,但明确保留了客户端 pck 的原样透传;本 PR 在非中继 chat 出口上将其剥离,并额外修复了 #2649 未触及的扩展侧 Cowork 漏洞。

验证期间保留在本地的 bug 报告草稿及复现细节:维护者需要的话可随时附上。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重结论:不重复,但与在途 PR #2649 同域覆盖(#3556 ⊇ #2649),需 owner 定夺合并顺序。


审核进展(方向关已过,代码关发现 6 个小问题,将直接以标注 commit 修进 PR 分支)

方向判定(独立复核,未照抄 issue):根因分析成立。我逐条验证了不变量——「stamp 当且仅当 bytes 会被 proxy 看到并消费」:

  • ompCoworkTransportBypassesFetch 的 De Morgan 改写是逻辑 no-op(仅注释增强)✓;coworkTransportPossible:true 仅 omp(src/host-profiles.ts:73)✓;
  • withhold 提升到 routed-check 之上正确:destinationRoutedThroughProxy 为 true 的 MITM 白名单路径上,Cowork 的 node:https 直连根本不看 env proxy(live req 证据),旧代码在该分支整个跳过 withhold = 泄漏点,提升后堵住 ✓;
  • launcher 填 PI_PROXY_ANTHROPIC=<origin> 的守卫正确保护用户自设值:buildPiEnv(src/launcher.ts:896-935)只 spread baseEnv、自身不设任何 PI_PROXY*,所以 env.PI_PROXY(_ANTHROPIC) 有值只可能来自用户环境 ✓;设了它 OMP 走 Bun fetch → 拦截器对一切 isModelApiUrl URL 重写为 <proxy>/bili/<url>(src/agent/native-intercept.ts:179-199)→ pck 由 proxy 消费并剥离,lane 变压缩可见 ✓。

既有行为清点(回归关):

  1. stamped session.id pck 的出站面:master = rewritten-route OR loopback → 新 = 仅 loopback([PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 既定方向,PR 已披露 ✓);
  2. client-supplied chat-wire pck:master = 恒 verbatim 透传 → 新 = 非 loopback 出站剥离(PR 已披露 ✓)。niche 风险:依赖 pck 做路由键的远端 relay 会失去该提示头(x-session-id header 仍转发)——可接受,换掉的是 strict API 400 类故障;
  3. anthropic/responses wire 不受影响(anthropic 出站本就剥 pck:src/server/prepare-anthropic.ts:509;responses 的 pck 是 schema 定义字段,保留正确)✓;
  4. 现有测试无一处钉死「非 loopback 透传」旧行为(CI 全绿即为证明;tests/openai-pck-identity.test.ts:166 等的 fake upstream 都是 loopback)→ 无意外回归。

发现的问题(将直接修,各自独立 commit):

测试有效性关:新单测有牙——MITM-lane withhold 用例(BILI_MITM_HOSTS=api.anthropic.com 断言 undefined)在旧代码下会 stamp,是真正的 bug 复现;PI_PROXY 正例(tests/omp-native-identity.test.ts:151-163)钉住不过度 withhold。缺口即 F3/F4。

diff 整洁度:6 源文件 + 2 测试文件,每行都与目的相关,干净。

配置面:不新增 bili 配置键/BILI_* 变量/CLI flag;仅向 omp 子进程 env 新增一个 OMP 原生变量 PI_PROXY_ANTHROPIC(spawn-channel 类别,用户环境同名变量优先,buildPiEnv 已设的 HTTPS_PROXY/NODE_EXTRA_CA_CERTS/BILI_MITM_HOSTS 同理先例)。

处置计划:F1–F6 作为标注 commit push 到 PR 分支 → rebase 到当前 master(base 落后但触碰文件零漂移,merge-tree 零冲突)→ 定向跑受影响测试文件 + typecheck(全量交 CI)→ 回八问结论。当前 PR head 的 CI 已全绿(test 5 shard × ubuntu/windows + 全部 static gates success)。不会合并、不会关闭 #2649。

askl56 and others added 5 commits October 17, 2026 20:44
…ant prompt_cache_key on every egress lane

- session-id: drop the route-rewritten leg of shouldStampRelayAffinityPck
  (ranxianglei#2649: a rewritten/embedded URL is not relay evidence — the /bili/ tunnel
  rewrites the user's own remote destination too); loopback is the only
  destination-shape proof. Export relayAffinityDestined for the egress site.
- prepare-openai: chat wire no longer passes a client prompt_cache_key
  through verbatim to non-relay upstreams — strict APIs 400 unknown body
  params (ranxianglei#2645). Client value still wins on loopback relay destinations.
- pi (stampPromptCacheKey): hoist the ranxianglei#2583 Cowork withhold above the
  routed-check so it gates ALL stamp paths. Pre-hoist, the launcher
  cert-MITM lane (BILI_MITM_HOSTS) made destinationRoutedThroughProxy()
  true and skipped the withhold entirely — stamped bodies reached
  Anthropic's strict schema verbatim (ranxianglei#1403 400s).
- pi (ompCoworkTransportBypassesFetch): a LOOPBACK HTTPS_PROXY is bili
  itself and Cowork's node:https honors it — treat as routing evidence
  (stamp); a foreign/non-loopback HTTPS_PROXY is a bypass (withhold).

Tests: flip ranxianglei#2649 matrix row; 4 new cases (MITM withhold, loopback
HTTPS_PROXY stamp, foreign HTTPS_PROXY withhold, predicate matrix).
…PROXY_ANTHROPIC)

The ranxianglei#2583 withhold (hoisted earlier in this branch) correctly stops the
identity stamp from leaking, but Cowork traffic still left the host
direct — uncompressed and invisible to the proxy — because omp's Cowork
transport sends node:https and ignores HTTPS_PROXY entirely (proven live,
Anthropic req_011Cg7cujfgv4xLjuRvLMqvg).

PI_PROXY_ANTHROPIC pushes Cowork onto Bun's own fetch, where the
interceptor's /bili/ rewrite carries it through the proxy as plain
loopback HTTP (no MITM CA involved). Verified live: forward POST →
api.anthropic.com/v1/messages, session-visible, 200, pck scrubbed.

Also reverts the loopback-HTTPS_PROXY clause in
ompCoworkTransportBypassesFetch (same live proof: not routing evidence
for this transport) and flips its tests to the proven posture.
… doc placement; add ranxianglei#2645/ranxianglei#3556 remote-destination pck regressions

Review of ranxianglei#3556: this PR already dropped the rewritten-URL leg of shouldStampRelayAffinityPck, which left the third parameter dead and the full-gate JSDoc stranded above relayAffinityDestined. Aligns the signature with ranxianglei#2649's 3-arg form and moves the doc back onto the function it describes.

Also ports the ranxianglei#2649 strict-remote regression (mock upstream that 400s on prompt_cache_key, bound to a non-loopback IPv4 so bili sees a REMOTE destination) and adds the missing regression for the new client-pck strip: verbatim client prompt_cache_key must not reach non-relay chat egress (plain-client and dsh plugin lanes), while x-session-id identity survives.
… guard

Review nit on ranxianglei#3556: OMP's getProxyForProvider treats an empty-string PI_PROXY_ANTHROPIC and a whitespace-only PI_PROXY as unset, but the === undefined guard counted them as user-set, leaving Cowork on node:https direct (the stamped-body 400 class this PR exists to kill). The guard now mirrors the src/agent/pi.ts predicate exactly.
…anxianglei#3556)

README en/zh caveat paragraph, TECHNICAL-NOTES en/zh paragraph (heading omp native -> omp; launcher completion sentence; cert-MITM hoist), CONFIGURATION en/zh (client-table omp row + env appendix PI_PROXY_ANTHROPIC row): the default bili omp launcher lane now routes Cowork through the proxy via PI_PROXY_ANTHROPIC; direct-and-anonymous remains only for native mode and user-pinned proxy postures.
@ranxianglei
ranxianglei force-pushed the fork/pck-wire-conformance branch from 1a6777b to 36e073e Compare October 17, 2026 12:45
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

审核结论(第二轮:修复已推送到分支)

首轮列的 F1–F6 已全部以独立标注 commit 修好并推到 fork/pck-wire-conformance(rebase 到当前 master b10c52576,零冲突):

  • eb6f4174a refactor(session-id):删掉死参数 routeRewrittenUrl(签名对齐 [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 的 3 参形态)、把整段 gate JSDoc 移回 shouldStampRelayAffinityPck;移植 [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 的严格远端回归(mock 上游对 pck 回 400、绑非环回 IPv4)+ 新增客户端自带 pck 在非 relay 出口被剥离的回归(plain-client 与 dsh lane 两个子例)。
  • 0d185808b fix(launcher):PI_PROXY_ANTHROPIC 填充守卫改用与 src/agent/pi.ts 谓词完全一致的 OMP truthiness(空串 PI_PROXY_ANTHROPIC / 纯空白 PI_PROXY 视为未设置,否则该姿态下 Cowork 仍直发、打戳 400 复现)。
  • 36e073ec2 docs:README / TECHNICAL-NOTES / CONFIGURATION 中英同步 —— omp caveat 改为「默认 launcher lane 经 PI_PROXY_ANTHROPIC 走代理(可压缩、会话可见);直连匿名只保留在 native omp 模式与用户自钉代理姿态」。

验证:本地定向测试 28/28(issue2218 8/8 含两个新回归、omp-native-identity 20/20)、tsc --noEmit 干净(rebased head);CI 静态门禁全绿,test 分片运行中。审核中新增的必要注释仅一处(dsh 子例断言处,说明会话头优先于 body pck —— 防止误读断言值)。

结构化八问

  1. 是什么问题:部分出口通道上 prompt_cache_key 到达了不认识该字段的严格上游 schema → 硬 400;另有一类流量(OMP Cowork 的 anthropic 请求)完全绕过代理,既无压缩也无身份。两个独立机制。
  2. 什么原因导致的:(a) chat wire 把「URL 被改写」当作 relay 证据,但 /bili/ 隧道会改写任何远端目的地 —— 决定 pck 是否合法的是目的地形状,不是改写事实;客户端自带的 pck 被文档化为逐字透传、出口无任何闸门。(b) [Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 的 withhold 嵌套在 if (!destinationRoutedThroughProxy(...)) 内 —— MITM lane 按该谓词算「已路由」,但 Cowork 用 node:https 直发、无视 env 代理,打戳后的 body 原样到达 Anthropic。
  3. 影响范围与严重程度:特定条件下硬失败,非全局坏。(a) 通过 /bili/ 隧道访问自己远端 API 的 chat 用户(如 dsh plugin lane → NVIDIA NIM,openai wire: prompt_cache_key stamped unconditionally — breaks strict-schema upstreams (NVIDIA NIM 400), no config escape #2645 实锤 400);(b) bili omp 默认 Anthropic 模型的每次委派都 400(作者实锤 req_011Cg7ZKRAu1VTco9UPZGZZ7),且该流量对代理不可见、不压缩。
  4. 怎么修复的:闸门移到正确的决策点 —— 只有环回(代理自己拥有字节)才算 relay 证据;其余 chat 出口剥离客户端 pck。withhold 提升到 routed 检查之上,门控所有打戳路径。launcher 在用户未设代理姿态时导出 PI_PROXY_ANTHROPIC=<proxy>,把 Cowork 推回 Bun fetch → /bili/ 改写 → 正常压缩通道。疏而非堵:改的是「何处判定/何处路由」,不是在传输层过滤字节。
  5. 是否有回归问题:逐项过过既有行为 —— 环回打戳不变(既有集成用例绿);Responses wire 保留 pck(schema 定义字段,prepare-responses.ts)不动;anthropic wire scrub([Bug] bili omp 扩展 stampPromptCacheKey 无条件注入顶层 prompt_cache_key —— 严格 schema 上游(opencode zen anthropic 端点)全量 400 #1403,route-passthrough.test.ts 钉住)不动;x-session-id 头转发完好;openai-pck-identity 环回转发用例仍绿。未发现无意回归。
  6. 是否破坏缓存:不涉及 bili 内部缓存/重试/增量游标/去重键。上游侧效应即下面披露的行为变更本身。
  7. 是否改了设计方向:没有架构转向 —— 同一套「单一写者、源头打戳」纪律,只是判定从错误信号(改写事实)换到正确信号(目的地形状);launcher 补全走既有 env 注入档。
  8. 是否引入了新的配置:无用户侧新配置。launcher 向子进程导出 PI_PROXY_ANTHROPIC(已入 CONFIGURATION.md 中英;用户自设值永远优先),无新 BILI_*、无配置文件字段。

行为变更披露(旧值 → 新值 + 原因)

  • chat wire 打戳 pck:master = 「URL 被改写 OR 环回」即打 → 新 = 仅环回。原因:改写不是 relay 所有权证据(/bili/ 隧道改写任意远端),严格远端 API 对未知参数直接 400([PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649 同方向)。
  • 客户端自带 chat wire pck:master = 永远逐字透传 → 新 = 非环回出口剥离。原因同上。边缘风险:若你有依赖客户端 pck 做路由键的远端 relay,经 bili 后该提示丢失(x-session-id 头仍转发)——此类用法请在 issue 里反馈,评估加白名单。
  • bili omp 默认 launcher lane 的 Cowork anthropic 流量:master = 直发(不压缩、对代理匿名)→ 新 = 经代理(可压缩、会话可见,pck 由代理消费并剥离)。原因:恢复可用性+可见性;想保留旧行为的用户显式设置 PI_PROXY / PI_PROXY_ANTHROPIC 即可(守卫不覆盖用户值)。

判定

可合(等 CI test 分片转绿即可合入)。另请 owner 拍板:#2649 与本 PR 同函数互斥形态、本 PR ⊇ 其范围且已吸收其 e2e 回归 —— 建议合并本 PR 后将 #2649 关为 superseded(关闭动作由你执行或明确授权)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI 全绿确认:head 36e073ec2 上 30/30 check runs 完成、零失败(静态门禁 + ubuntu/windows × node22/24 test 分片),与 master 无冲突。PR 处于可合状态(合并动作按仓库规则由人工执行)。

待 owner 拍板的仍只有那一项:合并本 PR 后是否将 #2649 关为 superseded(本 PR 已吸收其 e2e 回归)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

收到同步的 PR 描述(与已审核内容一致,无新增信息)。状态不变:head 36e073ec2(含审核补充的 3 个标注 commit)CI 30/30 全绿、与 master 无冲突、可合。待办仅剩 owner 拍板:合并后是否将 #2649 关为 superseded(本 PR 已吸收其 e2e 回归)。

@askl56

askl56 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Verified the review commits locally on the PR head (36e073ec2, rebased on v0.1.198): targeted suites 28/28 (issue2218 8/8 incl. the ported strict-remote and client-pck-strip regressions, omp-native-identity 20/20), tsc --noEmit clean, full build green. Rebuilt our production install from this exact head and re-ran the live repro lane — bili omp -p --model claude-sonnet-5-5 forwards through the proxy to api.anthropic.com/v1/messages, 200, no prompt_cache_key in egress. F1–F6 all look right, including the truthiness fix (F6) — good catch on the empty-string posture.

No objection from our side to closing #2649 as superseded once this merges; this PR absorbed its e2e regression. Thanks for the thorough review.

已在本地验证 PR head(28/28、tsc 干净),并已将该 head 构建为我们线上在跑的安装;#2649 按 superseded 关闭我们无异议。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

感谢独立验证 —— 线上安装从 36e073ec2 重建后实跑复现通过(200、出站无 pck),这是最硬的证据。你的无异议已记录;#2649 的 superseded 关闭按流程等 owner 最终确认后执行(合并本 PR 时一并处理)。当前状态:可合,无阻塞。

@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zhipuai-lb/glm-5.3)

谢谢!这个 PR 里真正有效的部分已被 cherry-pick 进替代 PR #3736 ,原作者与提交信息用 -x 尾注保留:

原提交 去向
ddc4d0ab(pi-lane stamp-withhold 上提 + loopback-HTTPS_PROXY 判定 + omp-native-identity 测试) → 54f1b964,部分采用(它的 session-id 改写和 prepare-openai 静态剥 client key 两条腿被 probe-and-remember 设计取代)
925e6e65(launcher PI_PROXY_ANTHROPIC 填充 + Cowork node:https 完全忽略 env 代理的线上实测 req_011Cg7cujfgv4xLjuRvLMqvg) → a8c4c606,整体采用——那次实测直接成为「HTTPS_PROXY 存在不等于流量走代理」这条判据的依据,很关键
0d185808(空串/纯空白 proxy 变量视为未设) → dd401a68,整体采用
36e073ec(README/CONFIGURATION 中英 + TECHNICAL-NOTES caveat 文档同步) → b0980718,整体采用
eb6f4174(dead-param 重构 + 「远端目的地永不盖键」回归矩阵) 未整体采用:参数重构已被新的 resolveRelayAffinityPck 覆盖;而「远端不发键」断言与最终定案的设计相反(定案=默认全发,只有被上游实证拒收才停,且仅内存记忆)

两条 PR 先保持原状,#3736 合并后再决定是否一并关闭(关闭动作留给 owner)。@askl56 你线上那次 Cowork 验证帮了大忙。

@ranxianglei ranxianglei changed the title fix(#2645/#2649/#2583): wire-conformant prompt_cache_key on every egress lane + Cowork lane routing [PR] fix(#2645/#2649/#2583): wire-conformant prompt_cache_key on every egress lane + Cowork lane routing Oct 18, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

收到,cherry-pick 映射清楚,无异议。#3556 / #2649 按指示保持原状不动。

两点备查,供 #3736 合并后的收尾用:

  1. 关闭说明可直接引用本线程的查重结论:[PR] fix(#2645/#2649/#2583): wire-conformant prompt_cache_key on every egress lane + Cowork lane routing #3556 ⊇ [PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations #2649(同函数互斥形态),两者均被 [PR] fix(#2645): probe-and-remember prompt_cache_key — stamp by default, self-heal strict upstreams #3736 的 probe-and-remember 设计取代 ——「远端默认发键、被上游实证拒收才停(仅内存记忆)」与 [PR] fix(#2645/#2649/#2583): wire-conformant prompt_cache_key on every egress lane + Cowork lane routing #3556 的「非环回静态剥离」是相反定案,以 [PR] fix(#2645): probe-and-remember prompt_cache_key — stamp by default, self-heal strict upstreams #3736 为准。
  2. 证据链已随 a8c4c606 保留:@askl56 的 Cowork 直连实测(req_011Cg7cujfgv4xLjuRvLMqvg)与 Anthropic 严格 schema 400(req_011Cg7ZKRAu1VTco9UPZGZZ7)。

需要的话我可以在 #3736 合并后起草两条 superseded 关闭说明(带来源标记),由你执行或授权。

@ranxianglei

Copy link
Copy Markdown
Owner

see #3736 一个自愈的并兼容所有场景的方案

LoveDoLove pushed a commit to LoveDoLove-Forked-Projects/billion-context that referenced this pull request Oct 19, 2026
…ache_key stamp on un-consumable transports

Adopted from ranxianglei#3556 (ddc4d0a) — the pi.ts + omp test half. The commit's
session-id/prepare-openai/issue2218 changes are NOT adopted: this branch's
first commit replaces that destination-shape gate with A/B-verified
probe-and-remember instead of static stripping (ranxianglei#2649's loopback-only gate
was vetoed — it cost the two biggest relay/account-pool populations their
prefix-cache affinity).

- pi (stampPromptCacheKey): hoist the ranxianglei#2583 Cowork withhold above the
  routed-check so it gates ALL stamp paths. Pre-hoist, the launcher
  cert-MITM lane (BILI_MITM_HOSTS) made destinationRoutedThroughProxy()
  true and skipped the withhold entirely — stamped bodies reached
  Anthropic's strict schema verbatim (ranxianglei#1403 400s).
- pi (ompCoworkTransportBypassesFetch): a LOOPBACK HTTPS_PROXY is bili
  itself and Cowork's node:https honors it — treat as routing evidence
  (stamp); a foreign/non-loopback HTTPS_PROXY is a bypass (withhold).

Tests: 4 new cases in omp-native-identity (MITM withhold, loopback
HTTPS_PROXY stamp, foreign HTTPS_PROXY withhold, predicate matrix).

(cherry picked from commit ddc4d0a)
LoveDoLove pushed a commit to LoveDoLove-Forked-Projects/billion-context that referenced this pull request Oct 19, 2026
… guard

Review nit on ranxianglei#3556: OMP's getProxyForProvider treats an empty-string PI_PROXY_ANTHROPIC and a whitespace-only PI_PROXY as unset, but the === undefined guard counted them as user-set, leaving Cowork on node:https direct (the stamped-body 400 class this PR exists to kill). The guard now mirrors the src/agent/pi.ts predicate exactly.

(cherry picked from commit 0d18580)
LoveDoLove pushed a commit to LoveDoLove-Forked-Projects/billion-context that referenced this pull request Oct 19, 2026
…anxianglei#3556)

README en/zh caveat paragraph, TECHNICAL-NOTES en/zh paragraph (heading omp native -> omp; launcher completion sentence; cert-MITM hoist), CONFIGURATION en/zh (client-table omp row + env appendix PI_PROXY_ANTHROPIC row): the default bili omp launcher lane now routes Cowork through the proxy via PI_PROXY_ANTHROPIC; direct-and-anonymous remains only for native mode and user-pinned proxy postures.

(cherry picked from commit 36e073e)
LoveDoLove pushed a commit to LoveDoLove-Forked-Projects/billion-context that referenced this pull request Oct 19, 2026
@github-actions github-actions Bot mentioned this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants