Skip to content

[PR] fix(#5620): name never-foldable media mass in acp_status (MEDIA FLOOR) - #5619

Open
ranxianglei wants to merge 4 commits into
masterfrom
2026-11-04_media-floor-status
Open

ranxianglei wants to merge 4 commits into
masterfrom
2026-11-04_media-floor-status

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Part of #5620 — observability option C from the decision comment in that thread. Root-fix options A/B remain pending owner decision there.

Problem

A dsh session dominated by remote-URL / file-ref images climbs to ~70% usage while the kernel offers only tens of K of foldable mass: such messages can never fold (#1188/#2609) and turn integrity pins the turns around them (#684). The existing PRESSURE NOTE cannot fire in exactly this state — its maxPending < growth-step condition fails because pinned turns keep a range advertised forever (in the #5620 log maxPending stayed >= 50K while every idle reason read growth N < floor 22500). The user sees a stuck context with zero visibility into why.

Change

src/acp-status.ts: new MEDIA FLOOR section after the PRESSURE NOTE. When >= 1 live message carries unrecoverable media (kernel predicate hasUnrecoverableMediaPayload) AND their mass is >= 5% of modelContextLimit (MEDIA_FLOOR_REPORT_FRACTION, named constant beside PRESSURE_NOTE_USAGE_FRACTION), full-view acp_status reports count, token mass, share of the window, and why the floor does not come down.

Behavior change disclosure

Additive-only: one new informational line appears in full-view acp_status output, only when the gate fires. No other output, default, threshold, timing, or wire shape changes. No config surface added.

Tests

New tests/issue5620-media-floor-status.test.ts, 4 rows per gate discipline (#3617): positive (remote-URL image mass above threshold), negative (archivable data:URL images fold normally, #2607), negative (sub-threshold mass stays silent), additive (media-free sessions keep today's output). Typecheck clean, targeted suites green locally; full suite rides CI.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-04_media-floor-status (7d56a01)

Latest build — install this exact version

npm install -g billion-context@0.0.8046-pr.5619.5c061df

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
7d56a01 billion-context@0.0.8046-pr.5619.5c061df build
f90bb0e billion-context@0.0.8045-pr.5619.c275fd9 build
6d839f5 billion-context@0.0.8043-pr.5619.74db914 build
c18ebcd billion-context@0.0.8041-pr.5619.59f6806 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(#5620): name never-foldable media mass in acp_status (MEDIA FLOOR) [PR] fix(#5620): name never-foldable media mass in acp_status (MEDIA FLOOR) Nov 3, 2026
ci-check added 2 commits November 4, 2026 01:24
dsh sessions dominated by remote-URL / file-ref images climb to ~70% usage
while the kernel offers only tens of K of foldable mass: such messages can
never fold (#1188/#2609) and turn integrity pins the turns around them
(#684). The PRESSURE NOTE cannot fire in exactly this state — its
maxPending < growth-step condition fails because pinned turns keep a range
advertised forever (log: maxPending >= 50K while idle reasons show
'growth N < floor 22500') — so users saw a stuck context with zero
visibility into why.

acp_status (full view) now renders a MEDIA FLOOR line after the PRESSURE
NOTE whenever >= 1 live message carries unrecoverable media (kernel
predicate hasUnrecoverableMediaPayload) AND their mass is >= 5% of
modelContextLimit (MEDIA_FLOOR_REPORT_FRACTION): count, token mass, share
of the window, and why the floor does not come down. Additive-only: no
existing section, default, threshold, timing, or wire shape changes; no
config surface added.
The gate as submitted measured media mass with the local text meter only — openai-wire image parts ride a "[image]" placeholder in CoreMessage.text (kernel/src/wire/openai.ts), so each remote-URL image counted ~2 tok against its billed cost and the 5%-of-window gate was effectively unreachable in exactly the sessions this line exists for (#5620: dsh at ~70% usage dominated by remote images).

Add the billed-grade prior the billing lane already uses for images whose bytes bili never sees: REMOTE_IMAGE_TOKENS (src/image-tokens.ts, 4096) per remote-URL image payload, mirroring the media branches of hasUnrecoverableMediaPayload over the sidecar shapes reachable in ctx.messages (openai content/parts, anthropic block/tool_result url-source, responses input_image). Other unrecoverable payloads (file refs, Google fileData/videoMetadata) keep counting toward the message count only — no stable billed prior exists for them.

Tests: row A now uses realistic caption-sized fixtures and pins the billed prior in the rendered line; row C re-anchors on 1 remote image ≈ 4096 tok = ~2% < 5%. Typecheck clean; targeted suites green locally, full suite rides CI.
@ranxianglei
ranxianglei force-pushed the 2026-11-04_media-floor-status branch from 6d839f5 to f90bb0e Compare November 3, 2026 17:26
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复 —— 本 PR 是内部 #5620 决策评论中 option C(可观测性)的实现,open/closed 检索无其他 MEDIA FLOOR / media-mass status 相关条目或并行 PR。
标签: dsh / scope/ui / p3(dsh 场景驱动的诊断面增强;p3=可观测性瑕疵级。本环境的 label API 未实现,仅申报,未能程序化打标。)

审核结论:发现一个真问题,已直接在 PR 分支修掉,并 rebase 到当前 master

发现的问题(提交版缺陷):门槛的量程装错了表。mediaFloorMass 只用本地文本计量器(countMessageTokens)数媒体消息的质量——但 openai-wire 的图片部分在 core message 里只是一个 "[image]" 占位符(kernel/src/wire/openai.ts:170-196 写入 text: CANONICAL_IMAGE_TEXT;kernel/src/wire/identity.ts:43 定义其为 "[image]"),每张远程图只计 ~2 tok,与其计费成本差约三个数量级。后果:#5620 的目标场景(dsh 会话被远程图片主导、usage ~70%)下,媒体质量几乎永远够不到 5% 窗口门槛——这行会在真正需要它的会话里始终缺席,option C 落空。原测试行 A 用「20000 字符文本 + 远程 URL」的合成夹具掩盖了这一点(真实形态是短 caption + 独立 [image] 消息)。

修复(独立标注 commit f90bb0e):按计费层既有约定补上计费级先验——每个远程 URL 图片 payload 加 REMOTE_IMAGE_TOKENS(src/image-tokens.ts:31,4096 tok,billing lane 对「bili 拿不到字节的图」的既有平估);payload 计数镜像 hasUnrecoverableMediaPayload 的媒体分支,覆盖 ctx.messages 可达的 sidecar 形态(openai content/parts、anthropic block/tool_result url-source、responses input_image;system 侧车分支在 prepare 后不可达,已在注释说明)。无稳定计费先验的不可恢复载荷(file ref、Google fileData/videoMetadata)仍计入消息数、不计入质量——不猜。渲染行同步注明混合口径。

行为变更披露(相对提交版,不是相对 master):MEDIA FLOOR 行的 tokens 口径从「纯本地文本估计」→「文本估计 + 每远程图 4096 tok」。相对 master 仍是纯增量(master 无此功能);0.05 门槛常量不变,无配置面新增。修复后目标场景可达:3 张远程图 ≈ 12300 tok ≈ 6% ≥ 5% → 出报告行;1 张 ≈ 2% < 5% → 保持静默(噪音护栏保留)。

验证:typecheck 干净;tests/issue5620-media-floor-status.test.ts 4/4(行 A 改为真实 caption 形态并钉住 ~6% 与 4096 字样;行 C 重锚为 1 张远程图 ≈2% 静默);相邻 acp_status 套件(acp-status / issue2366-cjk-billed / issue4331-uncovered-history / dead-ref-range-filter / issue2432-breaker-awareness)合计 43/43 绿。全量回归交 CI。

基线处理:PR 原分支基于 10-28 的旧 master,落后约一周(~229 文件漂移,含 src/acp-status.ts 自身的 #5139/#5221 改动)。已 rebase 到当前 master 9dc4c94(无冲突;MEDIA FLOOR 区块与 master 新增的 else 提示分支、RESOLVER WEDGE 段互不干扰),rebase 后 typecheck + 全部定向测试重跑通过,已 push(force-with-lease,head=f90bb0e30)。旧 head c18ebcd 的全量 CI 曾为绿(镜像缓存可查);新 head CI 运行中。

八问

  1. 是什么问题:dsh 类会话被远程 URL/文件引用图片主导时,上下文涨到 ~70% 却没有任何面解释「为什么压不动」;option C 在 acp_status full-view 加一行 MEDIA FLOOR,点名这批永不折叠的质量及其占比。
  2. 什么原因导致的:两层。结构性:这类媒体折叠即永久销毁(这个插件压缩上下文,会导致deepseek识图出问题。 #1188/Google wire 的 fileData(URL 引用)图像不被识别为媒体负载:可被折叠、折叠后静默丢失且无警告(#1188 不变量缺口) #2609),turn integrity 又钉住周边回合([bug] compress 保护区过滤在完整性调整之后挖洞,导致 assistant tool-call 消息缺 reasoning_content(DeepSeek 思考模式 400) #684),所以它们构成降不下来的地板;可见性缺口:PRESSURE NOTE 的 maxPending < growth-step 条件在此态恒假(钉住的 range 被永久 advertise,maxPending 常驻 ≥50K),既有告警恰好在此盲区哑火。
  3. 影响范围与严重程度:体验/可观测性瑕疵——会话可用、压缩在增长触发点照常工作,只是卡死态零解释。p3。
  4. 怎么修复的:full-view 在 PRESSURE NOTE 后新增独立门槛(≥1 条 live 消息带不可恢复媒体,且质量 ≥5% modelContextLimit,命名常量 MEDIA_FLOOR_REPORT_FRACTION)的报告行:条数、质量、窗口占比、为何降不下来。审核中把质量计量修正为「文本估计 + 每远程图 4096 tok 计费先验」,否则目标场景触达不到门槛。
  5. 是否有回归问题:逐项审过既有行为——scope view(提前 return,不受影响)、Nudge/PRESSURE NOTE/BILLED INPUT/ranges 表/UNCOVERED HISTORY/DEAD REFS 各段输出与触发条件均不变;新行仅在门槛命中时追加进 full-view extra[],与 PRESSURE NOTE 同生命周期(同一 try/catch 降级语义,processTurn 失败则整段缺省,与邻段一致)。与 master 新增的 [Bug][Codex] Temporary separator selected as compression endpoint, causing acp_status to silently fail to report ~180K t | [Bug][Codex] 临时分隔符被选作压缩端点,导致 acp_status 静默漏报约 18 万 token 可压缩历史 #5139 withoutTurnSeparators(只改 processTurn 入参;mass 计算沿用 raw ctx.messages,与上方 estTotal 循环同口径,分隔标记不带媒体侧车不可能被谓词命中)及 live===undefined 的 else 提示分支(与本段互斥)无交互。无回归。
  6. 是否破坏缓存:不涉及——不改 wire、不改出站字节、不动缓存/重试/游标/去重策略;acp_status 是诊断工具调用,多出的行只进模型可见历史,与该面板所有既有行同性质。
  7. 是否改了设计方向:不涉及——严格按 option C 既定形状落地(命名阈值 + 条数/质量/占比/原因);根修 A/B 仍在内部 [Bug] Config save rejects valid mitm:// provider lanes as "invalid recipe on named provider" | 整文件保存把 mitm:// 路由误判为命名配方 #5620 等 owner 拍板,本 PR 不触碰。
  8. 是否引入了新的配置:无——MEDIA_FLOOR_REPORT_FRACTION=0.05 是代码内命名常量(与 PRESSURE_NOTE_USAGE_FRACTION 并列),非配置项;复用了既有 REMOTE_IMAGE_TOKENS 常量。

判定:方向正确,实现(修复后)成立,测试双向齐全(#3617 纪律:正例 + 可归档负例 + 亚阈值负例 + 增量行)。新 head CI 转绿即可合并;合并留给人。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

CI 跟进(新 head f90bb0e):静态门禁全绿(static-gates / gate / lock-sync / unused-exports / plan / test-import-graph / config-surface-guard / docs-sync / lifecycle-ledger-guard / pi-subagents-guard / mysql-contract),测试分片(ubuntu/windows × node 22/24 共 12 片)排队/运行中,目前零失败。分片跑完转绿即可合并;若某片红了我会被唤醒继续排查。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

方向(① 原 issue):#5620 的根因链成立——远程 URL / 文件引用媒体按设计永远不可折叠(#1188/#2609),turn integrity 又把跨越它们的整个回合钉住(#684),残段又低于 50K 折叠门槛,于是会话停在 ~72% 而只有几十 K 可折。本 PR 交付的就是该 issue 里承诺的选项 C(纯观测、零行为变更),范围精确;根治选项 A/B/D 留在 issue 线程等 owner 拍板,正确地没有混进来。无 kernel 触碰。

回归清点(②)——diff 只碰 src/acp-status.ts(+新测试文件),逐项过其承担的既有行为:

  • 全量视图输出在门槛未触发时:逐字节不变(单一受门控的 extra.push;测试 D 行钉死「无媒体时不出现新区段」);
  • scope 视图:if (scope) return toolOk(base)(src/acp-status.ts:274)先于 extra[] 构建返回,不受影响;
  • processTurn 失败降级:MEDIA FLOOR 与 Nudge/PRESSURE NOTE/ranges 在同一 try/catch 内,同等降级为 base-only;
  • Nudge 与 PRESSURE NOTE 门控代码:未触碰;
  • 成本:每次 acp_status 多一次 O(n) 谓词扫描 + 仅对命中消息做 token 计数——低频诊断工具调用,可忽略。
    行为变更披露:全量视图 acp_status 在不可恢复媒体质量 ≥ 窗口 5% 时新增一行信息性输出(PR 正文已声明,additive observability)。其余一律不变。

代码(③):计数器镜像 hasUnrecoverableMediaPayload(kernel/src/protected.ts:609-716)的媒体分支,我逐形状核对了可达性——openai rawOpenaiContent/rawOpenaiContentParts 由编解码器构造上互斥(kernel/src/wire/openai.ts:170-241),else-if 不会漏计;anthropic block / tool_result 嵌套、responses input_image 分支与内核谓词一致;inline-data 正则与内核 isInlineDataUrl 逐字节相同。计费级计量(f90bb0e30 评审修复)用的正是计费车道对远程图实际收费的 REMOTE_IMAGE_TOKENS(src/image-tokens.ts:31、:193-199),口径一致。

测试(④):断言有牙——A 行在无计费先验时会直接失败(恰好钉住 f90bb0e 修的那个缺陷);B/C 是真正的负例(可归档 data:URL、低于阈值);D 钉 additive-only。发现一个覆盖缺口并已顺手补上(见下)。

已顺手修(本分支两个独立 commit,均不触语义):

  1. src/acp-status.ts:128 原注释称 system sidecar 分支「cannot fire here」——不准确:会话中途的 system 消息带着 rawAnthropicMessage sidecar 留在 core 数组里(kernel/src/wire/anthropic.ts:114-124),谓词的 system 分支可以命中(计入 count、不加图片先验——行为本就正确,只是注释与事实不符)。修正于 261174a6d。
  2. 计数器的 anthropic / responses 线型分支原先无测试覆盖,补 E/F 两行正例钉住(7d56a01f6)。本地验证:6/6 通过、tsc 干净;CI 在新 head 重跑中。

结构化八问:

  1. 是什么问题:dsh 会话里带远程图片的消息永远无法折叠,把上下文地板顶到 ~72%,acp_status 却只报「可折叠范围很少」——用户分不清是压缩器坏了还是结构性地板。
  2. 什么原因导致的:三层机制叠加——远程媒体按设计不可恢复(#1188/#2609)+ turn integrity 钉住跨媒体回合(#684)+ 残段低于 50K 门槛使 nudge 恒 idle;且此前没有任何诊断面命名这块质量。
  3. 影响范围与严重程度:所有携带不可折叠媒体的长会话(dsh 截图类工作流最典型);体验瑕疵级——功能可用,但诊断缺失导致误判。本 PR 只加观测,不改任何折叠行为。
  4. 怎么修复的:acp_status 全量视图中,当不可恢复媒体质量 ≥ 窗口 5% 时输出一行 MEDIA FLOOR:消息数、计费口径 tok 数(文本估算 + 每远程图 REMOTE_IMAGE_TOKENS)、占窗口百分比、成因引用(#1188/#2609/#684)与唯一出路(减少此类图片或开新会话)。
  5. 是否有回归问题:无。上节逐项清点全部保持;高危模式(语义漂移/fail-fast 变吞错/阈值时序格式漂移)逐项过——唯一的输出变化就是声明过的新增行。
  6. 是否破坏缓存:不涉及——不改任何出站字节、账本、游标或缓存键。
  7. 是否改了设计方向:不涉及——A/B/D 根治选项仍在 #5620 待 owner 决策;本 PR 是既定的观测选项 C。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值;5% 是模块内常量 MEDIA_FLOOR_REPORT_FRACTION,与相邻的 PRESSURE_NOTE_USAGE_FRACTION 同风格。

结论:APPROVE —— 方向与既定选项 C 一致,回归清点干净,测试有牙并补齐线型覆盖;两处小问题已在本分支顺手修掉(261174a6d、7d56a01f6),无阻塞项。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

Review 完成:GitHub PR #5619(MEDIA FLOOR 观测,#5620 选项 C)判定 APPROVE——方向与既定选项 C 一致、回归清点干净(门槛未触发时输出逐字节不变、scope 视图与降级路径不受影响、无缓存/配置面变化)、测试有牙(A 行恰好钉住 f90bb0e 修的计量缺陷)。GitHub 禁止同账号自批,故以完整 review 评论载体发布判定(含八问)。
已顺手修:① src/acp-status.ts 注释与代码事实不符(声称 system sidecar 分支不可达 ctx.messages,实际会话中途 system 消息带 sidecar 留在 core 数组、谓词可命中——行为本就正确,仅注释错)+ commit 261174a;② 计数器 anthropic/responses 线型分支补 E/F 两行测试覆盖 + commit 7d56a01。本地验证 6/6 通过、tsc 干净,CI 在新 head 重跑中。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

新 head 7d56a01 复核(re-trigger):与上轮已审 head f90bb0e 的增量 = 且仅是本审核自己顺手修的两个 commit(261174a6d 注释修正、7d56a01f6 测试行 E/F),git diff --stat f90bb0e30..origin/2026-11-04_media-floor-status 核实:src/acp-status.ts 仅注释 5+/4-,tests/issue5620-media-floor-status.test.ts 纯增 41 行;无第三方推送。两 commit 推送前已本地验证(该文件 6/6 通过、tsc 干净)。完整评审与八问见上一条 review 评论,判定不变:APPROVE。CI:镜像缓存最近一次读取(fetched_at 2026-11-03T17:58Z)显示 7 success / 11 skipped、12 个 test shard 在跑、零非通过项——按惯例不轮询 gh,以该 head 的 CI 收敛为准。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

Re-trigger(head 7d56a01)复核完成:增量核实为且仅为本审核自己上轮顺手修的两个 commit(注释修正 261174a + 测试行 E/F 7d56a01),无第三方推送,判定维持 APPROVE;已在 PR 留简短复核评论。CI 镜像缓存最近读取:7 success / 11 skipped、12 shard 在跑、零非通过项,待该 head 收敛即可合入。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review 结论:当前对 master 可合并(CI 35/35 绿、MERGEABLE),但有一个必须知道的前置依赖。

设计本身扎实:独立门槛正确(PRESSURE NOTE 的 maxPending < nudgeGrowthTokens 在媒体墙会话里结构性永不满足,已复核 master @ 5dee485 src/acp-status.ts:278);billed-grade 计量(REMOTE_IMAGE_TOKENS prior)补掉了本地文本计量只看 [image] 占位符(~2 tok)永远够不到阈值的坑——正是这条报告存在的场景;正负例成对(#3617 纪律)。

顺序耦合(实测):我把它的新测试原样叠加到 #5629(kernel 根治,谓词翻转)的 head 上运行:3 pass / 3 fail。原因:它的阳性用例假设"远程 URL 图片永远不可折叠"(旧谓词),#5629 之后这类消息可折叠,MEDIA FLOOR 不再触发。结论二选一:

  1. 推荐:#5619 先合(#5618 是进行中事故,观测能力先行有价值;此时它完全自洽),#5629 随后;
  2. 若 #5629 先落:#5619 需 rebase 并把阳性行改钉真正无句柄的形状({type:"mystery"} opaque、document 块、videoMetadata-only),同时重新审视 REMOTE_IMAGE_TOKENS 计量的稳态意义(被识别的远程图家族都会变可折叠)。

两条非阻塞观察:① 报告文案 "these can never fold (#1188/#2609)" 在 #5629 落地后自动变为精确(语义收窄为真·不可恢复质量),无需改动;② mediaFloorMass 每次 acp_status 全量扫消息,O(n) 轻量,无性能问题。

This branch has not been deployed

No deployments
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