fix(ai): fix bedrock throttling misidentification (#2699)
- Add NON_OVERFLOW_PATTERNS to explicitly exclude known non-overflow errors
- Consolidate Cerebras 400/413 no-body check into OVERFLOW_PATTERNS
- Format Bedrock errors as ${error.name}: ${error.message} for pattern matching
This commit is contained in:
@@ -39,4 +39,26 @@ describe("isContextOverflow", () => {
|
||||
const message = createErrorMessage("500 `model runner crashed unexpectedly`");
|
||||
expect(isContextOverflow(message, 32768)).toBe(false);
|
||||
});
|
||||
|
||||
it("does not treat Bedrock throttling 'Too many tokens' as overflow", () => {
|
||||
// Bedrock returns this for HTTP 429 rate limiting, NOT context overflow.
|
||||
// formatBedrockError uses a human-readable prefix for ThrottlingException.
|
||||
const message = createErrorMessage("Throttling error: Too many tokens, please wait before trying again.");
|
||||
expect(isContextOverflow(message, 200000)).toBe(false);
|
||||
});
|
||||
|
||||
it("does not treat Bedrock service unavailable as overflow", () => {
|
||||
const message = createErrorMessage("Service unavailable: The service is temporarily unavailable.");
|
||||
expect(isContextOverflow(message, 200000)).toBe(false);
|
||||
});
|
||||
|
||||
it("does not treat generic rate limit errors as overflow", () => {
|
||||
const message = createErrorMessage("Rate limit exceeded, please retry after 30 seconds.");
|
||||
expect(isContextOverflow(message, 200000)).toBe(false);
|
||||
});
|
||||
|
||||
it("does not treat HTTP 429 style errors as overflow", () => {
|
||||
const message = createErrorMessage("Too many requests. Please slow down.");
|
||||
expect(isContextOverflow(message, 200000)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user