anomalyco / anomalyco/opencode

Custom provider models (via `@ai-sdk/openai-compatible`) fail in sub-agent context

Open
#39,303 1 comment 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Jul 28, 2026.

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

Description

Description

Custom provider models registered in config.json via the npm + options pattern do not work when assigned to a sub-agent (mode: subagent). The sub-agent returns a bare Error with no details — no crash log, no stack trace, no console output.

The same sub-agent works correctly when using the built-in opencode/deepseek-v4-flash-free model.

The custom provider itself works fine:

  • The OpenAI-compatible API endpoint responds correctly
  • The @ai-sdk/openai-compatible module resolves and creates a working provider from the config.json settings
  • Direct API calls to the local model succeed

Steps to Reproduce

  1. Create a custom provider in ~/.config/opencode/config.json:

    {
      "provider": {
        "Lemonade": {
          "name": "Lemonade (Local LLM)",
          "npm": "@ai-sdk/openai-compatible",
          "options": {
            "apiKey": "lemonade",
            "baseURL": "http://127.0.0.1:13305/v1"
          },
          "models": {
            "Qwen3.6-35B-A3B-MTP-GGUF": {
              "name": "Qwen3.6 35B (GPU)"
            }
          }
        }
      }
    }
    
  2. Install the npm package:

    cd ~/.config/opencode
    bun install @ai-sdk/openai-compatible
    
  3. Create a sub-agent with the custom model:

    ---
    description: Test agent with custom provider
    mode: subagent
    model: Lemonade:Qwen3.6-35B-A3B-MTP-GGUF
    temperature: 0.3
    ---
    You are a test agent.
    
  4. Invoke the sub-agent via the task tool with subagent_type: "subagents/<name>".

  5. Observe Error with no detail.

Expected Behavior

The sub-agent should use the custom provider model, or at minimum return a descriptive error (e.g., "Provider not found", "Model not available", "Failed to load provider package").

Actual Behavior

Bare Error with no details. No log entries in ~/.local/share/opencode/log/. The opencode providers list CLI command also does not list custom providers from config.json — it only shows credential-based providers (Nvidia API, DeepSeek API).

Diagnostic Checklist

Check Result
Provider config.json syntax ✅ Valid JSON
@ai-sdk/openai-compatible installed ✅ Installed via bun in ~/.config/opencode/node_modules/
Module resolves via bun require.resolve('@ai-sdk/openai-compatible') works
Provider creates successfully createOpenAICompatible() returns a valid provider
Model API endpoint responds POST /v1/chat/completions returns 200 with valid response
Same sub-agent with default model ✅ Works with opencode/deepseek-v4-flash-free
Model name in Lemonade API ✅ Reported as Qwen3.6-35B-A3B-MTP-GGUF in /v1/models
Sub-agent tools section removed ✅ (Tools access confirmed working with default model)
opencode providers list ❌ Does NOT show Lemonade provider (only shows credential providers)
Error logs ❌ No relevant entries found

Additional Notes

  • The issue is specifically with sub-agent model resolution for custom providers. The built-in providers work fine.
  • Restarting OpenCode after config changes does not resolve the issue.
  • The npm auto-install mechanism (referenced by the "npm" field in config) may not be triggering, or the module resolve path does not include the config directory's node_modules.
  • This was tested with a local OpenAI-compatible server (Lemonade Server v10.9.0) and also may affect any custom provider using @ai-sdk/openai-compatible.

Related Files

  • ~/.config/opencode/config.json — provider configuration
  • ~/.config/opencode/package.json — dependencies (includes @ai-sdk/openai-compatible)
  • ~/.config/opencode/bun.lock — lockfile after bun install
  • ~/.config/opencode/agents/subagents/<name>.md — sub-agent definition
Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

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.