<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dursun S.Ahmet</title>
    <description>The latest articles on DEV Community by Dursun S.Ahmet (@sertdisk).</description>
    <link>https://dev.to/sertdisk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4165070%2Fb253ebc6-a54a-4932-afce-29819a612a70.jpg</url>
      <title>DEV Community: Dursun S.Ahmet</title>
      <link>https://dev.to/sertdisk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sertdisk"/>
    <language>en</language>
    <item>
      <title>OpenCode Model Router: per-agent model fallback chains with a local web UI</title>
      <dc:creator>Dursun S.Ahmet</dc:creator>
      <pubDate>Tue, 06 Oct 2026 02:39:52 +0000</pubDate>
      <link>https://dev.to/sertdisk/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui-4n23</link>
      <guid>https://dev.to/sertdisk/opencode-model-router-per-agent-model-fallback-chains-with-a-local-web-ui-4n23</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sertdisk/OpenCode-Model-Router" rel="noopener noreferrer"&gt;OpenCode Model Router&lt;/a&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Per-agent chains
&lt;/h2&gt;

&lt;p&gt;A chain is an ordered list of model refs in the form &lt;code&gt;{providerID, id, variant?}&lt;/code&gt;. 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.&lt;/p&gt;

&lt;p&gt;Chains 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.&lt;/p&gt;

&lt;p&gt;A step can carry an optional &lt;code&gt;variant&lt;/code&gt;, 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.&lt;/p&gt;

&lt;p&gt;The model picker only offers models and providers that you have already added and enabled in OpenCode. It mirrors the visibility configured under Settings &amp;gt; Models, reading that state from &lt;code&gt;drafts.sqlite&lt;/code&gt;. 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The web UI
&lt;/h2&gt;

&lt;p&gt;Chains are managed from a small web UI that the plugin serves itself at &lt;a href="http://127.0.0.1:37337" rel="noopener noreferrer"&gt;http://127.0.0.1:37337&lt;/a&gt;. 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 &lt;code&gt;/model-router&lt;/code&gt; command provides a fallback path to the same management.&lt;/p&gt;

&lt;h2&gt;
  
  
  oh-my-opencode-slim, natively
&lt;/h2&gt;

&lt;p&gt;If you run oh-my-opencode-slim, the plugin writes chains as native &lt;code&gt;agents.&amp;lt;agent&amp;gt;.model&lt;/code&gt; 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 &lt;code&gt;.model-router.bak&lt;/code&gt; backup next to the target file, which makes reverting a bad change a copy operation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/sertdisk/OpenCode-Model-Router
powershell &lt;span class="nt"&gt;-ExecutionPolicy&lt;/span&gt; Bypass &lt;span class="nt"&gt;-File&lt;/span&gt; tools/install-dev.ps1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The plugin has zero dependencies. The README covers setup in both English and Turkish.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;Two 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.&lt;/p&gt;

&lt;p&gt;Beyond 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 &lt;a href="https://github.com/sertdisk/OpenCode-Model-Router" rel="noopener noreferrer"&gt;https://github.com/sertdisk/OpenCode-Model-Router&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
