Repository navigation
Conversation
|
以下为同一内容的中文说明。 概述目前
改动内容
验证
与 #2649 的关系#2649 约束了代理侧的 Responses 打标,但明确保留了客户端 pck 的原样透传;本 PR 在非中继 chat 出口上将其剥离,并额外修复了 #2649 未触及的扩展侧 Cowork 漏洞。 验证期间保留在本地的 bug 报告草稿及复现细节:维护者需要的话可随时附上。 |
(ai: vllm-qwen/qwen3.8-27b) 查重结论:不重复,但与在途 PR #2649 同域覆盖(#3556 ⊇ #2649),需 owner 定夺合并顺序。
审核进展(方向关已过,代码关发现 6 个小问题,将直接以标注 commit 修进 PR 分支)方向判定(独立复核,未照抄 issue):根因分析成立。我逐条验证了不变量——「stamp 当且仅当 bytes 会被 proxy 看到并消费」:
既有行为清点(回归关):
发现的问题(将直接修,各自独立 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 原生变量 处置计划:F1–F6 作为标注 commit push 到 PR 分支 → rebase 到当前 master(base 落后但触碰文件零漂移,merge-tree 零冲突)→ 定向跑受影响测试文件 + typecheck(全量交 CI)→ 回八问结论。当前 PR head 的 CI 已全绿(test 5 shard × ubuntu/windows + 全部 static gates success)。不会合并、不会关闭 #2649。 |
…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.
1a6777b to
36e073e
Compare
(ai: vllm-qwen/qwen3.8-27b) 审核结论(第二轮:修复已推送到分支)首轮列的 F1–F6 已全部以独立标注 commit 修好并推到
验证:本地定向测试 28/28(issue2218 8/8 含两个新回归、omp-native-identity 20/20)、 结构化八问
行为变更披露(旧值 → 新值 + 原因)
判定可合(等 CI test 分片转绿即可合入)。另请 owner 拍板:#2649 与本 PR 同函数互斥形态、本 PR ⊇ 其范围且已吸收其 e2e 回归 —— 建议合并本 PR 后将 #2649 关为 superseded(关闭动作由你执行或明确授权)。 |
|
Verified the review commits locally on the PR head ( 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 关闭我们无异议。 |
|
(ai: zhipuai-lb/glm-5.3) 谢谢!这个 PR 里真正有效的部分已被 cherry-pick 进替代 PR #3736 ,原作者与提交信息用
两条 PR 先保持原状,#3736 合并后再决定是否一并关闭(关闭动作留给 owner)。@askl56 你线上那次 Cowork 验证帮了大忙。 |
(ai: vllm-qwen/qwen3.8-27b) 收到,cherry-pick 映射清楚,无异议。#3556 / #2649 按指示保持原状不动。 两点备查,供 #3736 合并后的收尾用:
需要的话我可以在 #3736 合并后起草两条 superseded 关闭说明(带来源标记),由你执行或授权。 |
|
see #3736 一个自愈的并兼容所有场景的方案 |
…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)
… 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)
…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)
…y-default + A/B probe-and-remember (ranxianglei#2218/ranxianglei#2645/ranxianglei#3556)
Summary
prompt_cache_keycurrently 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: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).
shouldStampRelayAffinityPckshort-circuitsreturn truewheneverrouteRewrittenUrl !== 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-suppliedprompt_cache_keypassed through verbatim on the chat wire (prepare-openai.tsdocuments it as deliberate passthrough) — the same 400 class on strict chat upstreams.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).
stampPromptCacheKeystamps 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) sendsnode:httpsdirect and ignores env proxies entirely — the stamped body reaches Anthropic verbatim and 400s (Extra inputs are not permitted, live repro: Anthropicreq_011Cg7ZKRAu1VTco9UPZGZZ7). The existing [Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583 withhold was nested insideif (!destinationRoutedThroughProxy(...)), so the MITM lane skipped it entirely.Changes
src/session-id.ts—shouldStampRelayAffinityPckdrops 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 exportedrelayAffinityDestined(upstreamOrigin)shared with the chat egress site.src/server/prepare-openai.ts— client-suppliedprompt_cache_keysurvives only on relay (loopback) destinations; stripped on all other chat egress. Body-stamp ofsession.idunchanged (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 fillsPI_PROXY_ANTHROPIC = <proxy origin>when (and only when) neitherPI_PROXY_ANTHROPICnorPI_PROXYis 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.tsmatrix 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.tsc --noEmitclean, full suite unchanged vs master (one pre-existing env-related dsh failure reproduces identically on clean master).bili omp -p --model claude-sonnet-5-5— previously a hard 400 on every delegation; nowforward 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.