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
More from coding & agent
- Hamel Husain and sh_reya launch O'Reilly book 'Evals for AI Engineers' — sh_reya · 2026-11-21
- End-to-end walkthrough: fine-tuning adapters for Qwen3-27B with coding harnesses like pi and opencode — mrdbourke · 2026-11-21
- Ex-games founder prototyping an elemental-bending sports anime game with AI as collaborator — trq212 · 2026-11-21
- Redditor turns Claude Code into a voice assistant that runs their mornings — SilverEvening4150 · 2026-11-21
- Leak: Cursor to Be Renamed Grok Build, CLI 2.0 Already in Alpha — mark_k · 2026-11-21
- MCP servers don't use AI themselves—they're just API wrappers designed for agents — tristanbob · 2026-11-21