Skip to content

[PR] fix(config): preserve TOML integer limits across Kimi and Codex readers - #6188

Open
Afloat16 wants to merge 4 commits into
ranxianglei:masterfrom
Afloat16:2026-11-10_kimi-toml-integers
Open

Afloat16 wants to merge 4 commits into
ranxianglei:masterfrom
Afloat16:2026-11-10_kimi-toml-integers

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6180

Problem

Valid TOML model limits such as 128_000, +262_144 and hexadecimal/octal/binary integers are ignored by prefix-based readers. Floats and dates can also be misread as an integer prefix. This affects native Kimi routing, the launcher-side Kimi model-window map and Codex context/output/auto-compaction limits.

Changes

Read the complete scalar and share a strict nonnegative TOML integer validator across the native Kimi reader and both sibling readers identified in review. Digit separators, optional decimal plus signs and the supported bases retain their exact values; malformed scalars and unsafe integers are ignored. Preserve Kimi override precedence and the original configuration text.

The sibling fixes are an additive commit on this PR, following option A from the review. Integer syntax: https://toml.io/en/v1.0.0#integer

Validation

Exact published head: ec36a74925464250ff13780a75955dae3e5f2070. This preserves the architecture-map follow-up and merges current master dc041dd1ab1a014efa352ba47a6f31fc47f55284; the targeted tests, typecheck and build below were rerun on the integrated source tree.

node --import ./tests/preload-test-env.mjs --import tsx --test tests/client-config-toml-integers.test.ts tests/kimi-native.test.ts tests/model-windows.test.ts tests/launcher-max-outputs.test.ts
npm run typecheck
npm run build
  • 95 targeted tests passed, with no failures, skips or cancellations.
  • Negative control for the newly added sibling-reader regressions on the preceding PR head: 15 failed and 7 controls passed.
  • Full project type checking and the standard build passed for the updated source tree.
  • Every modified/new file was fetched from the published commit and verified byte-for-byte against the tested files; git diff --check passed.
  • Local runtime: Node.js 24.22.1 on Linux. Cross-platform CI is tracked by this PR.

The change repairs parsing of existing fields and adds no settings or kernel changes.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Dedup check (查重): not a duplicate — searched open+closed issues/PRs for kimi / TOML-integer / window-limit terms; #6188 is the only PR touching this area and the sole fix for #6180.

Direction (original-issue review). #6180: legitimate TOML integer spellings of max_context_size/max_output_size (128_000, hex/oct/bin, optional +) are silently dropped or prefix-misread by the kimi line reader, so native routing loses the declared context/output limits. The patch fixes the producer — the scalar parse in keyValue() (src/kimi/toml-edit.ts) — instead of filtering downstream. Root-cause level, correct layer.

What I verified independently (fresh checkout of the real head 9c197621, a single commit on current master e3220adc — base is up to date):

  • tests/kimi-native.test.ts: 43/43 pass on the PR head.
  • Negative control: restoring the pre-fix toml-edit.ts from master makes exactly 11 of the new cases fail (all 6 positive spellings + 1.5, 2026-01-01, 01, 1 trailing, 9007199254740993) — the tests have teeth and reproduce the reported bug; restoring the fix returns 43/43. Matches your stated validation.
  • npm run typecheck: clean.
  • Live CI (checked just now): lanes still queued/in-progress on head 9c197621 — nothing red, but not green yet either; the final verdict waits on CI.

Spec conformance. The new validator is the exact non-negative subset of the TOML 1.0.0 ABNF (checked against the official grammar): decimal with optional +, underscores only between digits, no leading zeros (except 0 itself), hex/oct/bin with lowercase prefixes. One deliberate deviation: values above Number.isSafeInteger (2⁵³−1) are rejected instead of lossy-parsed — sane for model limits, and strictly better than the old behavior, which accepted such values rounded; the 9007199254740993 case pins this.

Regression inventory. numVal feeds only max_context_size/max_output_size; every consumer degrades gracefully on undefined (managed-block render omits the lines, window scan skips, plugin-mode activation omits the info fields, launcher window filter drops non-positive values). Deltas, all intentional: plain decimals unchanged (existing test still green); trailing-garbage lines (65536 junk) go from misread-as-65536 to ignored (only invalid-TOML input is affected); ≥2⁵³ values go from rounded-accepted to rejected; underscore/hex/oct/bin/+ spellings are newly accepted. No kernel/, no config-surface, no wire-protocol change. §7.4 auto-merge gate: eligible on paper — the merge itself stays human-only.

