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

Open
opened 2026-02-16 18:10:04 -05:00 by yindo · 2 comments
Owner

Originally created by @sheepmao on GitHub (Feb 3, 2026).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @sheepmao on GitHub (Feb 3, 2026). Originally assigned to: @rekram1-node on GitHub. ### 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: ```json "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 } } } ``` 2. Open OpenCode 3. Switch to plan agent (or any agent with explicit model config) 4. 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
yindo added the bug label 2026-02-16 18:10:04 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 3, 2026):

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

  • #8950: Ollama custom provider error - agent configured model validation fails with custom providers
  • #9603: Amazon Bedrock Model in Agents - agent model validation error with custom provider
  • #9392: Amazon Bedrock model in agent file - agent-level model validation failure
  • #7099: Server API ignores agent's configured model - agent-level model configuration not recognized
  • #7958: ProviderModelNotFoundError for custom provider in GitHub Action - custom provider model resolution issues
  • #6636: Subagent with specific model - agent-level model configuration handling issue
  • #11416: Agent variant incorrectly applied to all models with OpenAI-compatible providers (CLOSED)

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.

@github-actions[bot] commented on GitHub (Feb 3, 2026): This issue might be a duplicate of existing issues. Please check: - #8950: Ollama custom provider error - agent configured model validation fails with custom providers - #9603: Amazon Bedrock Model in Agents - agent model validation error with custom provider - #9392: Amazon Bedrock model in agent file - agent-level model validation failure - #7099: Server API ignores agent's configured model - agent-level model configuration not recognized - #7958: ProviderModelNotFoundError for custom provider in GitHub Action - custom provider model resolution issues - #6636: Subagent with specific model - agent-level model configuration handling issue - #11416: Agent variant incorrectly applied to all models with OpenAI-compatible providers (CLOSED) 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.
Author
Owner

@rekram1-node commented on GitHub (Feb 4, 2026):

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

@rekram1-node commented on GitHub (Feb 4, 2026): 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8482