Fix/swe family tool dialect - #252
Conversation
3126255 to
898af0f
Compare
|
Review: the premise is plausible — What I ranhead
The dialect table itself does what you say it does — I drove it: So the routing works. What it does downstream is the problem. B1 (blocker) — tool calls stop being extracted on the streaming path
Both failing tests are this: The second one matters more than its name suggests. It was added with the #241/#243
Why non-stream survives, and why that is not reassuring. It is not that the and then That is a streaming-vs-non-streaming fork on one B2 (blocker) — the prefix match is the mistake its neighbour already madeI nearly filed the failing tests as the whole finding, then checked the neighbours — if (normalizedProvider === 'moonshot' || normalizedModelKey.startsWith('kimi')) {
// The Kimi K2 vLLM dialect is verified working only against the original
// `kimi-k2` and `kimi-k2-thinking` SKUs. Newer Moonshot SKUs … are served by a
// different upstream runtime that rejects vLLM markup.
if (normalizedModelKey === 'kimi-k2' || normalizedModelKey === 'kimi-k2-thinking') return 'kimi_k2';
return 'openai_json_xml';
}The The history is sharper than the comment. On 2026-05-07, Related, from the #238 ledger entry on this same model family:
The claim I cannot check, and what would settle it// SWE-1.X use the same <|tool_call_begin|> / <|tool_call_end|> dialect as
// Kimi K2 — observed in production traffic 2026-08-07.I have no way to verify that from here, and I am not asserting it is wrong — if What would make this mergeable:
One more to think about before the next round: The dialect-per-family idea is sound and the code is in the right function. It needs the |
|
评审:方言这条观察我认为是对的,但 先说一句与你无关的:这个 PR 的 CI 从 08-07 起一直卡在 我实跑过什么head
两条失败: 第二条的措辞值得注意:原始工具标记直接当可见答案发给客户端了。 M1(blocker)—
|
| spec | 实测 master | spec 声明 | 合本 PR 后 |
|---|---|---|---|
bash-prefix-repair-boundary.json |
94 | 94 ✅ | 95 |
schema-ref-fanout-budget.json |
72 | 72 ✅ | 73 |
scripts/mutate-verify.mjs:208 在不匹配时是 die(),而测试套件不跑 spec,所以三个绿灯(你的 CI、本地 npm test、合并后门禁)都看不见这条。改 M1 时如果测试数又变,这两个数请一并按实测重量,不要从 94+1 推。
其余
方言判定放在 pickToolDialect 里、跟着 normalizedModelKey 走,位置是对的;改动只有 5 行加一条测试,范围克制。这个 PR 的价值在观察本身 —— SWE 系列跟 Kimi K2 共用 section-token 格式这件事,不看生产流量是想不到的。收窄之后我直接合。
改完 ping 我,我重跑门禁 + 那两个 spec。
- src/handlers/tool-emulation.js: constrain observed SWE routing, preserve native Kimi history continuity, and parse native plus legacy streamed forms (PR dwgx#252). - src/runtime-config.js, src/windsurf.js: suppress only contradictory tool syntax reinforcement (PR dwgx#252). - scripts/mutate-verify.mjs: read Node 22 and Node 24 TAP summary counters so the required mutation gate is portable (R2). - test/: pin stream/non-stream parity, history serialization, wire evidence, and measured mutation baselines (R2).
|
Thanks @dwgx for your review! I narrowed this back to the evidence from real SWE/Kimi traffic. The final scope is deliberately small:
I removed the unverified wrapperless-parser branch and the unrelated Node TAP reporter change, rather than broadening the PR without production evidence. Validation:
As a result, "unlimited" use of SWE model with external harness 😎 |
- src/handlers/tool-emulation.js: keep swe-1-7-lightning on openai_json_xml after the live probe showed narrative calls rather than Kimi section tokens (PR dwgx#252). - test/: pin the lightning exclusion and keep wrapperless grammar coverage bound to the actual kimi_k2 dialect.
- Remove wrapperless parser paths and generic prompt protocol detection without production evidence (PR dwgx#252). - Retain section/XML compatibility, narrow SWE routing, and Kimi history continuity. - Revert unrelated Node TAP reporter handling from this PR.
改了什么 / What changed
pickToolDialect in src/handlers/tool-emulation.js so that every model key starting with
swe-is routed to thekimi_k2tool-call dialect.为什么 / Why
SWE-family models use the same
� ... �section-token tool-call format as Kimi K2. the new rule makes the dialect dispatch model-agnostic for the whole SWE family, preventing "invalid tool call" errors while using external harness.测试 / Testing
node --test test/tool-emulation.test.js— 54/54 pass, including the newroutes all SWE family models to Kimi K2 vLLM dialecttest.POST /v1/chat/completionswithtool_choice=requiredto every SWE model served by the local instance:Checklist