From b2441050656d49d300f79a3a0029e6523520412d Mon Sep 17 00:00:00 2001 From: lovivi Date: Sun, 28 Jun 2026 00:45:01 +0800 Subject: [PATCH] fix(tool-emulation): use gpt_native dialect for glm-5.2 glm-5.2 ignores the glm47 XML tool-call markup and answers in prose. Switch it (and its variant SKU aliases) to the gpt_native function_call JSON dialect, which is emitted reliably and parsed correctly. Keep an env override (WINDSURFAPI_FORCE_TOOL_DIALECT) for tests. --- src/handlers/tool-emulation.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/handlers/tool-emulation.js b/src/handlers/tool-emulation.js index bbf85ade..63898d9c 100644 --- a/src/handlers/tool-emulation.js +++ b/src/handlers/tool-emulation.js @@ -219,9 +219,18 @@ Rules: } export function pickToolDialect(modelKey, provider, route = null) { + const forced = process.env.WINDSURFAPI_FORCE_TOOL_DIALECT; + if (forced && /^(glm47|openai_json_xml|kimi_k2|gpt_native)$/.test(forced)) return forced; const normalizedProvider = String(provider || '').toLowerCase(); const normalizedModelKey = String(modelKey || '').toLowerCase(); - if (normalizedProvider === 'zhipu' || normalizedModelKey.startsWith('glm')) return 'glm47'; + if (normalizedProvider === 'zhipu' || normalizedModelKey.startsWith('glm')) { + // v2.0.72 — glm-5.2 probe: the glm47 XML markup dialect is ignored and + // the model answers in plain text. The gpt_native function_call JSON + // dialect is emitted reliably and parsed correctly. Keep older GLM on + // glm47 until proven otherwise; env override still available for tests. + if (normalizedModelKey === 'glm-5.2' || normalizedModelKey.startsWith('glm-5-2-')) return 'gpt_native'; + return 'glm47'; + } 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