Open-source router factors prompt cache into LLM switching decisions for coding agents

Broad_Abies9390 · reddit · 2026-11-21

A developer released opencode-router, an Apache-2.0 OpenCode V2 plugin that factors prompt-cache economics into model-switching decisions. A small local judge (e.g. Qwen 4B) scores each turn, then the router picks from a configurable pool of local and cloud models, favoring cost, quality or balance, with deterministic heuristics as fallback. Key insight: switching to a cheaper model can cost more if it must cold-read the whole context, so the router pins the current model unless the alternative is much better, needed, or far cheaper, plus anti-flapping guards. In a 24-turn simulated benchmark, balanced mode made 7 switches vs 18 in aggressive mode at $4.212 vs $4.190 — switching more was slightly cheaper there. Caveats: published prices, 80% cache-reuse assumption, judge latency ignored; it's a simulation, not proof of real savings. Code: github.com/231self/opencode-router

Original post →

More from coding & agent

coding & agent channel →