Merge pull request #9511 from continuedev/dallin/context-length-fixes
fix: context length error detection
This commit is contained in:
commit
8f088dc2d5
1 changed files with 11 additions and 2 deletions
|
|
@ -80,8 +80,18 @@ function isConnectionError(errorMessage: string): boolean {
|
|||
/**
|
||||
* Checks if the error indicates a context length issue (non-retryable)
|
||||
*/
|
||||
export function isContextLengthError(error: any): boolean {
|
||||
export function isContextLengthError(error: unknown): boolean {
|
||||
if (!(error instanceof Error)) {
|
||||
return false;
|
||||
}
|
||||
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 +104,6 @@ export function isContextLengthError(error: any): boolean {
|
|||
"use a shorter prompt",
|
||||
// Generic patterns
|
||||
"context_length_exceeded",
|
||||
"invalid_request_error",
|
||||
];
|
||||
|
||||
return contextLengthPatterns.some((pattern) =>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue