anomalyco / anomalyco/opencode

ai: classify plain AI SDK stream errors

Open
#43,791 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

Plain errors emitted by an AI SDK model stream bypass shared provider-failure classification. Transient messages such as provider capacity errors are therefore classified as UnknownProvider and are not retried, while equivalent APICallError and native AI-package failures use classifyProviderFailure correctly.

Environment

  • opencode version: v0.0.0-dev-17773
  • OS: Darwin 25.6.0 arm64
  • Terminal: Ghostty (TERM=xterm-256color, COLORTERM=truecolor)
  • Shell: /bin/zsh
  • Install/channel: dev, V2
  • Active plugins: none configured

Reproduction

  1. Configure an AI SDK language model whose stream emits an error part containing a plain Error, rather than an APICallError.
  2. Use a transient provider message such as The model is currently at capacity due to high demand. Please try again in a few minutes.
  3. Run a prompt through the V2 Session runner.

Expected Behavior

The plain stream error message should pass through the shared provider-failure classifier. Known transient text should become ProviderInternal and participate in the existing retry policy.

Actual Behavior

packages/core/src/aisdk.ts routes APICallError through RequestExecutor.classifyHttpFailure, which reaches classifyProviderFailure. A plain Error instead falls through llmError() directly to UnknownProviderReason, so transient text matching never runs and the failure is not retried.

Additional Context

This affects AI SDK stream errors from language.doStream(), readable-stream failures, and LanguageModelV3StreamPart error events whenever the underlying value is a plain error. Native AI-package HTTP failures and modeled stream error events already converge on packages/ai/src/provider-error.ts.

The fix should preserve unknown plain errors as UnknownProvider while allowing known structured or textual classifications to use the shared classifier. Add coverage for a plain AI SDK stream error carrying transient capacity text, alongside the existing APICallError tests.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/core/src/aisdk.ts to trace plain stream errors alongside APICallError handling, then read the shared classifier in packages/ai/src/provider-error.ts and the existing APICallError tests. Add coverage for a plain AI SDK stream error containing transient capacity text; done means it receives the shared transient classification and unknown plain errors remain UnknownProvider.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.