Skip to content

[PR] #2924 oversize 422: point dead-scope users at a host restart, not a futile retry - #3595

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-17_oversize-refusal-restart-guidance
Oct 19, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-17_oversize-refusal-restart-guidance

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What & why

Follows #3589. When a dsh agent scope dies mid-request (e.g. an auto-update cuts an in-flight stream), the #2924 takeover gate's refuse-oversized arm fires: attribution throws, the raw body provably exceeds the window, and bili refuses locally with a 422 (bili_gate_oversize_refusal) instead of forwarding a guaranteed upstream 400.

That arm is reachable only through the threw+oversized path — i.e. the scope is dead. In that state the old message told the user to "Retry the turn; if it persists … needs compaction or a fresh session", which is actively misleading: retrying the same call keeps failing while the scope stays dead, and compaction is impossible (there is no fold handle once attribution throws). The #3589 incident user retried 5+ times, each a 422, and read it as "context blew up".

This makes the 422 wording tell the truth and give the one remedy that actually works: restart the client host (session state is persisted on disk, nothing is lost; after the restart the oversized history folds back under the window normally), with a fresh session as the fallback.

Behavior change (error TEXT only — flagged per policy)

No logic / wire / HTTP-status / header / code / retryable change. Only the human-facing message field of the 422 changes:

  • Old: … host attribution failed mid-request and the request body cannot fit the model's context window — sending it uncompressed would be rejected upstream (#2924). Retry the turn; if it persists, the session's local history has outgrown the window and needs compaction or a fresh session.
  • New: … the host's attribution lookup threw mid-request (its agent scope is disposed/closing), so this body cannot be folded into the model's context window — forwarding it uncompressed would be rejected upstream (#2924). While that scope stays dead, retrying this same call will keep failing; restart the client host once (its session state is persisted on disk, so nothing is lost) so the oversized history can be folded back under the window. If you cannot restart, start a fresh session instead.

Why: the old "retry the turn / needs compaction" guidance cannot succeed in the only scenario that reaches this message (dead scope). Pointing at a host restart removes the futile-retry loop the user experienced in #3589.

Scope notes

Verification

  • Targeted suites green: node --import tsx --test tests/native-intercept.test.ts tests/dsh-native.test.ts → 114 pass / 0 fail (includes the #2924 refuse-oversized cases).
  • Rebased onto current master; single-file diff. Full-suite verdict = CI on the pushed head.

查重

不重复 — #2924(takeover-gate refusal 机制)已 closed/已合入;无在途 issue/PR 提议此 422 文案增强。dsh 死 scope / 无限重试等根因属外部 dsh 仓库,见 #3589 责任拆解,不在本 PR 范围。

Follows #3589

…etry (#3589)

The refuse-oversized arm is reachable ONLY via attribution-threw + body-over-window
(the host's agent scope died mid-request). In that state retrying the same call keeps
failing and compaction is impossible (no fold handle), so the old guidance ('retry the
turn; ... needs compaction or a fresh session') was misleading. State why retry is
futile and make the remedy a host restart (session state is persisted on disk); fresh
session as the fallback.

Behavior change (error TEXT only — no logic/wire/code path change): the 422 'message'
field of bili_gate_oversize_refusal now says restart-the-client-host instead of
retry/compaction. The stable code, HTTP status, x-bili-gate header, and retryable:false
are all unchanged.
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-17_oversize-refusal-restart-guidance (a73aae3)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4250-pr.3595.b6e6689

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3595.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复(独立检索,open+closed issue 与近期 PR,按措辞/失败签名匹配):无任何在途条目提议此 422 文案变更。相关但不同机制的条目:#3593(attribution 失效的可见化——panel + /__bili/status,是状态面不是报错文案)、#3589(事故根因拆解,死 scope 根因在外部 dsh 仓库)。本 PR 与它们互补不重叠。

初审已独立完成(不复读 PR 描述):

  • 方向关:读了 src/agent/dsh-native.ts:1424-1429 的 takeoverGate 与 settleThrewAttribution——refuse-oversized 唯一产出点是 dsh-native.ts:1420,且仅在「首次 attribution threw → settle-retry 仍 threw → body bytes/4 超窗」时返回。PR「该分支只可能经 threw+oversized 到达(scope 必死)」的论断成立;native-intercept.ts 两处调用点(routed 车道 :748、raw 车道 :939)都只在该 verdict 下触发 oversizeRefusal,文案确实只面向死 scope 场景。
  • 回归清单:diff 单文件 9 行,仅 message 字符串 + 函数 doc 注释变化;422 状态码、x-bili-gate header、code: bili_gate_oversize_refusal、retryable: false、Anthropic/OpenAI 双 envelope 形状全部未动;opencode V2 镜像 oversizeDirectRefusal(opencode-native.ts:120,proxy-unavailable 触发)确认未触碰;旧文案全仓无第二处引用。
  • 测试有效性:tests/native-intercept.test.ts 对该 422 断言的是 status/header/code/retryable + assert.match(message, /#2924/),新文案仍含 (#2924),满足;纯文案变更无需新钉文本(钉全文反而脆)。

CI 状态:static gates 全绿(kernel-guard/config-surface-guard/docs-sync/…),test 分片运行中。绿了之后补结构化八问结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 结论 + 结构化八问

CI:初跑(e8fdea0)恰好一个红 lane —— test (windows-latest, 22, 1):首个失败为 tests/lane-decisions-matrix.test.ts 的 lane matrix [google] dsh no-tools drops the surface (#3177),failureType: 'cancelledByParent',error 'Promise resolution is still pending but the event loop has already resolved',TAP pass 4170 / fail 0 / cancelled 6(后 5 个兄弟子测试被级联取消)。判定为既有 Windows flake,非本 PR diff 所致:

  • tests/lane-decisions-matrix.test.ts:72-78 的注释已记录这一类 flake、且引的就是同一句错误文案(lane 统一决策点收尾:四处 B 类名字旁路迁入 + nudgeOn 单点(#3482) #3490 加固 commit aa56257);
  • 本 PR diff 只有 oversizeRefusal 里两个字符串字面量 + 一条 doc 注释,该函数在 matrix 测试中不可达——对事件循环挂起没有因果路径;
  • 同 run 其余全部 lane 绿,master HEAD b10c525 的全量 run(含所有 windows shard)也全绿 → 间歇性。

处置:agent 账号无 actions rerun 权限(rerun-failed 与 check-runs/rerun 两个端点均 404),于是在 PR 分支推了一个空提交 a73aae3c0 重触发整套 CI → 30 个 lane 全绿。另立 #3602 跟踪该 flake 的残余变体(现有加固覆盖了 upstream.listen(0) 的重试,但 bili proxy 自身侧 listen——同文件 :119-128——没有同样包装,是疑似未覆盖路径),正文带来源标记与完整失败签名。

八问:

  1. 是什么问题:dsh 车道死 scope 时(attribution mid-request throw + body 超窗)的 422 报错文案把用户引向「重试/压缩」——而该场景下重试永远不会成功。
  2. 什么原因导致的:旧文案描述的是通用 oversized-session 处置;但该分支唯一可达路径是 host attribution lookup threw(scope disposed/closing),此时重发同一调用必再失败、compaction 又不可行(attribution throw 后没有 fold handle)。[dsh] Cannot intercept dsh requests? Dead scope retransmission + post-update dual instances trigger #2924 oversize 422 r | [dsh] 无法拦截dsh请求? 死 scope 重发 + 更新后双实例引发 #2924 oversize 422 重试风暴(用户全量日志定案,dsh 0.2.1rc1) #3589 的用户连试 5+ 次、每次 422,误读成上下文爆了。
  3. 影响范围与严重程度:仅命中 dsh 车道死 scope 这一 422 的用户(罕见故障态);严重度 = 误导性指引导致徒劳重试,无功能影响。
  4. 怎么修复的:纯文案修正——新文案讲清真因(attribution throw → scope 已死)、说明为何重试无效、给出唯一有效补救(重启一次 client host;session state 持久化在磁盘上,不丢东西),fresh session 作后备。逻辑/状态码/header/code/retryable 一律未动。
  5. 是否有回归问题:逐项过既有行为——422 状态码不变、x-bili-gate: oversize-refusal header 不变、code: bili_gate_oversize_refusal 不变、retryable: false 不变、Anthropic/OpenAI 双 envelope 形状不变、upstream 依旧永不被调用(sink 为空断言成立);opencode V2 镜像 oversizeDirectRefusal([Bug] plugin native 车道疑似静默直连:attach/spawn 未就绪即 proxy unavailable — go direct,长会话按未压缩历史直发上游撞 400(0.1.197 / opencode v2 2.0.29) #3308,proxy-unavailable 触发,不同机制)确认有意未触碰。唯一有意变更 = 人类可读 message 文本(旧值→新值已在 PR 正文按政策披露)。测试断言的是稳定 code 而非精确文本,新文案仍含 (#2924) 满足现有断言。无回归。
  6. 是否破坏缓存:不涉及——纯错误文案变更,不触碰缓存/去重/游标逻辑。
  7. 是否改了设计方向:否——takeover gate refusal 机制原样,只改人类可读输出。
  8. 是否引入了新的配置:无。

判定:可合并 —— 方向关/回归清单/测试有效性/diff 整洁度全部通过,全套 CI 绿(head a73aae3c0,含空提交重跑的 windows shard)。合并请你来点(系统规则禁止 agent merge PR):#3595

@ranxianglei
ranxianglei merged commit 4a40022 into master Oct 19, 2026
42 checks passed
@ranxianglei ranxianglei changed the title #2924 oversize 422: point dead-scope users at a host restart, not a futile retry [PR] #2924 oversize 422: point dead-scope users at a host restart, not a futile retry Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.582-master.4a40022 (rolling master tag).

npm install -g billion-context@0.0.582-master.4a40022  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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.

1 participant