mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
test: merge context-window overflow variants
This commit is contained in:
@@ -181,19 +181,10 @@ describe("isContextOverflowError", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("matches Anthropic 'Request size exceeds model context window' error", () => {
|
||||
// Anthropic returns this error format when the prompt exceeds the context window.
|
||||
// Without this fix, auto-compaction is NOT triggered because neither
|
||||
// isContextOverflowError nor pi-ai's isContextOverflow recognizes this pattern.
|
||||
// The user sees: "LLM request rejected: Request size exceeds model context window"
|
||||
// instead of automatic compaction + retry.
|
||||
const anthropicRawError =
|
||||
'{"type":"error","error":{"type":"invalid_request_error","message":"Request size exceeds model context window"}}';
|
||||
expect(isContextOverflowError(anthropicRawError)).toBe(true);
|
||||
});
|
||||
|
||||
it("matches 'exceeds model context window' in various formats", () => {
|
||||
const samples = [
|
||||
// Anthropic returns this JSON payload when prompt exceeds model context window.
|
||||
'{"type":"error","error":{"type":"invalid_request_error","message":"Request size exceeds model context window"}}',
|
||||
"Request size exceeds model context window",
|
||||
"request size exceeds model context window",
|
||||
'400 {"type":"error","error":{"type":"invalid_request_error","message":"Request size exceeds model context window"}}',
|
||||
|
||||
Reference in New Issue
Block a user