anomalyco / anomalyco/opencode

v2: normalize or reject unprefixed AI SDK packages in native provider config

Open
#44,881 0 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 25, 2026.

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

Description

Problem

Native V2 provider configuration accepts an AI SDK npm package without the required aisdk: prefix, but the resulting provider fails only when a prompt is sent. This makes a plausible configuration silently select the native OpenCode provider loader instead of AI SDK compatibility.

{
  "providers": {
    "custom": {
      "package": "@ai-sdk/openai-compatible",
      "models": { "chat": {} }
    }
  }
}

The currently working form requires an undocumented/non-obvious discriminator:

{
  "providers": {
    "custom": {
      "package": "aisdk:@ai-sdk/openai-compatible",
      "models": { "chat": {} }
    }
  }
}

The same issue applies to model-level package overrides. Legacy V1 provider.*.npm and model-level provider.npm values are automatically normalized during migration, and models.dev packages are also normalized, so native V2 config behaves inconsistently with those sources.

Current implementation

  • packages/core/src/config/plugin/provider.ts copies provider-level and model-level package values directly into the catalog.
  • packages/core/src/provider.ts recognizes AI SDK packages only when prefixed with aisdk:.
  • packages/core/src/model-resolver.ts treats every unprefixed package as a native OpenCode provider module.
  • V2 provider and model config schemas currently accept the invalid-looking-but-runtime-broken bare AI SDK strings.

Expected behavior

Native V2 configuration should either normalize obvious AI SDK package names such as @ai-sdk/* at both provider and model levels, or reject them early with an actionable validation error explaining the required aisdk: prefix. The public V2 provider documentation should explain native versus AI SDK package selection.

Preserve legitimate unprefixed native provider modules and native file:// packages; arbitrary third-party AI SDK packages may still need an explicit discriminator.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.