Skip to content

[Bug] Custom provider models not used at runtime when launching subagents via task() tool #2741

Closed

Description

@iceblove

Summary

When configuring custom provider models for agents in oh-my-opencode.json, the configuration is correctly parsed and validated by opencode debug agent <name>, but at runtime the subagent uses built-in opencode/* models instead of the configured custom provider models.

Environment

  • oh-my-opencode version: 3.12.3
  • opencode version: 1.2.27
  • Platform: macOS (darwin)

Configuration

~/.config/opencode/opencode.json:

{
  "plugin": ["oh-my-opencode"],
  "provider": {
    "opencode-go": {
      "npm": "@ai-sdk/anthropic",
      "name": "GenStudio (Anthropic Compatible)",
      "options": {
        "baseURL": "https://cloud.infini-ai.com/maas/coding/v1",
        "apiKey": "{env:GENSTUDIO_API_KEY}"
      },
      "models": {
        "minimax-m2.5": { "name": "MiniMax M2.5" },
        "minimax-m2.7": { "name": "MiniMax M2.7" },
        "glm-5": { "name": "GLM-5" }
      }
    }
  }
}

~/.config/opencode/oh-my-opencode.json:

{
  "$schema": "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
  "agents": {
    "explore": {
      "model": "opencode-go/minimax-m2.7",
      "fallback_models": ["opencode-go/minimax-m2.7", "opencode-go/minimax-m2.5"],
      "description": "Code exploration agent"
    },
    "librarian": {
      "model": "opencode-go/glm-5",
      "fallback_models": ["opencode-go/glm-5", "opencode-go/minimax-m2.7"]
    }
  }
}

Steps to Reproduce

  1. Configure a custom provider with models (as shown above)
  2. Verify the configuration is correct:
    opencode debug agent explore
    # Output shows: "model": { "providerID": "opencode-go", "modelID": "minimax-m2.7" }
  3. Test direct model usage (works correctly):
    opencode run -m opencode-go/minimax-m2.7 "Say: test"
    # Output: correctly uses minimax-m2.7
  4. Test via subagent task:
    task(subagent_type="explore", prompt="Say what model you are using")
    
  5. Observe the actual model used in the response

Expected Behavior

The subagent should use the configured model opencode-go/minimax-m2.7.

Actual Behavior

The subagent returns using minimax-m2.5-free (from built-in opencode provider):

[assistant (explore)] explore agent using: minimax-m2.5-free

Debug Information

Provider models cache (~/.cache/oh-my-opencode/provider-models.json):

  • opencode-go is in connected list
  • opencode-go/minimax-m2.7 is in available models

Model resolution simulation:

// Simulating resolveModelForDelegateTask
userModel: "opencode-go/minimax-m2.7"
fuzzyMatchModel result: "opencode-go/minimax-m2.7"  // ✅ Correct
resolution: { model: "opencode-go/minimax-m2.7" }   // ✅ Correct

Connected providers:

['opencode', 'opencode-go', 'kimi-for-coding', ...]

Analysis

I traced through the code and found:

  1. Configuration parsing is correct: opencode debug agent explore shows the correct model
  2. Model resolution returns correct value: resolveModelForDelegateTask() returns opencode-go/minimax-m2.7
  3. Direct model invocation works: opencode run -m opencode-go/minimax-m2.7 succeeds
  4. But subagent uses wrong model: The actual runtime model is opencode/minimax-m2.5-free

Possible causes:

  • The promptAsync call in startTask() may not correctly pass the custom provider model to the session
  • There may be an implicit fallback to built-in opencode provider models
  • The session model may be resolved differently at runtime vs configuration time

Relevant code paths:

  • resolveSubagentExecution() → resolveModelForDelegateTask() → categoryModel (correct)
  • executeBackgroundTask() → manager.launch({ model: categoryModel }) (should be correct)
  • startTask() → promptWithModelSuggestionRetry({ body: { model: launchModel } }) (should be correct)

Workaround Attempted

I tried adding fallback_models to the agent configuration, but the issue persists:

{
  "agents": {
    "explore": {
      "model": "opencode-go/minimax-m2.7",
      "fallback_models": ["opencode-go/minimax-m2.7", "opencode-go/minimax-m2.5"]
    }
  }
}

Questions

  1. Is there a specific configuration needed for custom provider models to work with subagents?
  2. Is there a runtime model resolution that differs from the configuration-time resolution?
  3. Are there any logs I can enable to trace the actual model being used at runtime?

Activity

  1. iceblove commented on Mar 22, 2026

    @iceblove
    Author

    Update: Root Cause Identified

    After further investigation, I found that this issue is actually in opencode core, not oh-my-opencode.

    Evidence

    Database records show that when a subagent is launched with agent: "explore", the model in the user message is already wrong:

    SELECT data FROM message WHERE agent = 'explore' AND role = 'user' ORDER BY time_created DESC LIMIT 1;
    -- Result: {"agent":"explore","model":{"providerID":"opencode","modelID":"minimax-m2.5-free"},...}

    The model parameter passed to promptAsync is opencode-go/minimax-m2.7, but the database shows opencode/minimax-m2.5-free.

    Root Cause

    OpenCode core has built-in fallback chains for agents. When processing a session prompt with an agent parameter, opencode overrides the model parameter with the agent's built-in fallback chain.

    Comparison

    Scenario Parameters Result
    Direct model usage model: opencode-go/minimax-m2.7 ✅ Uses opencode-go/minimax-m2.7
    Subagent with agent name agent: explore, model: opencode-go/minimax-m2.7 ❌ Uses opencode/minimax-m2.5-free (fallback)

    Related Issue

    Filed in opencode repo: anomalyco/opencode#18615

    This issue can be closed as it's a bug in opencode core, not oh-my-opencode.

  2. TrueHOOHA commented on Mar 23, 2026

    @TrueHOOHA

    I found this issue too. I don't have any Claude models in my provider list, and I didn't change anything Omo agent default models. When Sisyphus calls subagent to work. It always stuck with some subagent using Claude models not what my providers has.

  3. added a commit that references this issue on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions