Skip to content

[FEATURE]: Support non-factory LanguageModelV2 class exports in dynamic provider loader #16793

Closed as not planned

Description

@coconutbird

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

The dynamic provider loader only recognizes npm packages that export a create* factory. Some packages (e.g. @augmentcode/auggie-sdk) export a LanguageModelV2 class directly — no factory wrapper. These fail to load.

Proposal: add a fallback that duck-types LanguageModelV2 classes (doGenerate + doStream on prototype) and wraps them in a minimal provider object. The create* path stays preferred; class detection is the fallback.

Constructor convention: Every standard Vercel AI SDK provider uses (modelId, config) as the constructor signature:

SDK Class Constructor
@ai-sdk/anthropic AnthropicMessagesLanguageModel (modelId, config)
@ai-sdk/openai OpenAIChatLanguageModel (modelId, config)
@ai-sdk/google GoogleGenerativeAILanguageModel (modelId, config)
@ai-sdk/openai-compatible OpenAICompatibleChatLanguageModel (modelId, config)
@gitlab/gitlab-ai-provider GitLabAnthropicLanguageModel (modelId, config)
@augmentcode/auggie-sdk AugmentLanguageModel (modelId, config)
@openrouter/ai-sdk-provider OpenRouterChatLanguageModel (modelId, settings, config) ⚠️
ai-gateway-provider AiGatewayChatLanguageModel (models[], config) ⚠️

The two outliers (OpenRouter, ai-gateway-provider) both export create* factories, so the class fallback would never trigger for them. Function.length can be used as a runtime guard to reject constructors that don't take exactly 2 args.

This unblocks Augment Code support (#10216) and future-proofs the loader for any SDK that ships a raw LanguageModelV2 without a factory.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 9, 2026
  2. assigned and unassigned on Apr 26, 2026
  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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