Sibling finding — same defect, two more readers (belongs to #6180, not a new issue):
The identical prefix-regex flaw exists at:

  • src/client-config.ts:723 — parseCodexToml: model_context_window / model_auto_compact_token_limit / model_max_output_tokens (codex lane);
  • src/client-config.ts:1082 — parseKimiToml: max_context_size (+ overrides) — the launcher-side kimi reader feeding collectModelWindows / BILI_LAUNCHER_MODEL_WINDOWS.

This PR fixes only the native-mode reader (src/kimi/toml-edit.ts, the bootstrap + MCP-watchdog-respawn path). Per the same-symptom + same-mechanism = one-issue policy, these sites belong to #6180. Decision needed on the vehicle:


结构化八问:

  1. 是什么问题:Kimi config.toml 里以合法 TOML 整数写法(下划线分隔、十六进制/八进制/二进制、带 +)声明的模型上下文/输出上限,被 bili 的行读取器静默丢弃(128_000)或按前缀误读(1.5→1、日期→年份),导致 native 路由拿不到声明的窗口与输出上限。
  2. 什么原因导致的:行读取器 keyValue()(src/kimi/toml-edit.ts)用前缀正则 ([0-9]+)\b 抓数——下划线是 JS 词字符,128_000 整体失配被丢;小数/日期被截断取前缀。根因在生产者(解析器)本身,补丁改的就是这一层,不是下游过滤打补丁。
  3. 影响范围与严重程度:仅 kimi native 车道、且配置使用非纯十进制整数写法的用户;纯十进制写法完全不受影响。特定条件下有问题(声明上限丢失→窗口退回猜测解析),非不可用。
  4. 怎么修复的:数字抓取改为读完整标量,再按 TOML 1.0.0 ABNF 的非负整数子集严格校验(十进制可带 +、下划线只在数字间、无前导零、hex/oct/bin 小写前缀),且只接受恰好可表示的安全整数;用户配置原文保持不动。
  5. 是否有回归问题:已逐项清点 numVal 全部消费方(renderKimiManagedBlock / scanKimiModelWindows / native activateKimiPluginMode / parseLauncherModelWindows),均对 undefined 优雅降级;纯十进制行为不变(既有测试仍绿)。三处有意收紧均已披露:65536 junk 这类尾部垃圾行由"误读为 65536"改为忽略(仅非法 TOML 输入受影响);≥2⁵³ 的值由"舍入后接受"改为拒绝(旧行为本身就是错的,新测试钉住);下划线/hex/oct/bin/+ 写法由忽略改为正确接受。无内核、配置面、线上协议变更。
  6. 是否破坏缓存:不涉及(不触碰会话/缓存/重试/去重路径;改动只在启动期窗口扫描与托管配置渲染)。
  7. 是否改了设计方向:不涉及(单模块解析修正,无架构/边界/数据流转向)。
  8. 是否引入了新的配置:不涉及(无新 env/config/默认值)。

判定:审核通过。 本地双向验证齐全(正向 43/43 + 负向控制精确复现 11 例失败)、TOML 规格逐条核对、回归清点干净、diff 收敛(kimi 两文件,+49/−2)。CI 尚在执行中(非红),转绿后即可合并;另有 client-config.ts 两处同机制遗留点归属 #6180,处置方式见上方待决项(A/B)。

@Afloat16 Afloat16 changed the title [PR] fix(kimi): preserve model limits written as TOML integers [PR] fix(config): preserve TOML integer limits across Kimi and Codex readers Nov 11, 2026
@Afloat16

Afloat16 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Option A is now covered in this PR: c8b7ad0 applies the same strict integer validator to the three Codex model-limit fields and to the Kimi launcher model/override reader, alongside the native Kimi reader.

I also added the missing src/toml-integer.ts entry to the architecture map in 46a9588, fixing the architecture-docs failure introduced by extracting the shared helper.

Validation on the current source:

  • tests/client-config-toml-integers.test.ts and tests/kimi-native.test.ts: 65 passed, 0 failed, 0 skipped or cancelled.
  • node tools/check-architecture-docs.mjs: all checks passed (320 source files; 8 modules).
  • git diff --check: passed.

CI run 42995075326 is now green on this exact head, 46a95888c2471906287a9454c8805968a91a7e2b: all 11 test shards and both static-gates jobs passed, including typecheck and build.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Kimi model limits using TOML digit separators are dropped from native routing

2 participants