fix: prevent false positive context overflow detection in conversation text

The isContextOverflowError check was too broad - it matched any text containing
'context overflow', including legitimate conversation discussing the topic.

Changed to require 'context overflow:' (with colon) to only match actual error
messages like 'Context overflow: Summarization failed'.

Added test case to verify normal conversation text doesn't trigger false positives.
This commit is contained in:
Stephen King 2026-01-25 21:46:26 -07:00
parent e0adf65dac
commit 74a46bde5d
2 changed files with 9 additions and 1 deletions

View File

@ -46,4 +46,12 @@ describe("isContextOverflowError", () => {
expect(isContextOverflowError("model not found")).toBe(false);
expect(isContextOverflowError("authentication failed")).toBe(false);
});
it("ignores normal conversation text mentioning context overflow", () => {
// These are legitimate conversation snippets, not error messages
expect(isContextOverflowError("Let's investigate the context overflow bug")).toBe(false);
expect(isContextOverflowError("The mystery context overflow errors are strange")).toBe(false);
expect(isContextOverflowError("We're debugging context overflow issues")).toBe(false);
expect(isContextOverflowError("Something is causing context overflow messages")).toBe(false);
});
});

View File

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