fix: treat Anthropic long context billing error as context overflow
Anthropic returns "Extra usage is required for long context requests" when the prompt exceeds the billing tier's context limit. This was incorrectly classified as a retryable API error, causing infinite retries (observed up to attempt #7 with 2m delays). Classify it as a context overflow so compaction kicks in and reduces the prompt to fit within the standard context window.pull/18683/head
parent
71e7603d71
commit
5e8bcd1581
|
|
@ -8,6 +8,7 @@ export namespace ProviderError {
|
|||
// https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/utils/overflow.ts
|
||||
const OVERFLOW_PATTERNS = [
|
||||
/prompt is too long/i, // Anthropic
|
||||
/extra usage is required for long context/i, // Anthropic (billing tier context limit)
|
||||
/input is too long for requested model/i, // Amazon Bedrock
|
||||
/exceeds the context window/i, // OpenAI (Completions + Responses API message text)
|
||||
/input token count.*exceeds the maximum/i, // Google (Gemini)
|
||||
|
|
|
|||
Loading…
Reference in New Issue