Skip to content

Commit adf178a

Browse files
authored
fix(llm): classify zai token limit overflow (#35671)
1 parent 78f85b1 commit adf178a

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/llm/src/provider-error.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const patterns = [
66
/input is too long for requested model/i,
77
/exceeds the context window/i,
88
/input token count.*exceeds the maximum/i,
9+
/tokens in request more than max tokens allowed/i,
910
/maximum prompt length is \d+/i,
1011
/reduce the length of the messages/i,
1112
/maximum context length is \d+ tokens/i,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { describe, expect, test } from "bun:test"
2+
import { isContextOverflow } from "../src"
3+
4+
describe("provider error classification", () => {
5+
test("classifies Z.AI GLM token limit messages as context overflow", () => {
6+
expect(isContextOverflow("tokens in request more than max tokens allowed")).toBe(true)
7+
})
8+
})

packages/opencode/test/session/message-v2.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,7 @@ describe("session.message-v2.fromError", () => {
14481448
"prompt is too long: 213462 tokens > 200000 maximum",
14491449
"Your input exceeds the context window of this model",
14501450
"The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)",
1451+
"tokens in request more than max tokens allowed",
14511452
"Please reduce the length of the messages or completion",
14521453
"400 status code (no body)",
14531454
"413 status code (no body)",

0 commit comments

Comments
 (0)