Skip to content

[PR] fix: recognize Chinese relay overflow wording in the context-overflow detector (#3240) - #3246

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-15_chinese-overflow-markers
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-15_chinese-overflow-markers

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #3240

背景

b-c-pi#639 迁移至此:pi + 中转站 API 报错后,上下文长度一直算错。在 master 上逐条复核后:

  • 路径 B(溢出自愈标记只认英文)= 本仓库真实缺陷:CONTEXT_OVERFLOW_PATTERNS(src/util.ts)全部是英文措辞,中文中转站错误(「上下文长度超出限制」「输入长度超过模型支持的最大上下文」等)一个都不命中 → 使用pi 压缩后就提示prompt is too long #1195 同请求 refold 与 context window problem continues #987 紧急收缩武装都不触发 → 会话每轮原样重发同一个超窗 body、反复吃 400。本 PR 修这个。
  • 路径 A(contextWindow 缺失回退 150k):b-c-pi 的 FALLBACK_LIMIT=150_000 在本仓库不存在;bili 的窗口解析链(beta 头 > [Nm] 后缀 > 插件报告 > launcher > providers 声明 > 注册表 > 内置表 > 默认 200k)已覆盖声明路径,且 context window problem continues #987 的设计立场是「窗口归声明所有、永不从流量学习」。pi 模型配置或 providers 里声明 contextWindow 即解决——无代码改动,判定与配置解法详见 issue 回复。

改动

  1. src/util.ts CONTEXT_OVERFLOW_PATTERNS:新增 5 条中文溢出措辞,均要求方向词(超出/超过/超限/过长/超长),防止仅提及 上下文/token 的无关 400(鉴权过期、限流、格式错误)误触发自愈。
  2. tests/context-overflow.test.ts:新增 3 个回归用例——正例(6 种措辞,全部断言 window === undefined,钉住不学错数字)、5xx+中文标记组合(超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484 门禁同样适用)、反例(5 种非溢出中文错误必须不命中)。

行为变更(旧 → 新)

旧:上游返回带中文溢出措辞的 400/413/5xx → 检测器判非溢出 → 原样透传、不武装、不 refold,会话卡死循环。
新:同类措辞 → 判为溢出 → 按 payload 尺寸武装紧急收缩 + 尝试同请求 refold(#1195)。错误正文不带数字时仍学不到精确窗口(遗留项:等报告者补报错原文后按实际格式给 parseOverflowWindow 补数字提取,见 issue 评论跟踪)。英文行为不变。

验证

本地定向:tests/context-overflow.test.ts 28/28、tests/side-request-isolation.test.ts + tests/issue2484-overflow-and-summary.test.ts 27/27、typecheck clean。全量回归交 CI。

Config surface: N/A(未增改任何配置字段)。

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_chinese-overflow-markers (bcd039f)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3740-pr.3246.9449b27

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3246.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到。这是本仓库在 #3240 分析后提交的修复 PR(我此前会话的工作),现在按 PR 审核规范独立复审:拉分支核对代码、本地定向验证、查 CI,结论按八问体例回复。

查重:不重复——本 PR 就是 #3240(b-c-pi#639 迁移单)路径 B 的唯一修复条目;检索 open/closed issue 与近期 PR(overflow / selfheal / 中文错误措辞),无其他在途修复覆盖同一机制。

正在审核中,稍后给完整结论。

@ranxianglei
ranxianglei force-pushed the 2026-10-15_chinese-overflow-markers branch from fd4f6b6 to bcd039f Compare October 15, 2026 05:01
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #3246 复审结论(独立审核,非复读 issue)

前置动作:分支落后 master 37 个提交(含 #3154 熔断器——它动了 relay.ts,与本 PR 的 util.ts 无文本冲突),已 rebase 到当前 master 并强推本 PR 分支(fd4f6b61c → bcd039f,仅动本 PR 分支,未碰 master)。

验证结果:本地定向 tests/context-overflow.test.ts + tests/side-request-isolation.test.ts + tests/issue2484-overflow-and-summary.test.ts = 55/55 通过;typecheck clean;rebase 后 head 的远程 CI 39/39 全绿(含 ubuntu/windows × node 22/24 测试分片与全部 e2e lane)。

结构化八问

  1. 是什么问题:上游经中转站/网关返回中文溢出措辞的 400/413/5xx 时,溢出检测器判「非溢出」→ 同请求 refold 与紧急收缩都不触发 → 会话每轮原样重发同一个超窗 body、反复吃 400,彻底卡死。
  2. 什么原因导致的:CONTEXT_OVERFLOW_PATTERNS(src/util.ts)只写了英文 provider 措辞;中文 body 一个都不命中 → isOverflow=false。检测点本身没错,是标记表覆盖不全(疏堵判断:修在检测表这个决策点上,正确)。
  3. 影响范围与严重程度:走国内中转站、且声明窗口小于实际 payload(或未声明窗口)的用户;完全卡死(每轮同一 400),升级后自愈;英文 provider 用户零影响。
  4. 怎么修复的:既有标记表追加 5 条中文模式,全部强制方向词(超出/超过/超限/过长/超长)——仅提及 上下文/token 的无关 400(鉴权过期、限流、格式错误)不命中,防误武装紧急收缩;不做数字提取(诚实丢失 → 按 payload 尺寸武装),守住 context window problem continues #987「窗口归声明、永不从流量学习」。
  5. 是否有回归问题:逐项审过触碰路径的既有行为——① 英文标记全部原样保留、追加在表尾、.some() 语义不变 → 英文响应字节级不变(既有用例全过);② 状态门禁 400/413/5xx 未动,裸 5xx 无标记仍非溢出(既有用例钉住);③ parseOverflowWindow 未动,超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484「5xx+标记才算溢出」由新用例再钉一层;④ Bedrock "too many tokens" 是限流不是溢出的排除立场未被新模式破坏(5 条反例含 token 过期/限流措辞)。结论:无意回归 0 处。
  6. 是否破坏缓存:不涉及——只改错误分类,不碰缓存键、重试策略、增量游标、去重。
  7. 是否改了设计方向:不涉及——同一检测点、同一武装机制,只是标记账本扩充(与 wire-contract ledger only grows 同精神)。
  8. 是否引入新配置:不涉及。

行为变更披露(旧 → 新)

旧:中文溢出措辞的 400/413/5xx → 判非溢出 → 透传、不武装、不 refold,会话死循环。
新:同类措辞 → 判溢出 → 按 payload 尺寸武装紧急收缩 + 尝试同请求 refold。英文行为零变化。遗留项(已在 #3240 跟踪):带数字的中文报错原文还没拿到,parseOverflowWindow 的数字提取待报告者补原文后跟进,本 PR 故意不做猜测性提取。

代码与测试质量

判定

可合并:方向正确、修在根因层、回归审计 0 处、定向 55/55 + rebase 后 CI 39/39 全绿、行为变更已披露。等你合入即可(合并按规矩留给人)。

ranxianglei pushed a commit to DadayaSuwen/billion-context that referenced this pull request Oct 20, 2026
… this PR

ranxianglei#3246 (Closes ranxianglei#3240) predates this PR and is now mergeable:false against
master because ranxianglei#3787 landed the 上下文 direction it carried. After ranxianglei#3787 +
this PR's (a)-(d), two of its patterns keep unique coverage: the input side
named with an EXCEED predicate ('输入长度超出限制' — (c)'s length predicates
do not reach it, and extending (c)'s subjects to 超出/超过/超限 would light
up throttle phrasings like '请求超出频率限制') and the mixed-language
'prompt 过长'. Both are folded in here so the CJK detector surface lands in
one PR; ranxianglei#3246's field-phrasing regression cases (b-c-pi#639) move into
tests/cjk-context-overflow.test.ts alongside them.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

并入 #3950,本 PR 关闭。 审核 #3950(同一机制:CJK 溢出检测表 + 窗口解析,#3947 cause-5)时逐条比对了两个 PR 的覆盖:

内容零丢失,按「一个机制一个 PR」收口到 #3950。若你认为应保留本 PR 独立合入,重开即可,但两个 PR 同时编辑同一张标记表必然互相踩。

@ranxianglei ranxianglei changed the title fix: recognize Chinese relay overflow wording in the context-overflow detector (#3240) [PR] fix: recognize Chinese relay overflow wording in the context-overflow detector (#3240) Oct 20, 2026
ranxianglei pushed a commit to DadayaSuwen/billion-context that referenced this pull request Oct 20, 2026
… this PR

ranxianglei#3246 (Closes ranxianglei#3240) predates this PR and is now mergeable:false against
master because ranxianglei#3787 landed the 上下文 direction it carried. After ranxianglei#3787 +
this PR's (a)-(d), two of its patterns keep unique coverage: the input side
named with an EXCEED predicate ('输入长度超出限制' — (c)'s length predicates
do not reach it, and extending (c)'s subjects to 超出/超过/超限 would light
up throttle phrasings like '请求超出频率限制') and the mixed-language
'prompt 过长'. Both are folded in here so the CJK detector surface lands in
one PR; ranxianglei#3246's field-phrasing regression cases (b-c-pi#639) move into
tests/cjk-context-overflow.test.ts alongside them.
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant