Skip to content

Agent model validation fails with trailing slash for custom OpenAI-compatible provider models #12062

Closed as not planned

Description

@sheepmao

Description

Description

When using a custom provider model in agent configuration (plan/build/explore), the model validation fails because a trailing slash (/) is appended to the model name during validation.

Error message:

Agent plan's configured model my-custom-model/ is not valid

Note the trailing / at the end - my configuration does NOT include this slash.

Key observations:

  1. The same model works perfectly when set as the top-level "model" config
  2. The same model works when selected via /models command
  3. Only fails when specified in agent.plan.model, agent.build.model, or agent.explore.model
  4. Setting "model": "" in agent config works (falls back to top-level model)

This appears to be a validation bug where the model name string is being processed incorrectly for agent-level model configurations with custom OpenAI-compatible providers.

Expected behavior

Agent should use the configured model my-custom-model without appending a trailing slash.

Actual behavior

Model validation fails because a / is appended to the model name, making it my-custom-model/ which doesn't match any configured model.

Workaround

Set "model": "" in agent configuration to fallback to the top-level model:

"agent": {
  "plan": {
    "mode": "subagent",
    "model": "",  // fallback to top-level model
    ...
  }
}




### Plugins

_No response_

### OpenCode version

1.1.21

### Steps to reproduce

1. Configure a custom provider with models in `opencode.json`:
```json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "my-custom-model",
  "provider": {
    "my-provider": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "my-provider",
      "options": {
        "baseURL": "https://my-api-endpoint.com/v1"
      },
      "models": {
        "my-custom-model": {
          "name": "my-custom-model",
          "options": {
            "contextLength": 262144,
            "maxTokens": 16384
          }
        }
      }
    }
  },
  "agent": {
    "plan": {
      "mode":primary",
      "model": "my-custom-model",
      "temperature": 0.2
    }
  }
}
  1. Open OpenCode
  2. Switch to plan agent (or any agent with explicit model config)
  3. See error: Agent plan's configured model my-custom-model/ is not valid

Screenshot and/or share link

No response

Operating System

Linux

Terminal

vscode terminal zsh

Activity

  1. github-actions commented on Feb 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These issues share similar patterns with agent-level model configuration failures, custom OpenAI-compatible provider handling, and model validation errors. Feel free to ignore if your specific case with the trailing slash appended to the model name is unique.

  2. rekram1-node commented on Feb 4, 2026

    @rekram1-node
    Contributor

    run opencode models to see list of available models. It looks like you aren't properly configuring your model id. It needs a provider prefix:

    ex:

    openai/gpt-5.2

  3. mgscreativa commented on Feb 27, 2026

    @mgscreativa

    This issue is real! Been hours with chatgpt and gemini to try to fix it but no luck at all.

    Using latest opencode 1.2.15

    Latest opencode.json created by gemini I'm using to test:

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "local-ollama-host": {
          "api": "openai-compatible",
          "options": {
            "baseURL": "http://127.0.0.1:11434/v1",
            "apiKey": "ollama"
          }
        }
      },
      "default_agent": "architect",
      "agent": {
        "architect": {
          "mode": "primary",
          "provider": "local-ollama-host",
          "model": "qwen-next-joomla:latest",
          "tools": {
            "write": false,
            "edit": false,
            "bash": false
          }
        }
      }
    }
    

    Wit it I get Agent architect's configured model qwen-next-joomla:latest/ is not valid

    ollama list

    NAME                       ID              SIZE     MODIFIED    
    qwen-next-joomla:latest    29c27e42ac0e    51 GB    2 hours ago    
    qwen3-coder-next:q4_K_M    ca06e9e4087c    51 GB    5 hours ago    
    
  4. github-actions commented on Apr 29, 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

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions