fix(translator): strip thinking for NVIDIA glm-5.2 (port from 9router#2023) (#6413)

strip thinking for NVIDIA glm-5.2 (port #2023) (net +1/-0, test OK). Integrated into release/v3.8.46.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-07-06 19:23:43 -03:00
committed by GitHub
parent cfbc2c27c2
commit d415cc0216
3 changed files with 20 additions and 3 deletions

View File

@@ -21,6 +21,7 @@
### 🐛 Bug Fixes
- **fix(translator):** strip the Claude-style `thinking` field for **NVIDIA `z-ai/glm-5.2`**. NVIDIA's OpenAI-compatible wrapper 400s on `thinking` (a Claude-format client routed here leaves a `thinking:{type:"adaptive"}`); the existing strip rule only dropped `reasoning`. Same class already handled for `minimax-m2.7`. Regression guard: `tests/unit/nvidia-minimax-thinking-strip.test.ts` (+glm-5.2 case). (thanks @phidinhmanh)
- **fix(translator):** suppress the streamed `</think>` close marker for the **Antigravity IDE** client. On thinking-only turns Antigravity rendered a bare `</think>` as the sole visible content, tripping its loop-detection and wasting requests. Antigravity's UA (`vscode/<v> (Antigravity/<v>)`) is added to the marker-suppress allowlist (alongside OpenCode); Claude Code / Cursor still get the marker, and `x-omniroute-thinking-marker: on` force-restores it. Regression guard: `tests/unit/think-close-marker-suppress-5245.test.ts`. (thanks @abdofallah)
- **fix(executors):** strip nested `reasoning_content` from messages for **Mistral**. Mistral's API returns `422 extra_forbidden` when an assistant message carries `reasoning_content` (replayed thinking from a prior turn, e.g. via the Codex `/responses` path); the generic top-level 400 field-downgrade retry never covered the nested per-message field. `DefaultExecutor` now strips it for provider `mistral` only, so DeepSeek (which requires replayed `reasoning_content`) is unaffected. Regression guard: `tests/unit/mistral-strip-reasoning-content-1649.test.ts`. (thanks @xxy9468615)
- **fix(executors):** strip the `client_metadata` passthrough field on the **OpenCode** path. OpenCode upstreams (e.g. `kimi-k2.6` via opencode-go) reject it with `400 "Extra inputs are not permitted, field: 'client_metadata'"`; the DefaultExecutor strip only covered cerebras/mistral and `OpencodeExecutor` extends `BaseExecutor` directly, so nothing removed it there. Regression guard: `tests/unit/opencode-strip-client-metadata-1442.test.ts`. (thanks @yanpaing007)

View File

@@ -29,9 +29,12 @@ const STRIP_RULES: StripRule[] = [
/claude/i.test(m) && !/claude.*(opus|sonnet).*4\.6/i.test(m),
drop: ["thinking", "reasoning_effort"],
},
// NVIDIA NIM z-ai/glm-5.2: OpenAI-compatible wrapper rejects the `reasoning`
// body field → HTTP 400 "Unsupported parameter(s): `reasoning`". #6102 drop pattern.
{ provider: "nvidia", match: /z-ai\/glm-5\.2\b/i, drop: ["reasoning"] },
// NVIDIA NIM z-ai/glm-5.2: OpenAI-compatible wrapper rejects BOTH the `reasoning`
// body field (#6102) and the Claude-style `thinking` field. A Claude-format
// client (e.g. Claude Code) routed here leaves a `thinking:{type:"adaptive"}`
// that the wrapper 400s on — same class already handled for minimax-m2.7 below.
// 9router#2023.
{ provider: "nvidia", match: /z-ai\/glm-5\.2\b/i, drop: ["reasoning", "thinking"] },
// NVIDIA NIM minimaxai/minimax-m2.7: NVIDIA's OpenAI-compatible wrapper
// (format:"openai") does not accept the Claude-style `thinking` body field
// and returns 400 "Unsupported parameter(s): thinking". Upstream #2268.

View File

@@ -24,6 +24,19 @@ test("stripUnsupportedParams: nvidia + minimaxai/minimax-m2.7 drops thinking", (
assert.equal(body.model, "minimaxai/minimax-m2.7", "model must not be touched");
});
test("stripUnsupportedParams: nvidia + z-ai/glm-5.2 drops thinking AND reasoning (port from 9router#2023)", () => {
const body: Record<string, unknown> = {
model: "z-ai/glm-5.2",
thinking: { type: "adaptive" },
reasoning: { effort: "high" },
max_tokens: 512,
};
stripUnsupportedParams("nvidia", "z-ai/glm-5.2", body);
assert.equal(body.thinking, undefined, "thinking must be stripped for NVIDIA glm-5.2");
assert.equal(body.reasoning, undefined, "reasoning must still be stripped for NVIDIA glm-5.2");
assert.equal(body.max_tokens, 512, "other params must survive");
});
test("stripUnsupportedParams: nvidia + other model KEEPS thinking (regression guard)", () => {
const body: Record<string, unknown> = { thinking: { type: "adaptive" } };
stripUnsupportedParams("nvidia", "some-other-model", body);