Repository navigation
Description
Symptom
A session whose client reported a 1,000,000-token window gets its own idle-recap / subagent turns sized at 200,000, and the proxy then compresses them before forwarding:
[window] model=claude-… source=runtime-info native=1000000 … # parent request
[window] model=claude-… registry advertises 1000000 for claude-… but the request carries no
tier evidence (context-Nm beta header / [Nm] suffix) — capping at the built-in
standard 200000 (#1321) # child request
[headroom] … effective window 200000 -> 150000
context 173504 tokens reached preflight target 150000 … preflight compressing before forward
preflight still running after 30000ms grace — committed early SSE headers + keep-alive (#568)
preflight aborted (the client disconnected during preflight compression); not forwarding
Observed 3× on one host in ~2 minutes, every occurrence on a :side: id; each request spent ~60 s in preflight, paid for its summaries, and was then dropped without ever reaching the upstream. The parent conversation on the same model, same route, same second, sized correctly at 1M.
Root cause
The client mints child conversation ids for work that runs on the parent's own route+model and registers runtime-info only under the parent uuid:
- omp:
<sessionId>:side:<snowflake>for ephemeral turns,<sessionId>:side:conversation:<key>where a conversation key exists,<sessionId>:sub:<id>for subagents.
The window ladder looks the id up literally — src/server/handle.ts:744 calls pluginRuntimeInfoForConversation(runtimeConversationId(...)), which is a bare Map.get plus a model-equality guard (src/plugin.ts:603). A child id never has an entry, so runtimeWindow is undefined and resolution falls to the registry peek, capped by capRegistryWindowByStandard (src/server/context-window.ts:126) against tierGatedStandardWindow (src/config.ts:661) because the child request carries no anthropic-beta: context-Nm header and no [Nm] model suffix — the tier was negotiated for the parent, and the client has no reason to re-declare it on a child turn.
Nothing in the repo strips these client-minted suffixes; the jsdoc on pluginRuntimeInfoForConversation promises only a conversation-scoped lookup.
Minimal reproduction
Both requests carry the model, the route and the tier; only the conversation id differs.
- Register runtime-info once:
POST /__bili/plugin/runtime-infowith{ agent: "omp", model: "claude-opus-5-5", contextWindow: 1000000, conversationId: "<session-uuid>" }. POST /bili/<route>/v1/messageswithx-acp-session: <session-uuid>→[window] … source=runtime-info native=1000000;metadata.effectiveContextLimit= 1,000,000.- Same request with
x-acp-session: <session-uuid>:side:15b3f37086a59857→source=peek, capped to 200,000.
tests/side-window-inherit.test.ts (in the PR) encodes exactly this and fails on master.
Impact
- Small windows on big contexts: preflight or headroom rewrites requests the client had every right to send, burning summarizer spend.
- With a slow summarizer the client's own watchdog fires first, and the request ends as
not forwardingafter the SSE headers were already committed — a lost turn (see [Bug] Excessive preflight compression time on ultra-large contexts; client mid-disconnect causes repeated request forwar | [Bug] 超大上下文 preflight 压缩耗时过长,客户端中途断开导致请求反复无法转发 #3978 for that leg; this issue is the sizing bug that makes it reachable on a 1M route). - Same for
:sub:subagents: a subagent inherits the parent's route and model but not its window.
Workaround today: set a per-model context override (resolveConfiguredContextLimit), which ranks below runtimeWindow and therefore leaves parent sessions unchanged.
Proposed fix
pluginRuntimeInfoForConversation strips one client-minted child suffix at a time (:side:<id>, :side:conversation:<key>, :sub:<id>; bounded, since nesting is possible) and returns the nearest ancestor entry, applying the existing entry.model === model guard at whichever level answers — a child on a different model inherits nothing, and a direct hit is never overridden by a parent. No new config surface, no change to the ladder's precedence.
PR: <pr-url>
Code references (at the current master, d1b46fc0)
- window ladder / runtime lookup: https://github.com/ranxianglei/billion-context/blob/d1b46fc0/src/server/handle.ts#L744
- conversation-scoped lookup (exact
Map.get+ model guard): https://github.com/ranxianglei/billion-context/blob/d1b46fc0/src/plugin.ts#L603 - registry peek + tier cap: https://github.com/ranxianglei/billion-context/blob/d1b46fc0/src/server/handle.ts#L769 , https://github.com/ranxianglei/billion-context/blob/d1b46fc0/src/server/context-window.ts#L126 , https://github.com/ranxianglei/billion-context/blob/d1b46fc0/src/config.ts#L661
- fallback-output lookup through the same helper: https://github.com/ranxianglei/billion-context/blob/d1b46fc0/src/server/handle.ts#L2233
Activity
ranxianglei commentedon Oct 25, 2026
(ai: vllm-qwen/qwen3.8-27b)
查重: 无重复 issue(按症状/机制关键词检索 open+closed)。issue 正文已关联实现该修复的 PR #4683,未另起炉灶,直接对该 PR 做了完整审核。
标签: bug / omp / scope/wiring / p2 —— 缺陷类;实际受影响客户端是 omp;属请求管道窗口解析;有绕行(per-model context override)且主会话不受影响,不满足 p1 两类(会话不可恢复/缓存泄露)。
PR #4683 审核结论
审核基线为当前 master(
d1b46fc0);PR head1fafccf81直接基于 master、单提交、6 文件(+251/−6),diff 全部在范围内。本地已验证:新测试在 master 上失败(expected 1000000, actual 200000——正是 issue 症状)、在 PR head 通过;窗口阶梯周边 6 个相邻套件 48 例全绿;typecheck 干净。CI 全量套件运行中(回帖时 pending),以推送 head 的 CI 为准。八问:
:side:/:sub:子会话 id,但 runtime-info 只按父 uuid 上报;代理按字面 id 查窗口必然落空,落到注册表猜测值,而子请求不带 tier 证据,被 [bug] window resolution: registry 1M advertisement outranks built-in 200k standard window for claude native without context-1m beta header #1321 上限压到内置标准 200K。上报 1M 的会话于是把自己的复盘回合按 200K 预算,preflight 不必要地压缩 ~173K 上下文;summarizer 慢时客户端先放弃,回合丢失(not forwarding)。Map.get+ model 匹配检查,缺少「客户端自造子后缀」这一解析分支;tier 在父侧协商,客户端没有理由在子回合重声明——子 id 结构性命中不了 runtime-info 条目,落入会套 cap 的注册表路径。是解析分支缺失,不是配置错误也不是客户端错误。:side:<id>、:side:conversation:<key>、:sub:<id>,嵌套至多 4 层)逐层剥离,取最近的上报祖先条目;model 匹配检查仍在命中的那一层执行(换模型的子会话继承不到);直击条目永不被祖先覆盖;任何一层都不命中则回原路径(registry/[bug] window resolution: registry 1M advertisement outranks built-in 200k standard window for claude native without context-1m beta header #1321 cap 行为不变)。无新配置键,阶梯优先级顺序不变。/acpstatus 的诊断字段(子会话将显示继承条目而非 null,增量信息且更准);会话身份不变(子会话仍按自身 id 独立建键、压缩状态独立);[bug] window resolution: registry 1M advertisement outranks built-in 200k standard window for claude native without context-1m beta header #1321 cap 函数本体未动,且修复与其设计意图一致(该函数注释明确把 runtime-info 列为豁免源);阶梯顺序/缓存/时序/输出格式均无漂移。边界情形已验证并有测试钉住:空尾巴 id 不误配、无关 id 无前置误命中(e2e)、嵌套中间层 model 不匹配即止于该层(最近祖先语义,文档已载)。残留风险面:非客户端自造但恰好以:sub:<x>/:side:<x>结尾的 id 可能继承同模型祖先窗口——此类 id 原本就落注册表猜测,且有 model 门限,风险有界且保守。代码质量(外部提交从严标准):命名达意(
CHILD_CONVERSATION_SUFFIX/MAX_CHILD_CONVERSATION_DEPTH/parentConversationId)、无死代码与魔法数字、注释讲为什么、风格与既有文件一致、测试有牙(断言精确值且已验证在 master 复现失败)、TECHNICAL-NOTES 中英同步。各项通过,无需对齐重构。判定:可合(待 CI 转绿;合并权在 owner)。
fix(window): size a child conversation from its parent's runtime-info (…