Skip to content

[FEATURE]: Native Model Fallback / Failover Support #7602

@arisgrout

Description

@arisgrout

Problem

OpenCode supports:

  • Provider fallback only when the model ID is the same
  • Static agent-level model overrides

There is no way to define fallback between different models, e.g.:

“If model A errors or rate-limits → automatically retry with model B”

This causes long-running agent workflows to fail on transient provider/model issues and forces users to rely on external routers or proxies (like litellm).


Request

Add first-class model fallback support to OpenCode.

Example (global)

{
  "models": {
    "coder": {
      "fallback": [
        "anthropic/claude-3.5-sonnet",
        "openai/gpt-4o",
        "deepseek/deepseek-r1"
      ]
    }
  }
}

Example (agent-level)

{
  "agents": {
    "build": {
      "model": {
        "fallback": ["claude-sonnet", "gpt-4o-mini"]
      }
    }
  }
}

Behavior

  • Switch models on: rate limits, provider/model unavailability, 5xx errors
  • Do not retry on prompt or validation errors
  • Optional retry limit

Why in Core


Status

  • No existing plugin or PR implements true model fallback

Thanks,

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions