GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Anthropic 5xx errors incorrectly marked non-retryable, stopping agent loop · Issue #19394 · anomalyco/opencode

Anthropic 5xx errors incorrectly marked non-retryable, stopping agent loop #19394

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Anthropic 5xx errors incorrectly marked non-retryable, stopping agent loop#19394
Copy link
Assignees
rekram1-node

Description

@sigvardt
sigvardt
opened on Mar 27, 2026
Issue body actions

Bug

When the Anthropic API returns a 500 Internal Server Error via SSE stream, the agent loop stops immediately instead of retrying.

Root Cause

The Vercel AI SDK's Anthropic provider creates APICallError with isRetryable: error.type === 'overloaded_error' for SSE-delivered errors. This means internal_server_error (HTTP 500) is marked isRetryable: false.

In packages/opencode/src/provider/error.ts, parseAPICallError passes this through directly for non-OpenAI providers:

isRetryable: input.providerID.startsWith("openai")
  ? isOpenAiErrorRetryable(input.error)
  : input.error.isRetryable

Then in packages/opencode/src/session/retry.ts (line 65):

if (!error.data.isRetryable) return undefined

Returning undefined means "don't retry", so the processor stores the error and stops the loop.

Impact

Any Anthropic API 500 error kills the agent session. Users see AI_APICallError: Internal server error and the loop halts. This is especially disruptive during periods of API instability.

Note: OpenAI errors are handled separately with isOpenAiErrorRetryable() which correctly retries server errors. Only non-OpenAI providers are affected.

Evidence

From production logs — all 6 occurrences show statusCode: 500, isRetryable: false:

AI_APICallError: Internal server error
url: https://api.anthropic.com/v1/messages
statusCode: 500
isRetryable: false

Suggested Fix

In error.ts, add a server error check that overrides the SDK's isRetryable for any 5xx status:

function isServerError(e: APICallError): boolean {
  return !!e.statusCode && e.statusCode >= 500 && e.statusCode < 600
}

Then in parseAPICallError:

isRetryable: isServerError(input.error) || (
  input.providerID.startsWith("openai")
    ? isOpenAiErrorRetryable(input.error)
    : input.error.isRetryable
)

This ensures ANY 5xx error is retryable regardless of what the upstream SDK reports, matching standard HTTP retry semantics.

Environment

  • OpenCode v1.3.3 (also affects v1.2.27)
  • Model: claude-opus-4-6 via anthropic provider
  • AI SDK: @ai-sdk/anthropic
Reacted by mzq592

Activity

  1. github-actions
    assigned
    rekram1-node
    on Mar 27, 2026
  2. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 27, 2026
  3. github-actions commented on Mar 27, 2026

    @github-actions
    github-actionsBot
    on Mar 27, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • fix: 5xx errors from non-standard providers are not retried #19203: Very similar — also addresses 5xx errors not being retried due to isRetryable handling in non-OpenAI providers, and proposes the same fix of classifying any HTTP >= 500 as retryable regardless of SDK-reported value.
    • [FEATURE]: retry automatically after internet server error #19100: Related feature request for automatically retrying after internal server errors from LLM providers.

    Please review those issues to see if they cover your case, and consider whether this can be consolidated.

  4. tim-mohrbach-ikigai commented on Apr 14, 2026

    @tim-mohrbach-ikigai
    tim-mohrbach-ikigai
    on Apr 14, 2026
    More actions

    These two fixes are complementary rather than overlapping:

    • This issue (Anthropic 5xx errors incorrectly marked non-retryable, stopping agent loop #19394) addresses APICallError instances where isRetryable is incorrectly false for 5xx responses — the fix belongs in error.ts at the parseAPICallError level.

    • fix: 5xx errors from non-standard providers are not retried #19203 / PR fix(opencode): extract statusCode from error variants for 5xx retry #19204 addresses errors that never become APICallError in the first place — they arrive as plain Error or UnknownError because they don't come through the Vercel AI SDK's APICallError path. The fix belongs in fromError() to reclassify these as retryable APIError.

    Both paths can produce the same symptom (5xx kills the session), but fixing only one still leaves the other unfixed. For example, OpenRouter returns 502s as UnknownError with {"code":502,"message":"Network connection lost.","metadata":{"error_type":"provider_unavailable"}} — even if isRetryable is corrected for APICallError, these errors bypass that code path entirely and need the fromError() classification that PR #19204 provides.

    Related: #22448 documents the OpenRouter-specific gap where code (numeric) and metadata.error_type aren't checked by PR #19204's current JSON fallback either.

  5. thdxr
    removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. github-actions commented on Jul 5, 2026

    @github-actions
    github-actionsBot
    on Jul 5, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  7. github-actions
    closed this as not plannedon Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.