Skip to content

isLongContextError misses 'out of extra usage' error, breaking 1M context fallback #159

@flwrenn

Description

@flwrenn

Bug

When enable1mContext is true and the API returns a 400 with:

You're out of extra usage. Add more at claude.ai/settings/usage and keep going.

the retry logic in index.js:240-269 should drop the context-1m-2025-08-07 beta and retry at 200k context. Instead, the request fails outright because isLongContextError() doesn't match this error message.

Root Cause

isLongContextError in dist/betas.js only checks for two patterns:

export function isLongContextError(responseBody) {
    return (
        responseBody.includes("Extra usage is required for long context requests") ||
        responseBody.includes("long context beta is not yet available")
    );
}

The "You're out of extra usage" message — which occurs on Max subscriptions when 1M context requests hit extra usage billing limits — is not matched.

Suggested Fix

Add a third condition:

responseBody.includes("You're out of extra usage")

This allows the existing beta-exclusion retry loop to gracefully fall back to 200k context instead of failing.

Environment

  • opencode-claude-auth@1.4.7
  • Claude Max subscription
  • enable1mContext: true, model claude-opus-4-6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions