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:
parent
e0adf65dac
commit
74a46bde5d
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@ -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"))
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user