Skip to content

[Bug][wiring] :side: child conversations resolve the registry/#1321 cap instead of the parent's runtime-info window #4682

Closed

Description

@Maziar123

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.

  1. Register runtime-info once: POST /__bili/plugin/runtime-info with { agent: "omp", model: "claude-opus-5-5", contextWindow: 1000000, conversationId: "<session-uuid>" }.
  2. POST /bili/<route>/v1/messages with x-acp-session: <session-uuid> → [window] … source=runtime-info native=1000000; metadata.effectiveContextLimit = 1,000,000.
  3. 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

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)

Activity

  1. ranxianglei commented on Oct 25, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (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 head 1fafccf81 直接基于 master、单提交、6 文件(+251/−6),diff 全部在范围内。本地已验证:新测试在 master 上失败(expected 1000000, actual 200000——正是 issue 症状)、在 PR head 通过;窗口阶梯周边 6 个相邻套件 48 例全绿;typecheck 干净。CI 全量套件运行中(回帖时 pending),以推送 head 的 CI 为准。

    八问:

    1. 是什么问题:omp 系客户端给闲置复盘/子代理回合自造 :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)。
    2. 什么原因导致的:会话级窗口查询函数是裸 Map.get + model 匹配检查,缺少「客户端自造子后缀」这一解析分支;tier 在父侧协商,客户端没有理由在子回合重声明——子 id 结构性命中不了 runtime-info 条目,落入会套 cap 的注册表路径。是解析分支缺失,不是配置错误也不是客户端错误。
    3. 影响范围与严重程度:仅「自造子 id + 按父 uuid 上报」的插件客户端(实证 omp);主会话不受影响。受影响回合:小窗口+大上下文 → summarizer 成本空耗;慢 summarizer 场景 → 回合丢失(约 60s/次,观测 2 分钟 3 次)。有绕行。p2。
    4. 怎么修复的:精确条目缺失时,按已知子后缀(: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 行为不变)。无新配置键,阶梯优先级顺序不变。
    5. 是否有回归问题:未发现。逐项清点:精确命中语义与修复前逐字节一致(含 model 不匹配立即返回、不上溯);父级上溯只在「无精确条目」时触发,helper 的全部 4 个消费方都过了一遍——窗口阶梯(修复目标)、两处 fallback maxOutput 查询(子会话继承父输出预算,与窗口继承自洽,同一 route+model+tier)、/acp status 的诊断字段(子会话将显示继承条目而非 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 门限,风险有界且保守。
    6. 是否破坏缓存:不涉及——前缀缓存/重试/增量游标/去重键策略均未受影响;子会话窗口修正到 1M 后不必要的压缩减少,对缓存稳定性有利。
    7. 是否改了设计方向:不涉及——纯 host 侧解析分支修复,kernel 未触碰,架构/边界/数据流不变。
    8. 是否引入新配置:无——无新 env/config/默认值(CHANGELOG 已注明「无新增配置键」)。

    代码质量(外部提交从严标准):命名达意(CHILD_CONVERSATION_SUFFIX/MAX_CHILD_CONVERSATION_DEPTH/parentConversationId)、无死代码与魔法数字、注释讲为什么、风格与既有文件一致、测试有牙(断言精确值且已验证在 master 复现失败)、TECHNICAL-NOTES 中英同步。各项通过,无需对齐重构。

    判定:可合(待 CI 转绿;合并权在 owner)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions