This commit is contained in:
hcl 2026-01-30 12:52:48 +01:00 committed by GitHub
commit 063d283364
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -40,6 +40,20 @@ describe("isContextOverflowError", () => {
} }
}); });
it("matches 'context_overflow' with underscore format", () => {
// Issue #3154: Some providers return "context_overflow" (underscore) instead of
// "context overflow" (space). Without this fix, auto-compaction is NOT triggered.
// The user sees the error instead of automatic compaction + retry.
const samples = [
"context_overflow: prompt too large for the model",
"Context_Overflow: request exceeds limit",
"ERROR: context_overflow detected",
];
for (const sample of samples) {
expect(isContextOverflowError(sample)).toBe(true);
}
});
it("ignores unrelated errors", () => { it("ignores unrelated errors", () => {
expect(isContextOverflowError("rate limit exceeded")).toBe(false); expect(isContextOverflowError("rate limit exceeded")).toBe(false);
expect(isContextOverflowError("request size exceeds upload limit")).toBe(false); expect(isContextOverflowError("request size exceeds upload limit")).toBe(false);

View File

@ -21,6 +21,7 @@ export function isContextOverflowError(errorMessage?: string): boolean {
lower.includes("exceeds model context window") || lower.includes("exceeds model context window") ||
(hasRequestSizeExceeds && hasContextWindow) || (hasRequestSizeExceeds && hasContextWindow) ||
lower.includes("context overflow") || lower.includes("context overflow") ||
lower.includes("context_overflow") ||
(lower.includes("413") && lower.includes("too large")) (lower.includes("413") && lower.includes("too large"))
); );
} }