Repository navigation
[PR] fix(#2645): gate the openai prompt_cache_key stamp to loopback destinations - #2649
ranxianglei wants to merge 1 commit into
Conversation
…ations shouldStampRelayAffinityPck short-circuited to true whenever a URL was embedded/rewritten. The /bili/ tunnel and forward-proxy lanes set route.rewrittenUrl for the user's own REMOTE destination too, so the dsh plugin lane stamped prompt_cache_key onto strict-schema remote APIs (NVIDIA NIM answers 400) and broke every turn. rewrittenUrl always co-references route.upstream, so the destination origin is the only trustworthy signal: drop the short-circuit and gate purely on the destination being loopback. Local relays (every #2218 scenario) keep the stamp; remote strict APIs stop getting it. No config surface added.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2863-pr.2649.575f316This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2649.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #2649 Review 结论(结构化八问) 1. 是什么问题:openai chat/completions 线上,proxy 替 dsh 插件道往每个出站请求体里盖 2. 什么原因导致的: 3. 影响范围与严重程度:所有走 URL 嵌入 lane 的插件道 openai 请求 × 严格 schema 远端上游——完全无法使用(每轮 400)。触发条件明确:dsh 桌面/插件道 + 远端模型端点(经隧道或代理 env 到达)。本地 relay 部署不受影响。 4. 怎么修复的:删掉短路腿和第三个参数,gate 纯看目的地 origin 是否 loopback。这是机制级修复(疏而非堵):不改写载荷、不做 host 特判、不做 400 自愈(issue 里方案 4 是治标,方案 3 打的是另一个机制;本方案是方案 2 的更严格版本,且不新增配置面)。 5. 是否有回归问题:
6. 是否破坏缓存:loopback relay 路径字节级不变,前缀缓存策略无影响。远端严格 API 从「每轮 400(无任何缓存可言)」变为正常 200。唯一的亲和损失见第 5 条有意变更项,属设计态恢复而非破坏。 7. 是否改了设计方向:不涉及架构转向;是把 openai 线的盖章语义收敛到其本来的定义域(loopback 本地 relay)。若未来需要强制给特定远端 relay 盖章,按 Configuration Surface Discipline 走 owner-gated 提案,本 PR 正确地没有自建配置面。 8. 是否引入了新的配置:不涉及。零新 env/config/默认值。 验证证据(非转述作者声明,均独立执行):
判定:可合并。 方向对、根因准、测试真、CI 绿、行为变更已披露。请人工合并:#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).
… 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.
|
为什么本地就删除这个key 号池子就是本地 没有这个就遭殃 |
[bot] 🏷 先纠正一个关键误解:本 PR 没有删本地目的地的盖章。判定看的是请求最终目的地 origin 是否 loopback( 你的号池会不会受影响,取决于一个具体事实:不是号池部署在哪台机器,而是 dsh 侧指向号池时写的地址串是什么(判定用的就是这个串的 origin):
请给一行事实:dsh 侧配的上游地址里,号池写的是什么?( 如果已经是
八问(决策请求版)
收工判定:等你一行地址事实。 |
|
(ai: zhipuai-lb/glm-5.3) 此 PR 被替代:#3736 (superseded) 原因:静态门槛「非本地目的地一律不发」分不开两个群体——部署在 docker 桥 IP / 局域网 / VPS / 域名上的中转和号池同样靠 本分支没有代码行被沿用(静态判断逻辑整体被实证门取代),是否关闭由 owner 定。 |
[bot] 🏷 收到替代决定,事实已核:PR #3736 存在且 open(mergeable=True,分支 同时纠正我此前 review 记录里的一处低估(对替代决定是加强而非削弱):我重新核对了 #2649 基座( 八问(收工版)
收工判定:建议以 superseded 关闭 #2649(按你的措辞,关闭操作留给你)。两件可交接给 #3736 线程的东西:①我为红绿证明写的严格 mock upstream(NVIDIA 400 报错逐字对齐)+ 隧道 lane e2e 夹具(tests/issue2218-relay-affinity-signal.test.ts)可直接复用;②上面「基座 gate 事实行为=全发」的核对结论,可作其 review 背景——它说的 "restores master behavior" 字面上就是对的,因为全发正是 master 的事实行为。 |
|
[bot] 🏷 Superseded by #3736 — the static loopback/non-local gate does not separate the two large pool populations (local/docker/LAN/VPS/domain relays all need the key; strict APIs reject it), so the fix moves to adaptive learn-from-400 in #3736. Closing this PR; no part of it is carried forward. See #2645. |
…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)
CONFIGURATION en/zh: default column and section rewritten for the disabled default, both-wires semantics, client-key rule, entry points. TECHNICAL-NOTES en/zh: policy-reversal section superseding #2649's default-on ruling. CHANGELOG: Unreleased entry with the old->new behavior disclosure.
CONFIGURATION en/zh: default column and section rewritten for the disabled default, both-wires semantics, client-key rule, entry points. TECHNICAL-NOTES en/zh: policy-reversal section superseding #2649's default-on ruling. CHANGELOG: Unreleased entry with the old->new behavior disclosure.
CONFIGURATION en/zh: default column and section rewritten for the disabled default, both-wires semantics, client-key rule, entry points. TECHNICAL-NOTES en/zh: policy-reversal section superseding #2649's default-on ruling. CHANGELOG: Unreleased entry with the old->new behavior disclosure.
Closes #2645
What / why
On the
openai(chat/completions) wire,prompt_cache_keywas stamped onto every outbound dsh plugin-lane request — including strict-schema remote upstreams that reject unknown params. NVIDIA NIM answers400 Validation: Unsupported parameter(s): prompt_cache_key, so every turn on those models failed in <1s, with no config escape.Root cause
shouldStampRelayAffinityPck(src/session-id.ts) short-circuitedreturn truewhenever a URL had been embedded/rewritten (routeRewrittenUrl !== undefined). The/bili/<proto>/<abs-url>tunnel lane and the forward-proxy lane setroute.rewrittenUrlfor the user's own remote destination too (NVIDIA NIM here), so the gate stamped a strict remote API on every turn. The loopback check underneath was dead for the tunnel lane. This regressed #2218's stated intent ("unrouted non-loopback forwards stay unstamped"): its "admin-rewritten route" leg conflated a URL was embedded with a deliberate local relay.Fix
Since
route.rewrittenUrlalways co-referencesroute.upstream, the destination origin is the only trustworthy signal. Drop the short-circuit and gate purely on the destination being loopback:prompt_cache_keystill always wins (unchanged).No new config surface added (per Configuration Surface Discipline). If an admin ever needs to force-stamp a specific remote relay, that's a separate owner-gated proposal.
Tests
#2218/#2645 unit: shouldStampRelayAffinityPck gate matrix— pins loopback→stamp,localhost→stamp, remote (incl. a full tunnel-style URL with path)→no-stamp, client-pck-wins, non-plugin→no-stamp, unparseable→no-stamp.prompt_cache_key) reached from the dsh plugin lane through the machine's non-loopback address → asserts 200 + no stamped field +x-session-idheader relay still intact. Skips gracefully if the environment has no non-loopback IPv4.Verified locally: typecheck clean, targeted suites green (
tests/issue2218-relay-affinity-signal.test.ts7/7, plus openai/anthropic pck-identity + route-passthrough + codex-official 17/17), full build OK.