opencode-model-router 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
> **Use the cheapest model that can do the job. Automatically.**
|
|
4
4
|
|
|
5
|
-
An [OpenCode](https://opencode.ai) plugin that routes every task to the right-priced AI tier
|
|
5
|
+
An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with ~210 tokens of overhead.
|
|
6
|
+
|
|
7
|
+
## Why it's different
|
|
8
|
+
|
|
9
|
+
Most AI coding tools give you one model for everything. You pay Opus prices to run `grep`. opencode-model-router changes that with a stack of interlocking ideas:
|
|
10
|
+
|
|
11
|
+
**Use a mid-tier model as orchestrator.**
|
|
12
|
+
The orchestrator runs on *every* message. Put Sonnet there, not Opus. Sonnet reads a routing protocol and delegates just as well as Opus — at 4x lower cost. Reserve Opus for when it genuinely matters.
|
|
13
|
+
|
|
14
|
+
**Inject a compressed, LLM-optimized routing protocol.**
|
|
15
|
+
Instead of verbose instructions, the plugin injects ~210 tokens of dense, machine-readable notation the orchestrator understands perfectly. Same routing intelligence as 870 tokens of prose — 75% smaller. Every message, every session.
|
|
16
|
+
|
|
17
|
+
**Match task to tier using a configurable taxonomy.**
|
|
18
|
+
A keyword routing guide (`@fast→search/grep/read`, `@medium→impl/refactor/test`, `@heavy→arch/debug/security`) tells the orchestrator exactly which tier fits each task type. Fully customizable. No ambiguity.
|
|
19
|
+
|
|
20
|
+
**Split composite tasks: explore cheap, execute smart.**
|
|
21
|
+
"Find how auth works and refactor it" shouldn't cost @medium for the whole thing. The multi-phase decomposition rule splits it: @fast reads the files (1x cost), @medium does the rewrite (5x cost). ~36% savings on composite tasks, which are ~65% of real coding sessions.
|
|
22
|
+
|
|
23
|
+
**Skip delegation overhead for trivial work.**
|
|
24
|
+
Single grep? One file read? The orchestrator executes directly — zero delegation cost, zero latency.
|
|
25
|
+
|
|
26
|
+
**Three routing modes for different budgets.**
|
|
27
|
+
`/budget normal` (balanced), `/budget budget` (aggressive savings, defaults everything to @fast), `/budget quality` (liberal use of stronger models). Mode persists across restarts.
|
|
28
|
+
|
|
29
|
+
**Cost ratios in the prompt.**
|
|
30
|
+
Every tier carries its `costRatio` (fast=1x, medium=5x, heavy=20x) injected into the system prompt. The orchestrator sees the price before deciding. It picks the cheapest tier that can reliably handle the task.
|
|
31
|
+
|
|
32
|
+
**Orchestrator-awareness.**
|
|
33
|
+
If the orchestrator is already running on Opus, the rule `self∈opus→never→@heavy` fires — it does the heavy work itself rather than delegating to another Opus instance.
|
|
34
|
+
|
|
35
|
+
**Multi-provider support with automatic fallback.**
|
|
36
|
+
Four presets out of the box: Anthropic, OpenAI, GitHub Copilot, Google. Switch with `/preset`. If a provider fails, the fallback chain tries the next one automatically.
|
|
37
|
+
|
|
38
|
+
**Plan annotation for long tasks.**
|
|
39
|
+
`/annotate-plan` reads a markdown plan and tags each step with `[tier:fast]`, `[tier:medium]`, or `[tier:heavy]` — removing all routing ambiguity from multi-step workflows.
|
|
40
|
+
|
|
41
|
+
**Fully configurable.**
|
|
42
|
+
Tiers, models, cost ratios, rules, task patterns, routing modes, fallback chains — all in `tiers.json`. No code changes needed.
|
|
6
43
|
|
|
7
44
|
## The problem
|
|
8
45
|
|
|
@@ -77,7 +114,9 @@ Task distribution: 18 exploration (60%), 10 implementation (33%), 2 architecture
|
|
|
77
114
|
|
|
78
115
|
## How it works
|
|
79
116
|
|
|
80
|
-
On every message, the plugin injects ~210 tokens into the system prompt:
|
|
117
|
+
On every message, the plugin injects ~210 tokens into the system prompt. The notation is intentionally dense and compressed — it's **optimized for LLM comprehension, not human readability**. An agent reads it as a precise routing grammar; a human might squint at it. That's by design: verbose prose would cost 4x more tokens per message with no routing benefit.
|
|
118
|
+
|
|
119
|
+
What the orchestrator sees (Anthropic preset, normal mode):
|
|
81
120
|
|
|
82
121
|
```
|
|
83
122
|
## Model Delegation Protocol
|
|
@@ -90,7 +129,17 @@ Delegate with Task(subagent_type="fast|medium|heavy", prompt="...").
|
|
|
90
129
|
Keep orchestration and final synthesis in the primary agent.
|
|
91
130
|
```
|
|
92
131
|
|
|
93
|
-
|
|
132
|
+
**What each line means (for humans):**
|
|
133
|
+
|
|
134
|
+
| Line | What it encodes |
|
|
135
|
+
|------|----------------|
|
|
136
|
+
| `Tiers: @fast=...(1x) @medium=...(5x) @heavy=...(20x)` | Model + cost ratio per tier, all in one compact token |
|
|
137
|
+
| `R: @fast→search/grep/... @medium→impl/...` | Full task taxonomy — keyword triggers for each tier |
|
|
138
|
+
| `Multi-phase: split explore(@fast)→execute(@medium)` | Composite task decomposition rule |
|
|
139
|
+
| `1.[tier:X]→... 5.trivial(≤2tools)→direct... 6.self∈opus→...` | Numbered routing rules in abbreviated form |
|
|
140
|
+
| `Err→retry-alt-tier→fail→direct. Chain: anthropic→...` | Fallback strategy in one line |
|
|
141
|
+
|
|
142
|
+
The orchestrator reads this once per message and applies it to every tool call and delegation decision in that turn.
|
|
94
143
|
|
|
95
144
|
### Multi-phase decomposition (key differentiator)
|
|
96
145
|
|
package/package.json
CHANGED