You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Once the context reaches 800k, the model can no longer call tools. | 上下文涨到 80w 后模型无法调用工具 #6402
changed the title [-]上下文涨到 80w 后模型无法调用工具[/-][+]Once the context reaches 800k, the model can no longer call tools. | 上下文涨到 80w 后模型无法调用工具[/+]on Nov 12, 2026
主会话session-d685b99a(3983–4019 msgs,inbound 7.8MiB,outbound ~320KiB/~90K tokens)→ 成功(acp-usage input=85K–96K,cache hit 100%)。
persona 子会话session-d685b99a|sub:1ee45271ed060930(1 msg,inbound=outbound=2.8MiB/~792K tokens)→ 上游 400:"This model's maximum context length is 1048576 tokens. However, you requested 1048856 tokens (792856 in the messages, 256000 in the completion)."
persona 子会话(|sub:<fp>)是 dsh 的辅助 persona(KDD #9:同 conversation id 下不同 system prompt 自动分裂)。日志显示它只有 1 条 user 消息、2.8MiB、无 tools——这与 dsh 的 prompt-enhance sidecar(#5656:"请重写以下提示词…")形状一致:把完整对话历史塞进单条 user blob 发给模型重写。
Activity
[-]上下文涨到 80w 后模型无法调用工具[/-][+]Once the context reaches 800k, the model can no longer call tools. | 上下文涨到 80w 后模型无法调用工具[/+]ranxianglei commentedon Nov 12, 2026
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)
查重:不重复。 检索了 open + closed 的 issue 和 PR(关键词:context 80w tool call fail / sidecar overflow / persona sub session overflow 400 / preflight no compressible),无匹配项。
初步分析(基于日志
billion-context-full-log (10).txt,v0.1.212→0.1.213,model=deepseek-flash,upstream window=1048576,completion reservation=256000,bili effective window=792576):1. 主会话正常,persona 子会话溢出
日志里每个 turn 有两类请求:
session-d685b99a(3983–4019 msgs,inbound 7.8MiB,outbound ~320KiB/~90K tokens)→ 成功(acp-usage input=85K–96K,cache hit 100%)。session-d685b99a|sub:1ee45271ed060930(1 msg,inbound=outbound=2.8MiB/~792K tokens)→ 上游 400:"This model's maximum context length is 1048576 tokens. However, you requested 1048856 tokens (792856 in the messages, 256000 in the completion)."persona 子会话的 payload 每 turn 递增:792856 → 793547 → 793769 → …,始终超 792576 窗口。
2. preflight 判定"payload fits"但实际超窗 272 tokens
日志关键行:
preflight 的校准估计(792848)超窗 272 tokens,但
fits判定(src/server.ts:4403:estimateCoreMessages + overheadEstimate + imageTokens < limit)用了另一套估计值,判定为 fits → 转发 → 上游 400。3. 为什么 persona 子会话是 792K tokens 的单条消息
persona 子会话(
|sub:<fp>)是 dsh 的辅助 persona(KDD #9:同 conversation id 下不同 system prompt 自动分裂)。日志显示它只有 1 条 user 消息、2.8MiB、无 tools——这与 dsh 的 prompt-enhance sidecar(#5656:"请重写以下提示词…")形状一致:把完整对话历史塞进单条 user blob 发给模型重写。但
isDshSingleShotSidecar(src/server/side-request.ts:203)没有识别它为 sidecar,所以它走了主车道(processTurn + preflight)而不是 side 车道(passthrough + guard)。side 车道的sideRequestGuard会做本地估计并 fail-fast(413),但主车道的 preflight 在"0 viable range(s)"时 fail-open(转发)。4. 用户感知的"模型无法调用工具"
主会话(真实对话)是成功的,模型能响应。persona 子会话(prompt-enhance)失败。dsh 工作流里 prompt-enhance 失败可能导致宿主显示错误或阻断后续 turn——需要确认 dsh 侧的行为。
待确认:
修复方向(初步):
isDshSingleShotSidecar识别这种 full-context 单条消息的 persona sidecar,走 side 车道 + guard(fail-fast 413 而不是转发 400)。fits判定与校准估计不一致的问题(src/server.ts:4403vs preflight 的calibratedPayload)。继续深入分析中,有结论会更新。
ranxianglei commentedon Nov 12, 2026
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)
进度更新(上一轮分析被卡住重启,本轮继续):
已完成:
|sub:1ee45271ed060930)每 turn 发 2.8MiB 单条消息 → 上游 400fits判定与校准估计不一致的代码路径(src/server.ts:4403vscalibratedPayload)isDshSingleShotSidecar要求requestAgent !== "main",src/server/handle.ts:2543)当前正在做:
x-bili-request-agent: main还是不带该 header(决定走主车道还是 side 车道)fits判定对齐 / sidecar 检测扩展 / 0-viable-ranges fail-fast需要确认(@Dog):
继续分析中,有修复 PR 会更新。
ranxianglei commentedon Nov 12, 2026
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)
查重: 不重复。 检索了 open + closed issue 和 PR("context 80w tool call fail"、"sidecar overflow 400"、"persona sub session overflow"、"preflight no compressible"),无匹配。PR #5899(fixes #5880)是同一故障域(anthropic-wire + wrapper provider + 贴墙 → 400)的另外两个独立缺陷——(A) overflow-arm 证据降级 + (B) anthropic 车道缺出站 clamp。本 PR 修的是 (C) preflight fits 检查口径不一致。
PR: #6460
标签: bug / p1 / dsh / scope/wiring(缺陷类;请求管道接线域;受影响用户每轮硬 400 停摆 = 会话不可用)。
结构化八问
是什么问题: 上下文涨到 80w 后,preflight 压缩触发但找不到可压缩范围时,bili 仍然把请求转发出去,被上游硬拒 400 CONTEXT_WINDOW_EXCEEDED——模型无法调用工具,会话停摆。
什么原因导致的: preflight 的触发判定用校准后估算(calibratedPayload),但压缩失败后的 fits 检查用未校准估算(estimateCoreMessages + overhead + imageTokens)。当校准因子 k̂ > 1(本地估算器低估)时,校准后 > 未校准,触发条件满足(calibrated ≥ limit)但 fits 说放得下(uncalibrated < limit)→ 转发了一个必然 400 的请求。日志证据: "context 792848 tokens reached preflight target 792576 (… k̂=1.18); preflight compressing before forward" → "round 1/16: 0 viable range(s)" → "preflight made no progress but the payload fits; forwarding as-is" → 400。
影响范围与严重程度: 受影响面 = k̂ > 1 的会话(本地估算器低估,代码密集内容常见)+ preflight 触发但 0 可压缩范围 + 贴墙。命中时会话完全不可用(每轮 400),p1。
怎么修复的: fits 检查改用与触发判定相同的校准后估算(calibratedPayload < limit),与 if 分支(压缩成功时用 rebuiltCalibrated < limit)口径一致。校准后超窗且无压缩可做 → 413 fail-fast,不再转发必然 400 的请求。
是否有回归问题: k̂ ≤ 1 的会话不受影响(校准后 ≤ 未校准,旧检查已经保守)。k̂ > 1 且 preflight 触发 + 0 可压缩范围的会话:旧行为 = 转发 → 400;新行为 = 413 fail-fast。这是有意变更(从"转发必然失败"变为"本地快速失败"),已在 PR 正文披露。
是否破坏缓存: 不涉及。
是否改了设计方向: 不涉及。纯修口径不一致,不引入新模式。
是否引入了新的配置: 不涉及。
收工判定: 修复已提交,PR #6460 已开,标签已打,等 CI 绿 + 人审合并。