Skip to content

[PR] fix: annotate the output-headroom effective window on every denominator surface - #4138

Open
ranxianglei wants to merge 2 commits into
masterfrom
2026-10-21_headroom-denominator-note
Open

ranxianglei wants to merge 2 commits into
masterfrom
2026-10-21_headroom-denominator-note

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #4130

What was wrong

The compression engine judges against the effective window (declared window − output-headroom reservation, #896/#2096), but every persistent display surface showed that denominator bare. A 200K model judging at 150K read as a misidentified window — three rounds of misdiagnosis in the field before the relationship between the card's 200K, the [window] base=200000 line and the panel's 150K could be established from a one-shot deduped [headroom] log line nobody had noticed.

Fix (display-only, single source of truth)

handle() records the declared pre-reservation window in session.metadata.outputHeadroomBase at the same instant it writes effectiveContextLimit (one writer, all modes); it clears the field whenever no reservation is active, so a model/protocol switch never shows a stale annotation. Every surface annotates from that field:

Surface Before After
nudge log line usage=44% (65256/150000) usage=44% (65256/150000, window 200000 − output reserve 50000)
/acp panel Context (...): 45% (89K / 150K) + before-footer line Window: judging against 150K effective (200K declared − 50K output reserve) (human-only slot, LLM-context stripper unaffected)
Web UI session bar 89K / 150K (45%) + sub-line 窗口 200K − 输出预留 50K (zh/en i18n)
session report MD/SVG - context: 89K / 150K (45%) + (window 200K − output reserve 50K) note
JSON APIs — additive contextWindowBase on /__bili/plugin/status and admin session stats

The denominators themselves are unchanged — they ARE the values the kernel judges against; only the relationship to the declared window becomes visible.

Behavior changes (disclosed)

  • Nudge log line format: gains one extra comma-separated segment inside the usage parentheses, and ONLY while an output-headroom reservation is active for the session's current model. No reservation → byte-identical legacy line (pinned by test).
  • /acp panel: gains one human-only line in the existing before-footer slot under the same conditions; the box borders/stripper anchors are untouched.
  • JSON surfaces: purely additive fields (contextWindowBase, null/absent when no reservation).
  • No compression behavior change: reserveOutputHeadroom, the nudge/preflight math, the outgoing max_tokens clamp (plugin mode: no hard backstop when the agent ignores the compress nudge — context grows past the window and upstream 400s #453 guarantee) and the kernel are all untouched.

Config surface

None added, renamed or re-semantics'd. compress.outputHeadroomMaxPct keeps its existing meaning; this PR only makes its effect visible.

Tests

New tests/issue4130-headroom-denominator.test.ts (reuses the #2096 hermetic harness):

  • unit: nudge-line annotation present ⇔ reservation active, exact math, legacy shape preserved;
  • unit: outputHeadroomBase guard rejects non-number/NaN/missing;
  • e2e: reserved request writes the base (web projection shows contextWindow: 75000, contextWindowBase: 100000), a reservation-less request on the same session clears both (stale-annotation regression pin).

Local verification on rebased head: typecheck clean; targeted suites green (issue4130, session-report, web-sessions, issue2096-clamp-headroom-window, headroom-output-fallback — 49/49). Full-suite verdict from CI.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-21_headroom-denominator-note (18a8570)

Option A — Install this exact build (recommended)

npm install -g [email protected]

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-pr4138.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: annotate the output-headroom effective window on every denominator surface [PR] fix: annotate the output-headroom effective window on every denominator surface Oct 21, 2026
@ranxianglei
ranxianglei force-pushed the 2026-10-21_headroom-denominator-note branch from 57fc8b5 to cfb2ef1 Compare October 23, 2026 07:00
@ranxianglei ranxianglei added bug Something isn't working dsh p3 scope/ui labels Oct 23, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 与 output-headroom 家族的在途/已关条目机制不同——#4236/#4198/#4184 改的是「预留多少」的计算(且 #4184 已被 revert),#3328 钉的是判压分母本身,#3850 只改 [headroom] 日志里的配置键名;本 PR 不动任何预留数学,只在展示面把「有效窗口 = 声明窗口 − 输出预留」的关系标出来(症状:面板/日志分母被误读为窗口识别错;机制:缺关系标注)。与 #4130 是同一问题的修复,PR 正文已 Closes。

标签: bug / dsh / scope/ui / p3(纯展示面澄清缺陷,无功能影响,沿用 #4130 定级)

审核进行中,先报状态:

  • PR 原 head 57fc8b508 基于 v0.1.203(0e0803a78),落后 master 149 个提交且触碰热文件(server.ts/plugin.ts/web/*),按纪律先 rebase 到当前 master 再下结论。Rebase 零冲突,diff 逐文件 stat 不变(13 files, +220/−13)。
  • Rebased head cfb2ef125 本地预检:typecheck 干净、build 通过、定向套件(issue4130-headroom-denominator / session-report / web-sessions / issue2096-clamp-headroom-window / headroom-output-fallback)49/49 绿。已推回 PR 分支,C I 全量结果以新 head 为准。
  • 代码已通读:单写者(handle.ts 在写 effectiveContextLimit 同一瞬间写/clear outputHeadroomBase)、各展示面从同一字段渲染、无预留时字节级回退旧格式(有测试钉住)。

CI 出新 head 结果后我按八问体例给最终结论。

…or surface (#4130)

The compression engine judges against the effective window (declared window
minus the output-headroom reservation, #896), but every persistent display
surface showed that denominator bare — a 200K model judging at 150K read as a
misidentified window (three rounds of misdiagnosis in the field, #4130).

handle() now records the declared pre-reservation window in
session.metadata.outputHeadroomBase (cleared when no reservation is active, so
a model/protocol switch never shows a stale note); one writer, all modes.
The surfaces annotate from that single source:

- nudge log line: usage=44% (65256/150000, window 200000 − output reserve 50000)
- /acp panel: before-footer line 'Window: judging against 150K effective
  (200K declared − 50K output reserve)' + additive contextWindowBase JSON field
- Web UI session bar: sub-line 'window 200K − output reserve 50K' (+ zh/en i18n)
- session report MD/SVG: same note after the context fraction
- admin stats JSON: additive contextWindowBase

Display-only: the kernel keeps judging against the effective value; no config
surface added, no behavior change to compression.
@ranxianglei
ranxianglei force-pushed the 2026-10-21_headroom-denominator-note branch from cfb2ef1 to 1d77e5a Compare October 23, 2026 08:47
#4393 added a second top-level concurrency: block without noticing the
owner-approved one already present further down (skip-scoped labeled runs,
schedule-safe cancel-in-progress). The duplicate key makes the file fail
GitHub's parser ('concurrency' is already defined), so NO main-CI run
starts on any branch or on master since the merge — zero workflow runs on
master commit 970bd4d. The pre-existing block already delivers #4393's
goal (same-ref supersede cancellation), so the redundant block goes.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

中途更新:发现并顺手修掉一个刚合入 master 的 CI 回归(#4393 遗留),本 PR 已带上修复 commit,等 CI 出全量结论后发八问收尾。

发现了什么:#4393(ci-concurrency-dedup,今天合入 master)在 ci.yml 顶部加了一个新的顶层 concurrency: 块,但没注意到文件下方已经有一个 owner 批准过的 concurrency: 块(带 #3772 的 labeled-skip 分组和 #3331 的 schedule 豁免)。重复的顶层 key 让 GitHub 解析器直接拒绝整个文件(422: 'concurrency' is already defined),后果是:#4393 合入之后,主 CI 工作流在任何分支、包括 master 本身上都起不来——master 合并提交自己的 push 运行就是 0 job 的解析失败,各 PR 的 synchronize 运行也全部不出现。这正是本 PR 之前几轮「CI 排队数小时/被连环取消」的真正原因之一。

怎么修的:本分支新增独立标注 commit 18a85706a(fix(ci): drop duplicate concurrency key ...),只删那 8 行冗余块。保留的原有块本来就实现了 #4393 想要的行为(同 ref 新 push 取消旧运行,group 含 ref + cancel-in-progress,schedule 除外),所以删掉的是纯冗余+破坏项,YAML 已本地校验为单一合法 concurrency 键。没有决策依赖,按「CI 红几行级小修在当前 PR 顺手修」纪律处理;随本 PR 合入即恢复 master 的主 CI。

当前状态:PR 头 18a85706a(rebase 到最新 master + ci.yml 修复);typecheck/build/定向套件(issue4130 等 49/49)在 rebase 后重跑全绿;pull_request 触发的 CI 运行(run 39928090851)已在队中——今天仓库有 458 个排队运行的 runner 拥塞,预计要等一阵。绿了我就发最终八问 + 合并判定。

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

bug Something isn't working dsh p3 scope/ui

Projects

None yet

1 participant