From 5e8bcd15811adbcee252a9c8d1049f3223ca9ce1 Mon Sep 17 00:00:00 2001 From: Brendan DeBeasi Date: Sun, 22 Mar 2026 18:24:56 -0700 Subject: [PATCH] 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. --- packages/opencode/src/provider/error.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/opencode/src/provider/error.ts b/packages/opencode/src/provider/error.ts index 7a171f4dbb66..481180e03e8c 100644 --- a/packages/opencode/src/provider/error.ts +++ b/packages/opencode/src/provider/error.ts @@ -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)