Repository navigation
[PR] fix: raise a fallback-sized codex session to bili's own model window (#7205) - #7517
Conversation
…7205) An anonymous alias (e.g. codex-auto-review) matched no window source in the native ladder, so bili kept its generic 200K anonymous default while bili's own codex-fallback path knew the model accepts 272K — every payload between the two died on bili's LOCAL 413 wall below the point the model actually accepts. codexAlignedWindow gains an opt-in canRaise (off by default, byte-identical behavior): handle.ts passes nativeFromFallback so the raise only fires when bili's number came from the generic fallback. Client-declared windows are never raised; clamping still wins; source is preserved so the #5243 headroom accounting is untouched. New 8-case pin tests/issue7205-codex-window-raise.test.ts.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11572-pr.7517.b849664This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7517.tgz
npm install -g packageInstall instructions are refreshed on each push. |
codexAlignedWindow (codex-models.js) and FALLBACK_EFFECTIVE_WINDOW_FLOOR (config.js) were imported in src/server.ts but never referenced there — the real codexAlignedWindow usage is src/server/handle.ts:17, and both modules stay loaded through other imports, so module init order is unchanged. Pre-existing on master; found while reviewing #7517.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复(机制不同),但与 open PR #7206 同修 #7205 —— 见下方「与 #7206 的关系」,这是本轮 review 最重要的发现。 标签: 已打 Review 结论:代码正确、范围收敛、测试充分,可合(合并由 owner 执行)方向(① 原 issue): 打到根因,不是治标。#7205 的本质是 回归审查(② 逐项过既有行为):
代码审查(③): 机制干净—— 测试有效性(④): 新增 8 用例,正负双向(gate 纪律 #3617):非 codex 不抬、默认关 pin(不抬,钉住 PR 前行为)、bundled-snapshot 抬 200K→272K、未知 slug 抬到 flat 272K(codex-fallback)、clamp 优先(400K→272K)、client-declared 永不抬(×2)、shipped-snapshot sentinel 200K→372K(证明用真实快照值而非硬编码 272K)、isCodexClient 前缀。 diff 整洁度(⑤): 干净——3 文件(codex-models.ts / handle.ts / 新测试),无无关改动、无空行重排。 与 #7206 的关系(重要)open PR #7206(ReineLan,2026-11-18,#7205 的报告者)也写 "Fixes #7205",但机制不同:
关键:guard 的 limit 派生自 建议:合 #7517(更完整的修复);#7206 可标 顺手修(drive-by,独立 commit)review 中发现
本地 CI 状态
中文八问
收工判定:代码正确、范围收敛、测试充分(本地 18/18 + typecheck 0),CI 0 failed(7 shard 在跑 + drive-by commit 触发新一轮)。可合;合并由 owner 执行。建议同时处理与 #7206 的冗余关系(合 #7517,#7206 标 superseded 由 owner 定)。 |
…sized 200K now adopted) The untouched-below-perception expectation predates #7205: a codex session whose base window is bili's generic fallback (200K), below codex's own knowledge (272K), is now raised to 272K instead of min-kept. In-table and operator-tuned windows are untouched, as before. (#7205)
(ai: vllm-qwen/qwen3.8-27b) 结论:3 条红 lane = 继承性 master 红(post-#7546 born-red),非本 PR 代码问题。本 PR 分支未做任何改动;待 #7558 合入后 re-merge master 即转绿。 本次运行做了什么(全部实时核实,非凭记忆):
为何不动本 PR 分支:按 CI 失败协调政策(owner policy 2026-10-24),master 红 = 继承性失败,禁止在自己分支重复修 master 级失败;修复已收敛在 #7558,本分支再修一遍是重复且会与 #7558 冲突。 下一步:#7558 合入 master 后,re-merge master 进本分支触发 CI 即转绿,后续 wake 跟进。状态已一行报到 #4599。 结构化八问:
收工判定:本次确认为继承红,本 PR 分支无需改动,状态已报 #4599;等 #7558 合并后 re-merge master 转绿。 |
2335489 to
a77ed0e
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1296-master.a9a322d # this exact build
npm install -g billion-context@master # always the newest merged build
|
…lict at 0.0.208 Master advanced 325 commits past the PR base (compress length-rejection direction #6730/#6751 -> kernel 0.0.207, codex window raise #7517, #7583 review followups, #4410 plugin-carrier judge, #7574 id-list fixes, and more). Content hunks auto-merged (kernel/src/compress.ts — the PR's frontier/cloneState hunks vs master's #6730 length-remediation in disjoint regions — tests/storage-state-fields.test.ts — the PR's pendingOrphanSweepMaxRef round-trip lines vs master's new 3-arg loadLegacyView call in the same test, and all four storage-render goldens); the only conflicts were the three kernel version lines, resolved at 0.0.208 = master's 0.0.207 + this PR's kernel/src change, per the CI-enforced kernel version discipline. Targeted local verification: tests/golden-storage-render.test.ts + tests/storage-state-fields.test.ts 7/7, kernel issue6116/issue3769/ hide-consumed suites 27/27.
这是啥问题?
宿主的 codex 会话如果一开始落在 bili 的 fallback 窗口(比如 272K 以下),之后永远不会变大:即使 bili 自己的模型窗口是 1M,这个会话也只能在旧的小窗口里压缩,白白损失上下文长度。(#7205)
根本原因
src/codex-models.ts的窗口对齐逻辑只做"向小收"(bili 窗口 < 宿主窗口时收窄),没有"向大抬":会话在 fallback 窗口建立后,对齐函数拿到 bili 的更大窗口也不会把会话抬上去。怎么修的
codexAlignedWindow(limit, model, headers, clientWindow?, canRaise = false)新增canRaise参数。src/server/handle.ts只在bili 因 fallback 拿到了小于模型真实窗口的值时传canRaise = true(nativeFromFallback),即"bili 自己降级过,才允许把会话抬回 bili 的模型窗口"。影响面
canRaise=false,老调用点原样)。测试
tests/issue7205-codex-window-raise.test.ts(8 用例:fallback 抬升、不抬 client-metadata、抬升不发 shrink 提示、isCodexClient 判定等)。codex-models.test.ts10/10、tsc --noEmit0。风险
低。抬升只发生在 bili 自己降级过的场景,且是向大不是向小(客户端看到的可用窗口变多,不会因"窗口变小"触发重发/截断类连锁)。
Refs #7205