fix(volcengine-ark): clamp GLM-5 max_tokens to model output ceiling (#2428)

Ark rejects max_tokens above 128000 for GLM-5.2. Add a config-driven STRIP_RULES entry that clamps max_tokens, max_completion_tokens and max_output_tokens down to the model maxOutput before the upstream call.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whale
2026-07-07 11:57:04 +07:00
committed by decolua
co-authored by Cursor
parent 8c068a1f5c
commit bbae990b92
2 changed files with 41 additions and 0 deletions
+24
View File
@@ -28,4 +28,28 @@ describe("stripUnsupportedParams", () => {
expect(body).toEqual({ top_p: 1 });
});
it("clamps VolcEngine Ark GLM max token fields to the model output ceiling", () => {
const body = {
max_tokens: 131072,
max_completion_tokens: 131072,
max_output_tokens: 131072,
};
stripUnsupportedParams("volcengine-ark", "GLM-5.2", body);
expect(body).toEqual({
max_tokens: 128000,
max_completion_tokens: 128000,
max_output_tokens: 128000,
});
});
it("keeps VolcEngine Ark GLM max tokens when already under the ceiling", () => {
const body = { max_tokens: 64000 };
stripUnsupportedParams("volcengine-ark", "GLM-5.2", body);
expect(body.max_tokens).toBe(64000);
});
});