mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-13 01:31:22 +03:00
fix(ai): recognize more context overflow errors (#57982)
This commit is contained in:
committed by
GitHub
Unverified
parent
ad5336e636
commit
09a1db3b08
@@ -17,7 +17,9 @@ import { isRecord } from "./utils/record.js"
|
||||
|
||||
const patterns = [
|
||||
/prompt is too long/i,
|
||||
/input is too long for requested model/i,
|
||||
/input is too long for (?:the )?(?:requested|selected) model/i,
|
||||
// OpenCode Go
|
||||
/too large for the model'?s configured input limit/i,
|
||||
// Cloudflare Workers AI reports this as HTTP 413.
|
||||
/exceeded this model context window limit/i,
|
||||
/exceeds the context window/i,
|
||||
@@ -44,8 +46,8 @@ const patterns = [
|
||||
/context[_ ]length[_ ]exceeded/i,
|
||||
/context length is only \d+ tokens/i,
|
||||
/input length.*exceeds.*context length/i,
|
||||
// Z.ai code 1261 arrives as `Prompt too long` or `Prompt 超长`.
|
||||
/prompt (?:too long|超长)/i,
|
||||
// Z.ai code 1261 arrives as `Prompt too long`, `Prompt exceeds max length` or `Prompt 超长`.
|
||||
/prompt (?:too long|exceeds max length|超长)/i,
|
||||
/too large for model with \d+ maximum context length/i,
|
||||
/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,
|
||||
/model_context_window_exceeded/i,
|
||||
|
||||
@@ -17,6 +17,9 @@ describe("provider error classification", () => {
|
||||
"Too many tokens",
|
||||
"Input validation error: `inputs` tokens + `max_new_tokens` must be <= 131073. Given: 600035 `inputs` tokens and 16 `max_new_tokens`",
|
||||
"Token limit exceeded",
|
||||
"Prompt exceeds max length",
|
||||
"The input is too long for the selected model.",
|
||||
"This text request is too large for the model's configured input limit.",
|
||||
]
|
||||
|
||||
expect(messages.every(isContextOverflow)).toBe(true)
|
||||
|
||||
Reference in New Issue
Block a user