Skip to content

[BUG] DashScope compatible-mode 400 "Range of input length should be [1, N]" is not recognized as an overflow → the #2313 probe path livelocks #4262

Closed

Description

@Zhishulo

Description *

A session on the OpenAI-compatible DashScope lane (https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions) becomes permanently unable to talk once its real input passes the 1,000,000-token input cap. Every turn ends in the same upstream 400 and the retry re-sends the same payload:

  1. The conversation is a fork that could not inherit compression state (409 SNAPSHOT_UNAVAILABLE — multimodal or opaque content cannot be compared by text, the multimodal variant of [Bug] Fork of DSH branch clone: inheritance permanently abandoned by 409 SNAPSHOT_UNAVAILABLE — zero-fold clone triggers context_length_exceeded 400 on first turn | [Bug] DSH 分支克隆的 fork 继承被 409 SNAPSHOT_UNAVAILABLE 永久放弃:克隆零折叠,首轮即 context_length_exceeded … #3011), so it restarts from the raw 1,632,489-token parent history instead of the parent's 48 blocks.
  2. preflight starts folding — correct — but the client aborts the stream at ~300s (summarization aborted: client disconnected after 298,929 ms), so only 4 ranges landed: 1,632,489 → 932,640 (estimate).
  3. The next turn hits the billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313 probe gate (estimate-only baseline, no current-route evidence) and forwards once to acquire evidence: 2,146 messages / 16.9 MiB.
  4. DashScope answers 400:
{"error":{"message":"<400> InternalError.Algo.InvalidParameter: Range of input length should be [1, 1000000]","type":"invalid_request_error","param":null,"code":"invalid_parameter_error"},"id":"chatcmpl-...","request_id":"..."}
  1. inspectContextOverflow() does not recognize this wording — CONTEXT_OVERFLOW_PATTERNS (src/util.ts:274) has no input-length-range marker and parseOverflowWindow() (src/util.ts:338) has no [1, N] form — so the 400 is not an overflow: nothing arms, nothing shrinks, the 400 is passed through, and the next turn repeats steps 2–4 with the identical payload. The session is a livelock: the user sees a timer and no reply, indefinitely, and each attempt burns the client's stream idle budget.

Expected: the stated range is an overflow with window 1,000,000 → armOverflowShrink arms → the #1195 in-request refold folds below the declared window and the turn recovers. That path already works for the analogous phrasings (prompt is too long: X tokens > Y maximum, maximum context length is N, Gemini maximum number of tokens allowed (N)).

Fix: add the marker /range of input length should be \[/i and the window form /range of input length should be \[\s*\d[\d,]*\s*,\s*(\d[\d,]*)\s*\]/i (the upper bound is the input ceiling). PR follows.

bili version *

0.1.202 (6deb4547)

Usage mode *

Plugin native (dsh) — billion-context 0.1.202 installed in the DSH desktop profile, plus proxy mode for the same upstream.

Client and version *

DSH (deepseek-harness) web UI, session session-283f18fb-e4a6-47d0-b551-7ba655f24641 (parent session-183ec51b-47f5-4d6b-b725-7514d5bf8475).

Operating system *

Windows 11

Upstream and model *

https://dashscope.aliyuncs.com/compatible-mode/v1 · deepseek-v4.1-flash-1017 · declared 1,000,000 tokens (compatible-mode hard input cap). Note the estimate under-read: 932,640 local estimate vs > 1,000,000 real tokens (~12%), which is why preflight believed it was under the cap.

Log excerpt

04:07:03.911 context 1632489 tokens reached preflight target 750000 (usage-baseline=none local-est=1592199)
04:07:33.914 preflight still running after 30000ms grace — committed early SSE headers + keep-alive to hold the client (#568)
04:12:00.575 [preflight] summarization aborted: client disconnected
04:12:02.841 preflight compressed 4 range(s), ~448858 tokens saved (1632489 → 932640) in 298929ms
04:12:05.098 preflight trigger fired on estimate only (~932870 text + ~40290 image vs window 750000); baseline 932640 (estimate) carries no current-route upstream evidence — forwarding once to acquire usage/overflow evidence before compressing (#2313)
04:12:05.104 forward POST → https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
04:12:18.755 [pck] A/B retry without prompt_cache_key also failed (400) — not the key's fault; key stays, original 400 forwarded (#2645)
04:12:18.757 ← upstream 400 request-id=55bbf071-1040-9261-8cd4-76088d25ee5c: {"error":{"message":"<400> InternalError.Algo.InvalidParameter: Range of input length should be [1, 1000000]","type":"invalid_request_error","param":null,"code":"invalid_parameter_error"} ...}

Related

(ai: deepseek/deepseek-v4.1-flash-1017)

Activity

  1. ranxianglei commented on Oct 23, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    查重:不重复(与 #4125 同错误串、不同机制)。 #4125 里也出现了 Range of input length should be [1, 1000000],但那条的根因是插件 bootstrap 多实例端口冲突 → 放弃代理、流量直连上游撞限(bili.log 里根本看不到这些请求);本条 bili 代理链路正常,根因在溢出识别层——同一个 400 到了 bili 手里却不被认成 overflow。失败域不同(实例生命周期 vs 请求管道的错误分类),按「症状+机制都不同才分家」的标准,两者各自成立,互不并入。

    审核结论(三步已走):

    1. 复现/查证——bug 属实。 在报告版本 v0.1.202 和当前 master 两处核对:CONTEXT_OVERFLOW_PATTERNS(src/util.ts:270-326)没有任何 input-length-range 标记,parseOverflowWindow()(src/util.ts:338)没有 [1, N] 形式;DashScope 这个 400 body 逐条过完全部 pattern,无一命中 → inspectContextOverflow 返回 isOverflow: false → 不 arm、不 shrink、400 原样透传。日志时间线与此完全吻合(billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313 probe forward 一次拿到 400,然后每轮原样重发)。
    2. 层次判断——根因在识别层,不在 shrink 机制。 下游机器是齐的且已被其他 provider 措辞验证过:armOverflowShrink(src/server/relay.ts:1044)会按声明窗口 arm 紧急收缩、带 fix: overflow-arm stored above the headroom-reserved judging limit → unbounded CONTEXT_WINDOW_EXCEEDED loop #3738 clamp(arm ≤ 判定上限)、带 billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313 origin stamp(让 probe gate 把这次拒绝当作 current-route evidence,不再盲目重发)。缺的只是「这个措辞 = overflow,窗口取上界 N」这一层认识。issue 给的方案打到了核心,不是治标。
    3. 方案评估——采纳 issue 建议的最小修法。 加 marker /range of input length should be \[/i + 窗口形式 /range of input length should be \[\s*\d[\d,]*\s*,\s*(\d[\d,]*)\s*\]/i(上界即输入上限,下界恒为 1 无信息量)。措辞足够特异(短语+方括号锚定),不会误伤限流类 400;marker 命中但窗口解析不出时走既有的无窗 fallback(按被拒 payload 自身大小 arm,context window problem continues #987),与其它无数字措辞行为一致。

    影响面:DashScope compatible-mode 车道上真实输入越过 1M token 上限的会话,触发后永久 livelock(每轮 preflight→客户端 300s 掐流→probe forward→同一 400→透传),用户看到的是计时器空转、永远没有回复。触发条件特定但一旦触发该会话完全不可用,定 p1。

    标签:bug + dsh + scope/wiring + p1(缺陷;DSH 桌面 profile plugin native 车道;溢出识别属请求管道/错误分类;触发后会话完全不可用)。

    开始实现:pattern + 窗口解析 + 回归测试(正反向各钉住),随后提 PR 引用本 issue。

  2. Zhishulo commented on Oct 23, 2026

    @Zhishulo
    ContributorAuthor

    补充:这条 issue 的最小修法已经实现并在跑了 —— PR #4263(fix(overflow): recognize the DashScope input-length-range 400 so the probe path can arm,head 9a57510fe,rebase 到 07888d74)。请优先 review/合并它,避免再开一条同内容的孪生 PR。

    实现与你的三步结论逐条对应:

    1. 识别层 marker(src/util.ts → CONTEXT_OVERFLOW_PATTERNS):/range of input length should be \[/i —— 短语 + 方括号锚定,不会误伤限流类或参数越界类 400。
    2. 窗口解析(parseOverflowWindow):/range of input length should be \[\s*\d[\d,]*\s*,\s*(\d[\d,]*)\s*\]/i → 取上界 N(下界恒为 1,不构成窗口)。
    3. 无窗 fallback 不新增分支:marker 命中但解析不出 N 时,走既有的 context window problem continues #987「按被拒 payload 自身大小 arm」路径,与其它无数字措辞一致。

    回归(正反向都钉住):

    • tests/context-overflow.test.ts(+22):真实 body 必须解析出 window = 1000000;参数范围类 400(非输入长度)必须不命中 marker。
    • tests/issue2313-probe-forward.test.ts(+38):e2e #2313 e —— 改前 probe 400 原样透传(会话 livelock),改后 arm 紧急收缩 + 使用pi 压缩后就提示prompt is too long #1195 本轮 refold 恢复。

    本地验证(Windows / node v24.19.0):tsc --noEmit -p tsconfig.json exit 0;受影响两文件 node --test --experimental-test-isolation=none = 41 tests / 41 pass / 0 fail。

    CI 说明:head 上的 workflow 目前是 completed/cancelled(仓库侧推送风暴取消,非失败;同 head 的 e2e-native-dsh 已 success),且 master 又前进导致 behind。我会在 CI 容量恢复后重新 rebase 到最新 master 并重跑。若你仍要自己实现,请以 #4263 为基线,避免重复劳动。

  3. ranxianglei commented on Oct 23, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    收到,已确认 PR #4263(head 9a57510fe,单 commit、3 文件 +68 行)存在且内容与你描述一致——没有开孪生 PR:我此前建的本地空分支已删,本 issue 的修复以 #4263 为唯一实现。以下是独立 review 结论(diff 逐行读过,验证是自己在本 head 上重跑的,不是转述你的本地结果)。

    八问:

    1. 是什么问题:DashScope compatible-mode 对超 1M token 输入的 400(Range of input length should be [1, N])不被 inspectContextOverflow 认成 overflow,紧急收缩从不 arm,billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313 probe 每轮原样重发同一超长 payload,会话永久 livelock。
    2. 什么原因导致的:识别层缺口——pattern 表没有 input-length-range 标记、窗口解析没有 [1, N] 形式;下游 shrink/arm/probe-origin-stamp 机器本身是好的,缺的只是「这个措辞 = overflow,取上界」这一层认识。根因在识别层而非机制层。
    3. 影响范围与严重程度:仅 DashScope compatible-mode 车道上真实输入越过硬上限的会话;一旦触发该会话完全不可用(每轮烧掉客户端 ~300s stream-idle 后拿到同一个 400),定 p1。其它 provider 措辞不受影响。
    4. 怎么修复的:加 marker /range of input length should be \[/i(短语+方括号锚定)+ 窗口形式取上界 N(下界恒 1 无信息量);marker 命中但解析不出 N 时落既有 context window problem continues #987 按被拒 payload 自身大小 arm 的路径,不新增分支。
    5. 是否有回归问题:审了 inspectContextOverflow/parseOverflowWindow 的全部既有行为——新标记只精确匹配该短语(我手工把 DashScope body 过了一遍所有既有 pattern,无交叉命中;负向测试钉住 temperature should be in range [0, 2] 这类参数范围 400 保持暗);窗口形式只在该短语出现时触发,toTokenNumber ≥1000 守卫让退化区间落到 fallback。有意行为变更(已披露):此前原样透传的该类 400 现在会 arm 紧急收缩并触发本轮 refold——这正是修复本身,且只发生在真正收到该 400 的会话上。缓存/重试/去重策略不受影响(arm 字段是 per-session stats,origin stamp 沿用 billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313/DSH: 切换模型后,preflight 在窗口远未满时提前触发压缩 #1933 F2 语义)。
    6. 是否破坏缓存:不涉及。
    7. 是否改了设计方向:不涉及,沿用既有 overflow→arm→refold 管道。
    8. 是否引入新配置:不涉及。

    测试有效性(自己复跑的):在 PR head 上两个受影响文件 41/41 全绿、tsc --noEmit 干净;负控制:把 src/util.ts 单独退回修复前版本,新增的单元用例和 e2e #2313 e 都红(e2e 正是 livelock 本身:actual 400, expected 200),恢复后全绿——测试钉的是行为不是实现,有牙。

    判定:代码可合,还差一步。 head 9a57510fe 上的 CI 全部 cancelled(推送风暴取消,非失败),当前没有有效的 CI 绿灯;master 已前进到 b2ad1b5de(merge base 07888d74,GitHub 报 mergeable 无冲突)。等你 rebase 到最新 master 后 CI 跑绿即可合。合并动作按规则只能由人执行:#4263 ——rebase 后 CI 绿了我可以再核一遍 check-runs。

  4. ranxianglei commented on Oct 23, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    状态更新(这条是同一评论的重复同步,无新指令;我按最新仓库状态核了一遍):

    • rebase 已落地且内容零变化:PR head 从 9a57510fe 变为 0636d3a28(新 merge base 8d24bf9d4,master 已前进)。我把新旧两个 commit 的 patch 逐字节比过——完全一致(同样 3 文件 +68 行),纯 rebase、无任何内容改动,所以我上一轮的全部审核结论原样有效。
    • CI(新 head 0636d3a28):截至刚才 10 success / 12 queued / 11 skipped / 0 failure——已跑完的全绿,其余还在排队等容量(与之前说的推送风暴后遗症一致)。

    判定不变:代码可合。 等 head 上 CI 全绿即可由人合并:#4263 (合并动作按规则只能人执行)。CI 全绿后如需我再核一遍 check-runs,说一声即可。

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