r/opencode • u/Broad_Abies9390 • 6d ago
Another OpenCode model router, but this one tries not to burn your prompt cache
Yes, another model router š
I built an OpenCode V2 plugin inspired by Piās smart-router. It uses a small judge model to route each turn to a model from a pool you choose. The judge can run locallyāQwen 4B on oMLX or llama.cpp, for exampleāor through an OpenAI-compatible endpoint.
The obvious problem is that switching to a cheaper model can cost more if you lose a warm prompt cache. So the router estimates cached input cost for the current model against cold input cost for alternatives. It keeps a pin unless thereās a good reason to switch, like the task needing more capability or an adequate alternative being much cheaper. Thereās also a guard against bouncing between models.
You can choose cost, quality, or balanced preferences, mix local and cloud models, and choose how aggressively to favor the cache. If the judge times out, deterministic rules take over. /router explain shows the last decision and /router timing shows the overhead.
Iām not going to claim it saves everyone money. It depends on your models, cache pricing, workload, and whether the router makes good calls. Iād like to find out where it gets those calls wrong.
If you try it, Iād appreciate issues or feedbackāespecially bad model picks, unexpected cache behavior, judge latency, or setup problems.
GitHub: https://github.com/231self/opencode-router


