From 88429d6dc5f9e01adc8a1a9226511dfa357eafda Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Tue, 29 Sep 2026 13:17:22 -0500 Subject: [PATCH] fix(ai): classify Novita context length rejections as context overflow --- packages/ai/src/provider-error.ts | 3 ++- packages/ai/test/provider-error.test.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ai/src/provider-error.ts b/packages/ai/src/provider-error.ts index 35b9cff7425..fd8347328a9 100644 --- a/packages/ai/src/provider-error.ts +++ b/packages/ai/src/provider-error.ts @@ -28,7 +28,8 @@ const patterns = [ /reduce the length of the messages/i, /maximum context length is \d+ tokens/i, /exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i, - /input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i, + // Novita omits the token counts. + /input(?: \(\d+ tokens\))? is longer than the model'?s context length/i, /exceeds the limit of \d+/i, /exceeds the available context size/i, /greater than the context length/i, diff --git a/packages/ai/test/provider-error.test.ts b/packages/ai/test/provider-error.test.ts index 98a94c1b143..0e67aa1d383 100644 --- a/packages/ai/test/provider-error.test.ts +++ b/packages/ai/test/provider-error.test.ts @@ -10,6 +10,7 @@ describe("provider error classification", () => { "Input length (265330) exceeds model's maximum context length (262144).", "Input length 131393 exceeds the maximum allowed input length of 131040 tokens.", "The input (516368 tokens) is longer than the model's context length (262144 tokens).", + "The input is longer than the model's context length trace_id: 39d8c3a5c6c91dbc8dd9055f0b37e084", "Prompt has 5,958,968 tokens, but the configured context size is 256,000 tokens", "Range of input length should be [1, 129024]", "Too many tokens",