Skip to content

[PR] fix(agent): name the incompressible media share in the unattributed byte-cap 422 (#7450) - #7454

Merged
ranxianglei merged 1 commit into
masterfrom
2026-11-21_byte-cap-media-split
Nov 21, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-11-21_byte-cap-media-split

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #7450

What

The silent-direct byte ceiling (8 MiB, MAX_SILENT_DIRECT_BODY_BYTES) is on total request-body bytes, but compression can only act on text. An unattributed image-heavy session that crosses the ceiling got a 422 that said only "body larger than the silent-direct byte ceiling" — with no way to tell whether the incompressible media alone already exceeds the ceiling (a dead end no compression can rescue) or whether the text remainder could still be folded under it.

This is the observability gap (direction 3) from the #7450 report: the user should be able to see at a glance which lock did not open.

Fix

In the unattributed byte-cap arm (src/agent/native-intercept.ts):

  1. unattributedByteOversizeRefusal now takes {bytes, cap, mediaBytes?} and names the byte basis (X B > Y B) in the message. When the media share is known:
    • media >= cap → dead-end wording: the media alone already exceeds the ceiling; start a fresh session or attach smaller images; routing through bili will not remove the media.
    • 0 < media < cap → names the media share and notes the text remainder is foldable through a bili-managed session (the existing remedy).
    • media = 0 / unknown → the legacy remedy wording (no false media claim).
  2. The call site bills the media share via mediaBytesOfWireBody (the same protocol-agnostic walk the doom arms use, DSH's unattributed over-limit gate prices base64 images as text (bytes/4) — media-heavy requests are falsely rejected wi | dsh 无归属超限门把 base64 图片当文本计价(bytes/4)——媒体重的请求被假拒 422,上游本会正常接受 #4111) when the raw body is cheaply at hand (restored prep body / measured raw / string init body). One-time JSON.parse on the refusal path only (rare; the doom arms have the same exposure).
  3. The error log line gains ; N B inline media, incompressible when the media share is > 0.

Behavior change (flagged)

  • The 422 refusal message for the unattributed byte-cap arm now carries the byte counts (X B > Y B) and, when the raw body is decodable, the inline-media byte share. The gate decision is unchanged (same condition, same 422, same x-bili-gate: oversize-refusal-unattributed-bytes header, same retryable: true). Only the diagnostic text changed.
  • This text is host/user-facing (the 422 body returned to the host's fetch), not model prompt surface. Some hosts may surface error text to the model; the wording is a factual diagnostic, consistent with the existing directive wording in the same message.

Scope

  • Only the unattributed byte-cap arm — the arm that fired in the 【bug】#6511 Supplement | #6511 补充 #7450 report. The sibling token-doom arms (oversizeRefusal / unattributedOversizeRefusal / fallbackOversizeRefusal) already log the media split (native-intercept.ts:1816) and are a different verdict class.
  • No config-surface change, no wire/protocol change, no kernel change, no persistence change.

Tests

New regression test install: the unattributed byte-cap refusal names the incompressible media share (#7450) covers all three rows against a 1 MiB ceiling (BILI_SILENT_DIRECT_MAX_MB=1):

  • dead-end: data-URL media 1,200,000 B > ceiling → message names "media alone already exceeds the ceiling"
  • foldable: media 900,000 B + text pad → message names the media share + the text-remainder remedy
  • pure-text negative: no media claim, the legacy remedy

Targeted: node --import tsx --test tests/native-intercept.test.ts — 94 pass (incl. the new test). Typecheck clean. Full build OK. Related suites (issue5686-compaction-direct-refusal, issue3304-incremental-direct-send) — 27 pass.

…yte-cap 422 (#7450)

The silent-direct byte ceiling (8 MiB) is on TOTAL body bytes, but
compression only acts on text. An image-heavy unattributed session that
crosses the cap got a 422 that said only 'body larger than the ceiling'
with no way to tell whether the incompressible media alone already
exceeds it (a dead end) or the text remainder could still be folded.

Bill the media share (mediaBytesOfWireBody, the same walk the doom arms
use) when the raw body is cheaply at hand, and name it in both the
refusal message and the log:
- media >= cap   -> dead-end wording (fresh session / smaller images;
                    bili routing will not remove the media)
- media <  cap   -> media share named + the text-remainder remedy
- media = 0/unknown -> legacy wording, byte-count basis still shown

Regression test covers all three rows (dead-end, foldable, pure-text
negative) against a 1 MiB cap via BILI_SILENT_DIRECT_MAX_MB.
@ranxianglei ranxianglei added bug Something isn't working p2 scope/wiring labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-21_byte-cap-media-split (7571c0c)

Latest build — install this exact version

npm install -g billion-context@0.0.11194-pr.7454.3903d4f

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

Recent builds (commit → version)

commit version build
7571c0c billion-context@0.0.11194-pr.7454.3903d4f build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(agent): name the incompressible media share in the unattributed byte-cap 422 (#7450) [PR] fix(agent): name the incompressible media share in the unattributed byte-cap 422 (#7450) Nov 21, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #7454 review — verified live, mergeable.

State (just checked): open, mergeable, not draft; head 7571c0c on current master (0 commits behind); CI fully green — 0 failures, all test shards (ubuntu 22/24 ×3, windows 22 ×5), static-gates (ubuntu 24, windows 22), and every guard (version-guard, kernel-guard, pi-subagents-guard, config-surface-guard, …) pass. Diff: 2 files, 85+/6- (src/agent/native-intercept.ts, tests/native-intercept.test.ts). PR labels set on its own diff: bug / p2 / scope/wiring.

Independent verification (not just the PR's claims):

  • Read the full diff; traced the three-branch logic and the call-site variable sources (prep / measured / init — all in scope, all pre-existing).
  • Confirmed unattributedByteOversizeRefusal has exactly one caller (the signature change is safe).
  • Ran it locally: tests/native-intercept.test.ts → 94/94 pass (incl. the new #7450 regression test, all three rows); related issue5686-compaction-direct-refusal + issue3304-incremental-direct-send → 27/27 pass; npm run typecheck → clean. (The one transient failure I hit was an unbuilt pi-subagents in this fresh clone — an environment gap, not a code issue.)

八问(独立审核,非照抄 issue 侧)

  1. 是什么问题:未归属会话撞 byte-cap 422 时,拒答消息只说"body 超过静默直发字节上限",用户看不出是「不可压媒体单独就超限(死路,压缩救不了)」还是「文本剩余还能被折叠压到上限下」。这是 【bug】#6511 Supplement | #6511 补充 #7450 报告的方向 3(可观测性缺口)。
  2. 什么原因导致的:字节上限(8 MiB)数的是请求体总字节,但压缩只能作用于文本。原拒答消息不带字节构成,用户无法判断哪把锁没开。
  3. 影响范围与严重程度:仅影响未归属会话撞 byte-cap 422 时的诊断体验。422 判定本身不变(同条件、同 422、同 x-bili-gate 头、同 retryable)。属可观测性瑕疵(p2),非可用性缺陷——422 本来就会发生,只是现在能看出该走哪条补救路径。
  4. 怎么修复的:在拒答消息与错误日志里标出内联媒体字节占比(复用 doom 臂共用的 mediaBytesOfWireBody 协议无关遍历),按三种情况给不同指引:媒体≥上限→死路措辞(开新会话/换小图);0<媒体<上限→标媒体占比 + 文本剩余可折叠;媒体=0/未知→沿用旧措辞(不误报媒体)。
  5. 是否有回归问题:逐项过既有行为——byte-cap 判定条件、422 状态码、x-bili-gate 头、retryable、消息 envelope 形状(type/error/type/message/retryable)全部不变,只有诊断文本变了。函数签名加了 detail 参数,全仓唯一调用点已更新。新增 JSON.parse(mediaBytesOfWireBody 内)只在拒答路径(罕见)跑,内部 try/catch 包裹,parse 失败降级为 0(旧措辞)——与 doom 臂既有暴露一致,无新失败模式。无回归。
  6. 是否破坏缓存:不涉及(不碰缓存/重试/增量游标/去重键)。
  7. 是否改了设计方向:不涉及(纯诊断文本改善,不动架构/边界/数据流)。
  8. 是否引入了新的配置:不涉及(无新 env/config/CLI flag)。

一个提醒(非阻塞):PR 正文写 "Closes #7450",但 #7450 是机制报告(方向 1/2/3),本 PR 只做了方向 3(诊断)。核心机制(方向 1:byte-aware trigger)已单独立项 #7455(open,needs-decision,p1);方向 2 无需改代码。所以合并 #7454 会让 #7450 随之关闭——即「报告关闭、机制修复仍待 #7455 决策」。这个 scoping 在前一 session 的 #7450 交付评论里已写明、且 #7455 明确跟踪机制修复,故可接受;若你希望报告在 #7455 落定前保持 open,把 "Closes" 改成 "Part of" 即可(一行改动,我可以直接改)。

结论:可合。 代码正确、定向测试 + typecheck 全绿、CI 全绿、diff 干净、标签齐。合并权在你(agent 不合并 PR)。

@ranxianglei
ranxianglei merged commit 67e9bc2 into master Nov 21, 2026
88 of 126 checks passed
ranxianglei pushed a commit that referenced this pull request Nov 22, 2026
Fourth merge of master into the v6 re-land lane (master 75ab922, +74 commits: #7465 protectedMass, #7470 dsh-ext intercept, #7437 per-session ingest watermark, #7503 KDD7 doc, #7476 429-governor default-off, #7454 byte-cap, #7423 opencode fork lineage, #7417 tag-echo turn-bleed, plus kernel 0.0.202). Four conflicts, all config-reference docs where both sides added rollout entries at the same table position — resolved as union: lane's watermarkV6MsgId + watermarkV6Render rows kept (grouped with pluginFullResendWatermark), master's passDshExtensions row kept after them. Files: docs/configuration.md, docs/configuration.ja.md, docs/configuration.zh-CN.md, website/config-reference/rollout.yaml. No production-code conflicts; all src/ auto-merged. Typecheck + build clean; targeted suites 170 pass / 0 fail / 1 skip (pf-channel, v6 lane, v5 fastpath, storage, #2929, rollout, msgid-rule-parity, render-snapshot).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p2 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【bug】#6511 Supplement | #6511 补充

1 participant