Repository navigation
[PR] fix: reserve output headroom by route, not wire — caliber split (redo of reverted #4184) - #4236
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.5034-pr.4236.05d187aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4236.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本 PR 是 #4184(已被 #4198 回滚)的重做,针对 #4205 的在途修复仅此一条,无并行工作。 标签: 审查进展(进行中):
|
(ai: vllm-qwen/qwen3.8-27b) Review 完成,CI 全绿(head cc77646:34 success / 16 skipped-gated / 0 fail)。可合并。 结构化八问:
行为变更披露(旧→新):
新发现已立项:#4239 —— #282 回退下限在输出预留之后生效,会把任何 <100K 的回退基线抬到高于声明值(日志可见 合并判定:代码审查通过(调用点审计完整、双压缩模式均已推演、测试真值表双向覆盖符合 #3617),CI 在 cc77646 全绿,建议合并(合并操作归你)。提醒:#3973 的测试断言在本 PR 合并后需一行 rebase 调整( |
The caliber split moves metadata.effectiveContextLimit to the UNRESERVED window N on every display surface; the reserved band now lives in metadata.reservedContextLimit. The three #1531 subtests in tests/runtime-info.test.ts still pinned the reserved values (229376 / 983040 / 90000) on the plugin status contextLimit field, red-lining CI shard test (ubuntu-latest, 22, 3) with '262144 !== 229376'. Update the expectations to N (262144 / 1048576 / 100000); the entry-wins discriminating power of each subtest is kept (agent-slot 100000 vs conv 262144).
…ix (#4205) Bare-path /v1/messages requests missed the routes table, fell back to the option-level window, and read as fallback-derived — where the #282 floor lifts any reserved sub-100K window to 100K. Once anthropic wrapper routes reserve output headroom (#4205), that dilution pushed the control-arm usage from ~84% down to 42%, out of the >=75% pressure band these tests exercise. Routing through the zero-config prefix makes the declared routes-table window authoritative (source=configured, no floor). Complements 6ca565b (runtime-info status-surface alignment).
cc77646 to
1750866
Compare
|
(ai: vllm-qwen/qwen3.8-27b) 已 rebase 到 master@07888d74 并强推到本分支(cc77646 → 1750866),4 个 commit 全部保留。 冲突解法(逐文件)src/ 全部无冲突,PR 语义原样保留:
tests/ 4 个 golden 文件冲突(唯一冲突点,commit 2):
已丢弃/无对应丢弃的 hunk无丢弃。全部冲突只有 golden digest 一类,按上述重新生成解决;没有发现「PR hunk 已在 master 等价存在」需要丢弃的情况(PR diff 与 master 的最终差异 = 原 PR diff 内容,仅行号漂移 + golden digest 值变化)。 本地验证
全量判定看 CI test lanes。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.767-master.924b852 # this exact build
npm install -g billion-context@master # always the newest merged build
|
(ai: vllm-qwen/qwen3.8-27b) rebase 收尾独立复核完成——冲突已解、PR 已合入 master 并发布,任务闭环。以下结论是本轮对远端逐项重新验证的结果(不是转述上面的 rebase 报告): 独立核对(全部通过):
结构化八问:
CI 实况(如实记录):全量绿的基线在 rebase 前的 head 收工判定:冲突处理完成,PR 已合入 master 并已发布 master 构建,无遗留项,本任务闭环。 |
(ai: vllm-qwen/qwen3.8-27b)
Closes #4205
Refs: #3900 (original bug), #4184 (first attempt, reverted), #4198 (revert), #3973 (companion PR), #3837 (caliber discussion)
What this PR does
Re-lands output-headroom reservation for all wires — reverted by #4198 after #4184 landed red — and fixes both defects #4205 calls out: the test fallout and the global-boolean exemption.
1. Exemption decided per-route, not per-wire
shouldReserveOutputHeadroom(protocol)becomesshouldReserveOutputHeadroom(protocol, origin, modelId). Reservation happens by default everywhere; the anthropic wire is exempt only with positive separate-output-budget evidence:api.anthropic.com, orclaude-(covers Bedrock/Vertex/other fronts).Wrapper routes that bill completion INTO the window (the #3900 shape: DeepSeek
/anthropicservingDeepSeek-V3.2-Exp) have no such evidence and reserve like every other wire. This replaces the global boolean #4184 introduced (which shifted every real-Claude band down by maxOutput for no safety gain — #3900 thread analysis) while still fixing the wrapper class. #3973 composes above this: once a session has a PROVEN completion share from an overflow, its override can exempt a real-Claude route this heuristic cannot see.2. Caliber split: display N, decide R
metadata.effectiveContextLimitagain records the UNRESERVED window N (post self-heal) — what the status panel / acp_status / admin / web surfaces show. A new per-request fieldmetadata.reservedContextLimitrecords R = the window the kernel actually judges against (post headroom), and every decision consumer reads it (relay judging limit / #3738 arm, no-window overflow arm, side-lane guard call site).reqConfig.modelContextLimitstill carries R into the kernel/preflight paths — no kernel change. Fork inheritance copies both fields. The[headroom]log keeps printing both numbers (effective window N -> R (reserved …)), matching the #3837 caliber discussion.Behavior changes (old → new)
effectiveContextLimiton non-anthropic wires (panel/acp_status/web)reserveHeadroomflag; guard stays pure mechanicsNo
kernel/changes. Config surface: nothing added — no new config key, env var, or CLI flag; the reservation cap stayscompress.outputHeadroomMaxPct(default 0.25).Tests
tests/context-overflow.test.ts: protocol-gate test replaced by a 10-row truth table (both directions, Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617): openai/responses/google/undefined reserve; bare anthropic reserves; api.deepseek.com reserves; api.anthropic.com + claude-* exempts; loopback + claude-test exempts; DeepSeek-V3.2-Exp reserves; suffix-attack hostnameapi.anthropic.com.evil.examplereserves.tests/side-request-isolation.test.ts: openai rows pass explicitreserveHeadroom=true; three new wrapper-anthropic rows pin the reserved-limit math plus block/pass boundaries.tests/fix-arm-headroom-clamp.test.ts: judging-limit read switched toreservedContextLimit(falls back toeffectiveContextLimitfor legacy persisted sessions).tests/issue4205-output-headroom-caliber.test.ts: wire-mode e2e pinning (a) dual metadata fields (N=100000 / R=80000 at max_tokens=20000), (b) claude-x route exempt (R=N), (c) A/B [BUG] acp-proxy upstream HTTP 400: Request with 1,198,269 tokens exceeds the model's 1,048,576 token limit, consistently | [BUG] acp-proxy upstream HTTP 400:请求 1,198,269 tokens 超过模型上限 1,048,576,一直复现——是插件压缩未生效,还是 DSH 的问题? #3900-class: identical ~92K-token payload — the wrapper model gets a LOCAL fail-fast (413/502) with the doomed body never forwarded as a main-lane request (upstream main-call count stays 1), while the claude-x control forwards and succeeds (200).gpt-golden-acarries no separate-budget evidence on any of the four lanes, so every lane now records the newreservedContextLimitfield and the pre-reserving lanes moveeffectiveContextLimitback to the unreserved window.tests/fork-nudge-deadzone.test.ts: the nudge-log line filter now skips[headroom]lines (they contain the word "nudge"); the fixture deliberately stays a reserving route.The whole family that went red under #4184 — codex-window-align, bridge, sideRequestGuard, the registry/window suites, the #3900 e2e pair — is green WITHOUT modification; 188 targeted tests green locally including the side-lane e2e set. Full-suite verdict: CI.
CI
Green before merge — requirement 4 of #4205. #4184 landing red was a process incident; this PR does not merge on red checks.
Note for #3973
#3973 (proven completion-wall persistence) composes above this PR: its override sits at the same call sites and can exempt a real-Claude route this heuristic cannot see. Its test currently expects
effectiveContextLimit === R; after rebasing onto this PR that assertion moves toreservedContextLimit === R(one-line tweak). Suggested order: merge this first, rebase #3973 second.