anomalyco / anomalyco/opencode
ai: classify plain AI SDK stream errors
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
- Configure an AI SDK language model whose stream emits an error part containing a plain
Error, rather than anAPICallError. - Use a transient provider message such as
The model is currently at capacity due to high demand. Please try again in a few minutes. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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