fix: context length error detection

This commit is contained in:
Dallin Romney 2026-01-13 12:23:33 -08:00
parent abff13dbcf
commit 1bfb72edf3

View file

@ -82,6 +82,13 @@ function isConnectionError(errorMessage: string): boolean {
*/
export function isContextLengthError(error: any): boolean {
const errorMessage = error.message?.toLowerCase() || "";
if (errorMessage.includes("invalid_request_error")) {
if (errorMessage.includes("context")) {
return true;
}
}
const contextLengthPatterns = [
// Anthropic Claude
"input length and max_tokens exceed context limit",
@ -94,7 +101,6 @@ export function isContextLengthError(error: any): boolean {
"use a shorter prompt",
// Generic patterns
"context_length_exceeded",
"invalid_request_error",
];
return contextLengthPatterns.some((pattern) =>