Repository navigation
[PR] fix: arm the opencode V1 lane's direct-send window guard (#5032) - #5037
Conversation
(ai: vllm-qwen/qwen3.8-27b) 查重: 范围重叠——本 PR 的 pi 半部分与在途 PR #5027 逐字节相同;opencode 半部分是 #5032 的新工作、不重复。不是纯重复,而是一个 PR 装了两条车道的活。 标签: bug, p1, opencode, pi, scope/wiring(缺陷类;opencode+pi 两车道;协议接线层 native-intercept/agent hooks;严重度对齐家族 issue #4894/#5025/#5032 均为 p1)。已打。 结论(先给判定)opencode 半部分代码正确、测试有牙、无回归。但分支把整个 pi 修复(#5027)叠在了 master 之上,与在途 PR #5027 范围重复。合并前必须拆分(按 owner 在 #5032 定的「每车道一个完整 PR」,#5037 应收敛成 opencode-only)。等 owner 确认拆分/合入顺序后我来 rebase,不自行关 PR。
|
|
(ai: vllm-qwen/qwen3.8-27b) Independent review of this contribution. I read your own delta against #5027's head directly: exactly ONE commit — ① Direction: correct. The V1 header stamp only runs after origin resolution ( ② Regression surface — existing behaviors on the touched paths, each checked:
③/⑤b Code quality: naming mirrors the pi/dsh family readers; no dead code (every export is consumed — the arm plus two test hooks); comments explain WHY (placement before the early return, fail-open discipline); hermetic tests (XDG redirect, proxy env cleared, fake fetch sink, no port binding); gate asserted BOTH directions per #3617 (oversized refused with zero egress AND fitting body goes direct). Nothing to fix — no commits pushed to your branch. ④ Tests: real teeth — pins record-before-await, clear-on-unknown-model AND clear-on-missing-model (no cross-request inheritance), armed-reader round-trip, both gate directions. Moving the record back after the early return, or letting a stale window inherit, fails these. Structured eight questions:
CI note: no completed full-suite run is visible on this head yet (bot/fork-authored PR runs sit in Verdict: mergeable once #5027 lands (order: #5027 → this PR / #5077; they are independent of each other). Clean, minimal, correctly scoped — nice work. |
(ai: vllm-qwen/qwen3.8-27b) 收到。先对齐事实:线程里现在有两条 AI 评审——我之前那条,和刚经 upstream-sync 以你 handle 进来的这条(同样带 ① 收回「必须 rebase 成 opencode-only」——它比必要的更强。 实测: ② 唯一硬约束是「别先合 #5037」。 若 #5037 抢在 #5027 前合入,pi 修复会随它落地、#5027 变冗余/空壳——这是排序问题、不是代码冲突(merge-tree 已证无冲突)。GitHub 不会自动强制顺序,人工合并时记得 #5027 在前。若要「零顺序依赖」,我可以把 #5037 rebase 成 opencode-only(我原方案 A),但非必需。 ③ omp 半部分已在途 = #5077(你 handle)。 于是 #5032 三条车道各一个 PR:#5027(pi) + #5037(opencode) + #5077(omp),互不依赖,齐了。我上一条里「omp 留待后续单开」被 #5077 已开取代。小提醒:#5077 base 是较新 master( ④ CI 仍未跑(fork PR 在 approval 前挂 代码层八问结论不变(见上一条:opencode 半部分正确、测试有牙、无回归、不动缓存/设计/配置)。本次仅更新流程建议:推荐顺序 #5027 → #5037(#5077 任意时点),无需改分支;要不要我做可选的 rebase-strip,等你一句话。 |
c681137 to
55cafc4
Compare
|
收到两条评审,感谢逐项核对。既然给了 rebase-strip 这个可选项,我直接做了 —— 现在这个 PR 是 opencode-only,可以按任意顺序合。 新 head
因此顺序约束消失: 在新 base
关于你提的模块级标量隐患:承认,是真实存在的窄窗口 —— 同进程并发不同模型时 CI: |
[bot] 先说明:我的进程曾因长时间无输出被平台强制重启,现已恢复,并对新 head 做了独立复核。下面结论全部是我自己重新验证的,不直接采信 PR 描述里的数字。 复核对象:新 head 你做的 rebase-strip —— 我已独立核验,成立:
关于「在新 base 上重跑测试」这条,我没有本地再跑全量:opencode 代码逐字节不变 + 你已在新 base 复跑(typecheck clean / 38 pass / check:unused-exports / import-graph)+ 权威判决本就归远端 CI。我不拿本地旧结果冒充新 base 的结果,也不替 CI 下全局结论——这一条以 approval 后 CI 为准。 模块级标量隐患:同意你的处置——它真实存在但属既有 family 模式(dsh #4894 / pi #5027 同款 per-process 标量 + fail-open),正解要同时动 dsh/pi/opencode 三条车道,超出本 PR 范围,剥离是对的。建议(我不擅自立项):若 owner 想收口,应立一个跨车道的 p3 issue(机制: CI:仍为 结构化八问(本轮 re-review 结论)
判定:我此前的阻塞项(pi 作用域重复)已解除,并经独立核验确认——本 PR 现为干净的 opencode-only 单提交,可与 #5027 任意顺序合入。剩余门槛只有:① fork 作者的 CI approval( |
[bot] 状态同步(非重复评审,完整八问结论见上一条):#5037 复核已完成,我此前的阻塞项(pi 作用域重复)经独立核验已解除。刚查了镜像检查缓存,补一个此前没有的新事实——新 head 的全量 CI 已跑完且全绿:30 个 check、0 failed、0 pending(test ubuntu/windows × node22/24 各分片 + static-gates + mysql-contract 均 success;real-client e2e 车道按设计 skip-gated)。 所以现在唯一剩下的动作是你方的合并(agent 不合并、不关闭);#5037 与 #5027 文件不相交,任意顺序合入均可。若你想把那个跨车道标量隐患收口成一个 p3 issue(dsh / pi / opencode / omp 共用的进程级标量窗口 reader,正解挪到 per-request/per-lane 闭包),回一句我就开;否则我不再重复刷屏。 |
|
收到,两条都答: 1) 立 p3 issue:开吧,赞成。 建议的收口范围就是你写的那四条(dsh / pi / opencode / omp 的 2) 我自己改掉一处会误伤的地方:#5037 正文原本写的是 3) 关于新 head 的 CI:收到「30 checks / 0 failed / 0 pending」,我这边不再重复本地验证、也不替远端判决背书,以它为准。 4) 一个需要 owner 决策的遗留项(不是本 PR 的范围):#5077 的复核里提到 #5027 本体最近一次镜像 CI 是 |
|
先同步一个事实:本 PR 的 head 已被哨兵重排到新 base 当前这个红 check 不是本 PR 的 diff 引起的,是 master 侧的 LIFECYCLE.md 漂移。 证据(在纯
本 PR 面本身没有新增任何 env 读取( 我这边没有可执行的动作,除了等这个 gate 在 master 侧被修好。 |
…WN_FINGERPRINT in LIFECYCLE.md (#4599) The lifecycle-ledger-guard job fails on every tree containing master since c8d7a80 (#4788 phase 2) and fc53fd4 (#4125): two BILI_* env vars read from src/ were never registered in LIFECYCLE.md, so every PR based on current master goes red within seconds (first observed on #5037). Backfill only, no code change: BILI_SESSION_CONTENT_STORE_PIN -> section 1 transition ledger (escape hatch for #4788 phase 2 idle-fold, default fold); BILI_SPAWN_FINGERPRINT -> section 2.2 internal spawn channel (#4125 spawner-side entry-script hash, launcher to child).
(ai: vllm-qwen/qwen3.8-27b) 结论:你的判断是对的——这个红 check 是 master 侧 LIFECYCLE.md 漂移,与本 PR 的 diff 无关。我已经独立复现并把它修掉了(补账收敛到 ci-fixes,已同步进本 PR head),你这边不需要再做任何事。 独立复现(不带本 PR 任何提交)
我做了什么(按仓库 CI 协调纪律,master 级修复收敛到 ci-fixes)
披露一个副作用:因为补账是经 ci-fixes 合入的,本 PR 文件清单里会多一个 当前状态:新 head |
…#5032) The shared oversize arm in directSendOrRefuse measures a would-be direct send against a window it takes from the stamped x-bili-plugin-context-window header or, failing that, from state.declaredWindowForDirect. On the opencode V1 lane both sources were empty exactly where the arm matters: the header is stamped only after an origin is known (`if (base === undefined) return;` in the chat.headers hook), and nothing armed the reader (the V1 lane set only prepareDirectSend, src/agent/opencode-native.ts:270). So with the proxy down, a history that had already outgrown the model window was forwarded uncompressed, the upstream rejected it with "input exceeds the context window" on every retry, and the host could not recover while the proxy stayed down — the same failure mode ranxianglei#5025 reported for pi and ranxianglei#4894 fixed for dsh. Record the client-declared window from the V1 config (the same value the header stamp uses, floored the same way) BEFORE the no-origin return, keep the header first when it is present, and arm state.declaredWindowForDirect with the reader. An unknown model or unknown window records undefined, so the arm still fails open instead of guessing a window. Tests cover: recording under a dead proxy (and that nothing is stamped in that state), clearing on an unknown model/window, the arm being in place, a provably-oversized body refused locally with zero egress, and a fitting body still going direct (no false refusal). (cherry picked from commit 55cafc4)
28338b0 to
6393e0b
Compare
|
已经把这个 PR 重排到当前 master,重新起了一次干净 CI。 新 head
在新 base 上重跑的验证(不是沿用旧 head 的结果):
状态: 合并顺序建议不变:#5027(pi) 先,本 PR 任意时点(两者文件不相交,已用 merge-tree 验过)。#5077(omp) 仍需 #5027 落地后再 rebase —— 它现在冲突在 |
|
全量 CI 结果出来了,全绿。
主 当前唯一剩下的状态是 合并动作等 owner。顺序建议仍是 #5027 先、本 PR 任意时点。 |
(ai: vllm-qwen/qwen3.8-27b) 收到。全绿我独立核实过了;当前不需要再刷一版——BEHIND 不构成合并障碍,等 owner 拍板即可。 独立核实(不依赖你贴的结果)
为什么现在不刷新版
剩余状态:head |
(ai: vllm-qwen/qwen3.8-27b) 你的重排说明我逐条对着本地 git + 镜像缓存核过了:全部吻合,全绿独立确认。我这边没有待办动作,剩下就是等 owner 合并。 逐项核实(独立重查,不沿用你贴的结论)
状态与后续
|
(ai: vllm-qwen/qwen3.8-27b) 这条全绿报告之前已收到并独立核实过——见上方两条 [bot] 回复(06:11Z、06:31Z),此处不重复展开,无新动作。 刚又快速复核一遍:refs 无变化(head |
Part of #5032 (the opencode half — deliberately
Part ofso the issue is not auto-closed by whichever lane lands first). The other two lanes are separate PRs: #5027 (pi) and #5077 (omp) — this PR touches neither, so it is independent of merge order.Problem
directSendOrRefuse(src/agent/native-intercept.ts:1204) refuses a would-be direct send only when it can measure the body against a window:On the opencode V1 lane both sources were empty precisely on the degraded path:
chat.headersstampsx-bili-plugin-context-windowonly after an origin is known — the hook returns atif (base === undefined) return;(src/agent/opencode-native.ts), so a dead proxy means no header;state.declaredWindowForDirect— the V1 lane set onlyprepareDirectSend(src/agent/opencode-native.ts:270). [Bug][dsh] 0.1.208: attributed-but-not-ready direct send has no window guard, and takeover is declared before readiness — long sessions 400 with prompt_too_long | 归因正常但代理未就绪时直发无窗口护栏 + 就绪前就宣告接管 → 长会话必 400 #4894 armed dsh, [PR] fix: arm the pi lane's direct-send window guard so a proxy outage cannot egress an oversized history #5027 armed pi; opencode V1 was the remaining gap.Net effect with the proxy down: a session whose history had outgrown the model window was forwarded uncompressed, the upstream answered "input exceeds the context window", and every retry re-sent the same body — the turn could never succeed until the proxy came back (identical to #5025 for pi).
Fix
undefined.state.declaredWindowForDirectwith the recorded reader, sodirectSendOrRefusemeasures on the fallback path too.??short-circuits), so healthy-proxy traffic is byte-identical; an unknown window keeps fail-open (never a guessed window).Verification
tests/issue5032-opencode-direct-window.test.ts(5 cases): record-before-return under a dead proxy (and that nothing is stamped there); record cleared on unknown model/window; the arm is in place; provably-oversized body → local422withx-bili-gate: oversize-refusal-fallbackand zero egress; a fitting body still goes direct (no false refusal).npm run typecheck,npm run check:unused-exports,npm run check:test-import-graph,tests/opencode-native-v1.test.ts,tests/issue5025-pi-direct-window.test.ts,tests/issue4894-direct-window-guard.test.ts— all pass.Scope notes
state.windows, so opencode's V2 lane was never affected; only the V1 lane was naked.piDeclaredWindowForDirect, so it wants [PR] fix: arm the pi lane's direct-send window guard so a proxy outage cannot egress an oversized history #5027 first).prepareDirectSendclosure, which would also touch the dsh and pi lanes; out of scope here.