{"slug": "opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui", "title": "OpenCode Model Router: per-agent model fallback chains with a local web UI", "summary": "A developer released OpenCode Model Router, an MIT-licensed OpenCode plugin (v0.3.1) that gives each agent its own primary, secondary and tertiary model fallback chain, failing over automatically when a provider rate-limits or stops responding. Chains are configured through a local web UI bound to 127.0.0.1:37337 or a /model-router command, and are written either as native agents.<agent>.model arrays for oh-my-opencode-slim or into the host config, with a .model-router.bak backup on each write. The plugin has zero dependencies and only orders models already enabled in the user's OpenCode setup.", "body_md": "Long sessions tend to end the same way: the primary model starts returning rate-limit errors, or the provider goes quiet mid-task. The work is half done, the context is fully loaded, and the fix is either to wait or to switch models by hand and hope continuity survives. If you run more than one provider — OpenRouter, DeepSeek, and others — you already have somewhere to fail over to. What is usually missing is a way to declare \"this agent tries A, then B, then C\" and have that applied automatically when A stops answering. Waiting out a rate limit is fine once; doing it repeatedly, across agents and providers, is what gets old.\n\n[OpenCode Model Router](https://github.com/sertdisk/OpenCode-Model-Router) is an OpenCode plugin that adds exactly that. Every OpenCode agent gets its own model fallback chain: a primary, a secondary, and a tertiary model. When the primary model fails or does not respond, the plugin fails over to the second step, and then to the third. The project is MIT-licensed and currently at v0.3.1.\n\nA chain is an ordered list of model refs in the form `{providerID, id, variant?}`. The provider is part of a step's identity: the same model served by two different providers counts as two separate steps. That matters because the failure you are often defending against is the provider, not the model itself — a chain like \"model X on provider A, model X on provider B, model Y on provider C\" keeps the same model behavior for as long as possible and only changes model when both routes to it are gone.\n\nChains are per agent because agents do different work. A long-running coding agent and a short review agent do not need the same ordering, and one global fallback list forces a compromise between them. Each agent keeps its own three slots.\n\nA step can carry an optional `variant`, so two builds of the same model id can be ordered as distinct steps. Three slots is the whole model: primary, secondary, tertiary — enough to cover a provider outage plus a second degraded route in the same session, and short enough that keeping chains correct stays a small task.\n\nThe model picker only offers models and providers that you have already added and enabled in OpenCode. It mirrors the visibility configured under Settings > Models, reading that state from `drafts.sqlite`. Nothing is discovered or enabled behind your back; if a model is not part of your OpenCode setup, it does not appear in the picker, and every step you configure is something your installation can actually call.\n\nChains are managed from a small web UI that the plugin serves itself at [http://127.0.0.1:37337](http://127.0.0.1:37337). The listener binds to 127.0.0.1 only, so it is not exposed to the network. The UI is dark-themed and plain: an agent list, a three-slot chain editor, and a provider-grouped, searchable model drawer with keyboard navigation. Saving and applying writes the configuration and leaves a backup of the file it changes. If you would rather not leave the terminal, a `/model-router` command provides a fallback path to the same management.\n\nIf you run oh-my-opencode-slim, the plugin writes chains as native `agents.<agent>.model` arrays into the oh-my configuration, where its failover engine picks them up directly. On a plain OpenCode setup, the plugin writes the host configuration instead. Only one of the two is written at a time — the oh-my file or the host config, never both — so the two cannot drift apart. Each write also produces a `.model-router.bak` backup next to the target file, which makes reverting a bad change a copy operation.\n\n```\ngit clone https://github.com/sertdisk/OpenCode-Model-Router\npowershell -ExecutionPolicy Bypass -File tools/install-dev.ps1\n```\n\nThe plugin has zero dependencies. The README covers setup in both English and Turkish.\n\nTwo constraints are worth stating plainly. First, the plugin orders and fails over between models you already have; it does not provision anything. The models you want in the secondary and tertiary slots must be added and enabled in OpenCode first, or the picker will not show them. Second, the management UI is local-only. It binds to 127.0.0.1, there is no remote management surface, and chains are configured from the machine running OpenCode. If you need to edit chains from another machine, this plugin does not do that.\n\nBeyond that, the scope is narrow on purpose: three slots per agent, one writer for the config, and a backup on every write. If that matches how you run multiple providers, the repository is at [https://github.com/sertdisk/OpenCode-Model-Router](https://github.com/sertdisk/OpenCode-Model-Router).", "url": "https://wpnews.pro/news/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui", "canonical_source": "https://dev.to/sertdisk/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui-4n23", "published_at": "2026-10-06 02:39:52+00:00", "updated_at": "2026-10-06 02:47:40.567635+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-infrastructure"], "entities": ["OpenCode Model Router", "OpenCode", "oh-my-opencode-slim", "OpenRouter", "DeepSeek", "GitHub"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui", "markdown": "https://wpnews.pro/news/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui.md", "text": "https://wpnews.pro/news/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui.txt", "jsonld": "https://wpnews.pro/news/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui.jsonld"}}