opencode-model-router 1.6.0 → 1.7.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,357 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.7.0] - 2026-08-19
9
+
10
+ Minor release: live model-catalog discovery and validation — `/router models`, stale-model
11
+ and fallback-chain checks, orphaned strong-pattern detection with near-miss naming — plus
12
+ `subagentTiers` for routing pre-existing subagents, resolved prompt style in `/tiers`, and
13
+ a set of enforcement and noise fixes. Routing behavior is unchanged unless you opt into
14
+ the new keys.
15
+
16
+ ### Added
17
+
18
+ - **Near-miss reporting for orphaned strong-model patterns.** When a pattern matches
19
+ nothing served, `/router models` and the startup warning now name any served model
20
+ that matches once `.`, `-` and `_` are normalized away. The known failure is a
21
+ provider moving between separator styles rather than a wrong name, so this turns
22
+ "this matches nothing" into "this matches nothing, and here is the id it means".
23
+
24
+ - **`subagentTiers`, opt-in routing for your own subagents.** A map of agent name to
25
+ tier name repoints pre-existing custom subagents at the active preset's models, so
26
+ they follow `/preset` instead of pinning a model id in their own agent files. A
27
+ subagent that declares no `model` otherwise inherits the model of whoever invoked it,
28
+ which quietly runs cheap read-only helpers at orchestrator prices. Absent or empty
29
+ means no agent is touched.
30
+ - **`/router models [provider]`** lists valid model ids from opencode's live provider
31
+ catalog, with each provider's default and any `deprecated`/`alpha`/`beta` status.
32
+ - **Stale-model validation.** Bare `/router` checks the active preset's tier models
33
+ against the catalog and reports missing or deprecated ids with the closest valid
34
+ suggestions; the same check is logged once per session. Report-only, so the plugin
35
+ never changes a model for you. A bad model id previously failed silently on every
36
+ subagent dispatch.
37
+
38
+ ### Fixed
39
+
40
+ - **Orphaned-pattern warnings the user could not act on.** A pattern from the shipped
41
+ default list is now reported only when a near-miss proves the model is served under a
42
+ drifted separator; a pattern you wrote in `modelGenerations.strong` is still always
43
+ reported. An anthropic-only install no longer warns that `claude-mythos-5` matches
44
+ nothing — that provider simply does not sell it.
45
+
46
+ - **Dormant fallback chains reported as broken.** `fallback-provider-unknown` now fires
47
+ only when the active preset actually routes to that provider. The shipped chains cover
48
+ every provider, so a single-provider install was warning about chains that are inert by
49
+ design. Chain entries naming a preset that does not exist are still reported.
50
+
51
+ - Removed a stale `buildAgentOptions` from `src/commands/output.ts`. It was live when
52
+ the presentation layer was extracted, but `src/router/agent-options.ts` later became
53
+ the real implementation and gained `effort` handling. The orphan was reachable only
54
+ from its own test, and importing it by mistake would have silently dropped `effort`.
55
+
56
+ - **`thinking.budgetTokens: 0` no longer swallows a tier's `effort`.** Behavior change:
57
+ suppression used `budgetTokens != null` while emission required a truthy value, so a
58
+ Claude tier with `thinking: { budgetTokens: 0 }` plus `effort` warned that "explicit
59
+ thinking wins" and then registered neither key. A truthy `budgetTokens` is now the
60
+ single notion of "thinking was asked for": `0` is ignored (one-time notice per tier)
61
+ and `effort` applies normally.
62
+ - **Enforced-mode hard blocks now apply to non-trivial `@fast` recon.** Trivial
63
+ classification exempted *any* `fast`-tier dispatch whose text matched a `fast`
64
+ taskPattern stem (`read`, `search`, `grep`, …) from enforcement, so a multi-file
65
+ recon dispatch was treated as "trivial" and `guardBeforeCall` downgraded
66
+ `enforced` → `advisory`. The `read_budget` guard could therefore never
67
+ hard-block a `@fast` subagent — the precise runaway it exists to bound.
68
+ `classifyTrivial` now additionally requires single-shot shape: at most one named
69
+ file path (well-known extensionless files like `Makefile` or `LICENSE` count),
70
+ no multi-step marker (numbered or colon-numbered lists, sequencing words, `;`,
71
+ `&&`), no enumeration of three or more subjects, no multiple imperative lines,
72
+ no distributive breadth quantifier (`every` / `all` over a plural or collective
73
+ target class, as in `read all guard modules` — partitive depth over a single
74
+ file such as `read every line of package.json` stays trivial), and a length
75
+ backstop. Genuine single-shot lookups stay exempt, and real work
76
+ was never trivial either way. Present since
77
+ proportional enforcement landed (`80abf05`) and shipped in every release that
78
+ included it. The `enforcement.proportional.trivialBypass` knob and its semantics
79
+ are unchanged.
80
+
81
+ ## [1.6.0] - 2026-08-18
82
+
83
+ Minor release: a salvage port of the features worth keeping from an abandoned branch —
84
+ per-tier reasoning effort, goal-oriented prompts, session-resume accounting, time-boxes
85
+ on every verification hop, and idle eviction for the delegation store. Routing behavior
86
+ is unchanged unless you opt into the new keys.
87
+
88
+ ### Added
89
+
90
+ - **Per-tier `effort`.** Each tier may declare a reasoning-effort level that is forwarded
91
+ to the provider on dispatch. The bundled `fable-effort` preset uses it to run all three
92
+ tiers on the same model at different effort levels, so the cost ladder comes from
93
+ reasoning depth rather than model size.
94
+ - **Goal-oriented prompt styles.** `promptStyle` (`auto` | `prescriptive` | `goal-oriented`),
95
+ `modelGenerations`, and `tierPromptsGoalOriented` let a tier ship a goal-oriented prompt
96
+ instead of the terse rule list. Under `auto` a tier switches to the goal-oriented text
97
+ when its model matches a declared newer generation; everything else keeps the prescriptive
98
+ prompt.
99
+ - **Session-resume accounting.** A resumed session no longer restarts its budget: the
100
+ cumulative ceiling carries across resumes, and registration now returns a `RegisterResult`
101
+ so callers can see whether a dispatch was newly counted or replayed.
102
+ - **Time-boxes on delegate, grader, and gate.** `delegateTimeoutMs` (default 600000),
103
+ `graderTimeoutMs` (default 60000), and `gateBudgetMs` (default 90000) bound each hop.
104
+ They are fail-closed: a hop that runs out of budget is reported as unmet, never as
105
+ silently satisfied.
106
+ - **Idle-TTL eviction for the delegation store.** Entries idle for more than an hour are
107
+ swept, throttled to at most one sweep every five minutes. The sweep is timer-less — it
108
+ piggybacks on store access — so it adds no background handles and nothing to unref in
109
+ tests.
110
+ - **`cwd`-scoped verification.** A delegation may carry a `cwd`, which scopes the
111
+ deterministic file checks and the grader's session lookup to that directory.
112
+ - **Evidence-grounding clauses in the medium and heavy tier prompts.** Subagents are told
113
+ to check each reported claim against a tool result from the same session and to say so
114
+ explicitly when a claim is unverified.
115
+ - **An explicit `enforcement` block in `tiers.json`.** Every key is now written out at the
116
+ value that was previously the effective default, so the shipped behavior is unchanged and
117
+ readable rather than implicit. `validateEnforcement` type-checks every shipped key.
118
+
119
+ ### Changed
120
+
121
+ - **`CAP:none` now requires a `reason:` line.** A dispatch that says `CAP:none` without a
122
+ `reason:` line in its text falls back to the tier's baseline cap instead of lifting it.
123
+ The protocol states this in two places (rule 7 and the per-dispatch paragraph), which is
124
+ the whole of this release's prompt growth: the routing protocol goes from 2,970 to 3,089
125
+ characters, and the Claude and enforcement paths grow by the same 119 characters. See the
126
+ token-overhead table in the README.
127
+ - **Under `promptStyle: "auto"`, some bundled tiers switch to goal-oriented prompts.** Tiers
128
+ whose model is `claude-fable-5` or `claude-opus-4-8` — `anthropic.heavy`, `hybrid.heavy`,
129
+ and all three `fable-effort` tiers — now receive the goal-oriented text. Set
130
+ `promptStyle` to `prescriptive` to keep the previous prompts.
131
+
132
+ ### Fixed
133
+
134
+ - **Child-session disposal is idempotent.** Disposing a session that was already disposed
135
+ is a no-op instead of throwing.
136
+ - **Gate-timeout aborts are scoped per delegation.** A gate that runs out of budget aborts
137
+ only its own delegation; concurrent delegations are no longer cancelled with it.
138
+ - **`fileExists` reasons are honest about absolute paths.** The reason string reports the
139
+ path that was actually checked rather than the relative form that was passed in.
140
+ - **No more orphan `lastTouch` entries.** Touch records are removed with their delegation
141
+ instead of accumulating for the lifetime of the process.
142
+
143
+ ### Deliberately not ported
144
+
145
+ Several things from the source branch were left behind on purpose. The **lessons memory store**
146
+ (~800 lines) has no measurement behind it — if it is revisited it must arrive opt-in and
147
+ default-false rather than as a new always-on subsystem. The **anti-context-anxiety clause**,
148
+ the **INTENT section**, and the **workspace-root line** would re-add the prose that [#21]
149
+ deliberately removed. Flipping `activePreset` to `"opus"` would change the default for every
150
+ user, and flipping `enforcement.mode` to `"enforced"` would turn an advisory layer into a
151
+ blocking one; both stay as they are. `src/guard/smoke-evidence.ts` is test-support only and
152
+ carries no runtime behavior, so it was left as optional and not ported.
153
+
154
+ ### Credits
155
+
156
+ Refactors [#26], [#27], and [#28] by Lucas Húngaro were merged while this port was in
157
+ progress, and the ported code is built on top of them.
158
+
159
+ [#26]: https://github.com/marco-jardim/opencode-model-router/pull/26
160
+ [#27]: https://github.com/marco-jardim/opencode-model-router/pull/27
161
+ [#28]: https://github.com/marco-jardim/opencode-model-router/pull/28
162
+
163
+ ## [1.5.0] - 2026-08-18
164
+
165
+ Minor release: update-safe configuration overrides, so customizations survive the plugin
166
+ updates that overwrite the cached package file.
167
+
168
+ ### Added
169
+
170
+ - **Update-safe config overrides.** `~/.config/opencode/opencode-model-router.overrides.jsonc`
171
+ (global) and `<repo>/.opencode/opencode-model-router.overrides.jsonc` (project) are
172
+ deep-merged over the bundled `tiers.json` — specify only the keys you want to change.
173
+ The project file is located by searching upward to the repo root and wins over the
174
+ global file, which wins over the bundled defaults. Models, tiers, and whole presets can
175
+ now be customized without editing the cached package file, which every plugin update
176
+ overwrites. An overrides file can also define an entirely new preset — `model` is the
177
+ only required field per tier: `costRatio`/`steps` default to the conventional `1`/`5`/`20`
178
+ and `30`/`50`/`120` by tier name when omitted, and `description`/`whenToUse` are optional.
179
+ Contributed by Lucas Húngaro. ([#22], closes [#2] and [#4])
180
+ - **JSONC in the override files.** `//` and `/* */` comments and trailing commas are
181
+ accepted, via a small zero-dependency parser (`src/router/jsonc.ts`). No new runtime
182
+ dependencies.
183
+ - **`/router overrides`** — prints the global and project override paths, which of them
184
+ exist, and the merge precedence.
185
+
186
+ ### Fixed
187
+
188
+ - **The upward search for the project override file is now bounded.** It stops at a
189
+ `.git`, `.hg`, or `.svn` marker, at 16 levels above the working directory, or at the
190
+ user's home directory. A tree containing no repo marker previously walked all the way
191
+ to the filesystem root, so running opencode from a non-repo directory could silently
192
+ adopt an unrelated ancestor's override file. `package.json` is deliberately not treated
193
+ as a repo marker: in a monorepo it would stop the walk at `packages/<pkg>/` before
194
+ reaching the repo-root `.opencode/`. ([`8710a84`])
195
+
196
+ [`8710a84`]: https://github.com/marco-jardim/opencode-model-router/commit/8710a84
197
+ [#2]: https://github.com/marco-jardim/opencode-model-router/issues/2
198
+ [#4]: https://github.com/marco-jardim/opencode-model-router/issues/4
199
+ [#22]: https://github.com/marco-jardim/opencode-model-router/pull/22
200
+
201
+ ## [1.4.0] - 2026-08-18
202
+
203
+ Minor release: session lifecycle fixes, more reliable read-only delegation, and a
204
+ smaller routing protocol with measured overhead documentation.
205
+
206
+ ### Fixed
207
+
208
+ - **Grader and producer child sessions are now parented and disposed.** The plugin
209
+ previously created backend sessions for every grader and producer attempt but never
210
+ aborted or deleted them, including on the happy path, leaving orphaned top-level
211
+ sessions in the TUI. ([`40c9b94`])
212
+ - **Layer-2 grading now skips read-only research delegations** when the DoD is inferred,
213
+ checker-only, and no files changed. This prevents false "not accepted" notes on
214
+ legitimate research results. Contributed by Lucas Húngaro. ([#20])
215
+ - README prompt-overhead figures now use measured character counts and explicit token
216
+ estimate ranges. The previous `~210 tokens` claim understated the former default
217
+ Claude path by roughly eight to nine times.
218
+
219
+ ### Added
220
+
221
+ - A drift test now pins the acceptance-check grammar shared by the `/annotate-plan`
222
+ template, `parseAcceptanceBlock`, and the delegation protocol. ([`19171ea`])
223
+
224
+ ### Changed
225
+
226
+ - **The delegation protocol was rewritten without dropping routing rules.** On the
227
+ default Claude path it is 46.6% smaller, from 7,006 to 3,742 characters. Contributed
228
+ by Lucas Húngaro. ([#21])
229
+ - **The anti-narration guardrail is now opt-in.** Set the top-level `antiNarration`
230
+ boolean to `true` to restore the prompt clause and detector; the default is `false`.
231
+ ([#21])
232
+ - The package now declares Node.js 20 or later through `engines.node`. ([`6fa9bab`])
233
+
234
+ [`19171ea`]: https://github.com/marco-jardim/opencode-model-router/commit/19171ea
235
+ [`40c9b94`]: https://github.com/marco-jardim/opencode-model-router/commit/40c9b94
236
+ [`6fa9bab`]: https://github.com/marco-jardim/opencode-model-router/commit/6fa9bab
237
+ [#20]: https://github.com/marco-jardim/opencode-model-router/pull/20
238
+ [#21]: https://github.com/marco-jardim/opencode-model-router/pull/21
239
+
240
+ ## [1.3.1] - 2026-08-16
241
+
242
+ Patch release: bug fixes, documentation, and release-engineering only. No runtime
243
+ behaviour changes beyond the corrected `github-copilot` model identifiers.
244
+
245
+ ### Fixed
246
+
247
+ - **`github-copilot` preset model IDs** now use the dot-separated form the provider
248
+ actually serves (`claude-haiku-4.5`, `claude-sonnet-4.6`, `claude-opus-4.6`) instead of
249
+ the dash-separated variants, and the non-existent `/thinking` suffix has been dropped
250
+ from the `@heavy` tier. Delegations under this preset previously referenced models that
251
+ could not be resolved. ([#10], fixes [#9])
252
+ - Golden snapshot for the `github-copilot` delegation protocol realigned with the
253
+ corrected identifiers above.
254
+
255
+ ### Added
256
+
257
+ - **Continuous integration.** A `Test` workflow runs `npm ci`, the full suite, and
258
+ `npm run typecheck` on Node 24 for every pull request and every push to `master`.
259
+ - **Automated publishing via npm Trusted Publishing (OIDC).** Pushing a `v*` tag builds
260
+ and publishes from GitHub Actions with SLSA provenance attestation and no long-lived
261
+ npm token. Third-party actions are pinned by commit SHA.
262
+ - **`package-lock.json` is now tracked**, making installs reproducible across
263
+ contributors and CI. It is not included in the published tarball.
264
+
265
+ ### Changed
266
+
267
+ - README install and configuration instructions corrected and expanded, including how the
268
+ `tiers.json` cache behaves. ([#7])
269
+ - Development dependencies `vitest` and `@vitest/coverage-v8` upgraded to 4.x. Both are
270
+ bumped in lockstep because `@vitest/coverage-v8` pins an exact `vitest` peer; Dependabot
271
+ is now configured to group them. Dev-only — no effect on the published package. ([#8])
272
+
273
+ [#7]: https://github.com/marco-jardim/opencode-model-router/pull/7
274
+ [#8]: https://github.com/marco-jardim/opencode-model-router/pull/8
275
+ [#9]: https://github.com/marco-jardim/opencode-model-router/issues/9
276
+ [#10]: https://github.com/marco-jardim/opencode-model-router/pull/10
277
+
278
+ ## [1.3.0]
279
+
280
+ ### Changed — advisory enforcement is now the default
281
+
282
+ - **Default enforcement mode flipped `off` → `advisory`.** With `enforcement.mode`
283
+ unset, every non-trivial delegation is now verified and any miss surfaces a
284
+ non-blocking forcing-note; the orchestrator system prompt grows by ~200 tokens for
285
+ the DoD/acceptance section, and subagents may receive non-blocking guard banners.
286
+ Nothing is ever hard-blocked in `advisory`. To restore the previous byte-identical
287
+ behaviour (zero added tokens, zero new latency), set `"mode": "off"` explicitly, run
288
+ `/router enforce off`, or set `MODEL_ROUTER_ENFORCE=0`.
289
+ - **The custom `delegate` tool is now hidden by default.** Delegation routes through the
290
+ native `Task()` tool so subagents render inline in the TUI instead of running in an
291
+ invisible orphan session (fixes the `delegate [tier=…, task=…]` stall). The
292
+ independently-verified `delegate` tool remains available behind an opt-in flag.
293
+ - The acceptance forcing-note now includes tier-escalation guidance
294
+ (`Task(subagent_type="<nextTier>")`) when a delegated result is not accepted.
295
+
296
+ ### Added
297
+
298
+ - `experimental.verifiedDelegateTool` config flag in `tiers.json`, and the
299
+ `MODEL_ROUTER_VERIFIED_DELEGATE=1` environment variable, to opt back into the
300
+ authoritative `delegate` tool.
301
+
302
+ ## [1.2.0]
303
+
304
+ ### Added — Enforced delegation (opt-in, default OFF)
305
+
306
+ A three-layer enforcement system that makes tiered delegation *reliable* instead of
307
+ advisory. **It is opt-in and disabled by default**: with `enforcement.mode` unset (or
308
+ `"off"`), behaviour is byte-identical to previous releases — no added prompt tokens, no
309
+ new runtime behaviour. Enable per repo via `enforcement.mode` in `tiers.json`, per run
310
+ via the `MODEL_ROUTER_ENFORCE=1` environment variable, or per session via
311
+ `/router enforce <off|advisory|enforced>`. Enforcement applies only to subagent/delegate
312
+ sessions; the orchestrator session is never gated.
313
+
314
+ - **Layer 1 — hard-block guard** (`tool.execute.before`): an in-band, throw-to-block
315
+ guard for subagent sessions. Enforces a tool-call budget ceiling, anti-redundancy
316
+ (repeated identical reads), and anti-self-script (ad-hoc `bash` execution such as
317
+ heredocs / `node -e` / `cat >`), with an optional deliverable-first rule. Writing
318
+ source files is *never* blocked by default (`blockScriptWrites` is opt-in).
319
+ `off` is a no-op, `advisory` surfaces a banner, `enforced` blocks.
320
+ - **Layer 2 — independent acceptance gate**: turns "the producer says it's done" into
321
+ "the output was objectively accepted". A Definition-of-Done is parsed from an
322
+ `[acceptance]` block (Mode B) or auto-inferred from the dispatch (Mode A) and checked
323
+ either deterministically (`run` / `fileExists` / `schemaMatch` / `testsPass` /
324
+ `buildPasses` / `lintClean` behind an allowlisted exec/fs seam) or by an **independent
325
+ grader** in a fresh session at a tier ≥ the producer's. Fail-closed: any error,
326
+ unparseable verdict, or non-independent grader counts as a failure. Never silently
327
+ accepts a non-trivial delegation that lacks a checkable DoD.
328
+ - **Layer 3 — quality-escalation ladder**: on a failed gate the authoritative `delegate`
329
+ tool retries, then escalates `fast → medium → heavy`, then returns an honest
330
+ `status: unmet` — never a fake pass. Provably terminating (bounded by
331
+ `maxAttemptsPerTier`, `maxTotalAttempts`, and a cost ceiling) and composes with the
332
+ existing advisory provider-failover chain without double-counting attempts.
333
+
334
+ ### Added — tooling & APIs
335
+
336
+ - New `delegate` tool (authoritative produce → verify → escalate in one call) alongside
337
+ the existing raw `Task()` path (advisory-grade verify-dispatch).
338
+ - New `/router enforce <off|advisory|enforced>` command (persisted atomically).
339
+ - New `enforcement` configuration block in `tiers.json` (fully validated; see
340
+ `docs/CONFIG_REFERENCE.md`). Per-mode example presets in `docs/ENFORCEMENT_PRESETS.md`.
341
+ - TypeScript + Vitest test infrastructure, golden-snapshot characterization tests, and a
342
+ coverage gate. Documentation suite: `docs/ENFORCEMENT.md`, `docs/VERIFICATION.md`,
343
+ `docs/ESCALATION.md`, `docs/CONFIG_REFERENCE.md`, `docs/MIGRATION.md`, and ADRs
344
+ `docs/adr/0000`–`0002`.
345
+
346
+ ### Security
347
+
348
+ - Secret scrubbing (`scrubText`) is applied to every model-visible string the enforcement
349
+ layers emit — forcing messages, grader prompts, scorecards, and trajectory dumps.
350
+ - The deterministic verifier runs only allowlisted binaries, rejects shell
351
+ metacharacters, and blocks interpreter eval flags (`node -e`, `python -c`, …).
352
+
353
+ ### Notes
354
+
355
+ - Default is OFF; upgrading changes nothing until you opt in. See `docs/MIGRATION.md`.
356
+ - The bundled per-mode enforcement presets are **preliminary** (tuned from fixtures, not
357
+ field telemetry) and are documented rather than written into `tiers.json`.
package/README.md CHANGED
@@ -298,6 +298,15 @@ Restart opencode after adding a new preset so its tier subagents get registered.
298
298
 
299
299
  > **`activePreset` / `activeMode` / `enforcement.mode` in an override file are _defaults_.** Runtime selections — `/preset`, `/budget`, `/router enforce` — are persisted to the state file (`~/.config/opencode/opencode-model-router.state.json`), which is applied **after** the override files and therefore wins. So the override's `activePreset` takes effect until you switch at runtime; if it ever "isn't taking", it's because a past `/preset` left a value in the state file — run `/preset <name>` again or delete that file. (The state file is machine-written, so the plugin never rewrites your hand-authored, commented override file.)
300
300
 
301
+ ### Keeping models current
302
+
303
+ You do not have to wait on a plugin release when providers ship new models. opencode already resolves a live model catalog (models.dev plus your configured and authenticated providers), and the plugin reads it directly. No external fetch, no hardcoded list.
304
+
305
+ - **`/router models [provider]`** lists the valid model ids for your configured providers, each annotated with the provider's default and any `deprecated`, `alpha` or `beta` status. Copy an id straight into an overrides file.
306
+ - **Validation.** Bare `/router` checks the active preset's tier models against the catalog and reports any that are missing or deprecated, with the closest valid suggestions. A stale id surfaces immediately instead of failing silently on every subagent dispatch. The same check is logged once per session to the plugin console.
307
+
308
+ This is report-only. The plugin never changes your models for you: it tells you what is available and what to change, and you set it in the overrides file.
309
+
301
310
  ### Advanced: edit the bundled `tiers.json` directly
302
311
 
303
312
  For an npm install, `tiers.json` is **inside the cached package directory**, not your `~/.config/opencode/` folder — typically:
@@ -310,28 +319,28 @@ For an npm install, `tiers.json` is **inside the cached package directory**, not
310
319
 
311
320
  ### Presets
312
321
 
313
- The plugin ships with four presets (switch with `/preset <name>`):
322
+ The plugin ships with six presets (switch with `/preset <name>`):
314
323
 
315
324
  **anthropic** (default):
316
325
  | Tier | Model | Cost ratio |
317
326
  |------|-------|-----------|
318
327
  | @fast | `anthropic/claude-haiku-4-5` | 1x |
319
- | @medium | `anthropic/claude-sonnet-4-5` (max) | 5x |
320
- | @heavy | `anthropic/claude-opus-4-6` (max) | 20x |
328
+ | @medium | `anthropic/claude-sonnet-4-6` (max) | 5x |
329
+ | @heavy | `anthropic/claude-opus-4-8` (max) | 20x |
321
330
 
322
331
  **openai**:
323
332
  | Tier | Model | Cost ratio |
324
333
  |------|-------|-----------|
325
- | @fast | `openai/gpt-5.3-codex-spark` | 1x |
326
- | @medium | `openai/gpt-5.3-codex` | 5x |
327
- | @heavy | `openai/gpt-5.3-codex` (xhigh) | 20x |
334
+ | @fast | `openai/gpt-5.4-mini-fast` | 1x |
335
+ | @medium | `openai/gpt-5.5-fast` (high) | 5x |
336
+ | @heavy | `openai/gpt-5.5-fast` (xhigh) | 20x |
328
337
 
329
338
  **github-copilot**:
330
339
  | Tier | Model | Cost ratio |
331
340
  |------|-------|-----------|
332
- | @fast | `github-copilot/claude-haiku-4-5` | 1x |
333
- | @medium | `github-copilot/claude-sonnet-4-5` | 5x |
334
- | @heavy | `github-copilot/claude-opus-4-6` (thinking) | 20x |
341
+ | @fast | `github-copilot/claude-haiku-4.5` | 1x |
342
+ | @medium | `github-copilot/claude-sonnet-4.6` | 5x |
343
+ | @heavy | `github-copilot/claude-opus-4.6` | 20x |
335
344
 
336
345
  **google**:
337
346
  | Tier | Model | Cost ratio |
@@ -340,6 +349,13 @@ The plugin ships with four presets (switch with `/preset <name>`):
340
349
  | @medium | `google/gemini-2.5-pro` | 5x |
341
350
  | @heavy | `google/gemini-3-pro-preview` | 20x |
342
351
 
352
+ **hybrid** — Anthropic for exploration and heavy analysis, OpenAI for implementation:
353
+ | Tier | Model | Cost ratio |
354
+ |------|-------|-----------|
355
+ | @fast | `anthropic/claude-haiku-4-5` | 1x |
356
+ | @medium | `openai/gpt-5.5-fast` (high) | 5x |
357
+ | @heavy | `anthropic/claude-opus-4-8` (max) | 20x |
358
+
343
359
  **fable-effort** — one model, three reasoning depths (see [per-tier `effort`](#per-tier-effort)):
344
360
  | Tier | Model | Effort | Cost ratio |
345
361
  |------|-------|--------|-----------|
@@ -365,7 +381,7 @@ highest first:
365
381
  |---|---|---|
366
382
  | Anthropic | `options.effort`, incl. `xhigh`/`max` | Requires the `opencode-anthropic-fix` plugin (commit `307aea9`+ for fable/mythos). Non-adaptive Claude models (e.g. haiku) silently strip `effort` at the API layer, and without the plugin a top-level `effort` can break Claude-Code billing fingerprinting. |
367
383
  | OpenAI | `options.reasoning_effort` | Supports only `low`/`medium`/`high`; `xhigh` and `max` are downgraded to `high` with a warning. |
368
- | Other (Google, Copilot, …) | nothing | Dropped with a warning — no known mapping. |
384
+ | Other (Google, …) | nothing | Dropped with a warning — no known mapping. Detection is by model family, not provider prefix, so Copilot-proxied ids (`github-copilot/gpt-4o`, `github-copilot/claude-sonnet-4`) take their family's knob above. |
369
385
 
370
386
  An out-of-set value in `tiers.json` fails validation at load; one that arrives any other
371
387
  way is ignored with a single warning. Full detail in
@@ -493,6 +509,13 @@ A "resume" is a second `chat.message` to a session already tracked at the **same
493
509
 
494
510
  The ceiling follows the *current* cap, so a tighter resumed cap tightens the ceiling. `CAP:none` has no per-dispatch budget to derive from and therefore no cumulative ceiling. A **retry** (new session, e.g. an escalation to another tier) is not a resume: it gets fresh counters and an empty redundancy map. A session evicted by the idle-TTL sweep also comes back fresh.
495
511
 
512
+ The sweep exists so per-session bookkeeping does not grow without bound in a long-running
513
+ opencode process. A session is evicted once it has been idle for **1 hour**; every mutating
514
+ entry point refreshes its stamp, and a tool call refreshes at *start* so a single long call
515
+ cannot age out mid-flight. There are no timers: the sweep runs opportunistically off chat
516
+ activity, throttled to at most once every **5 minutes**, and covers the four session-keyed
517
+ stores (subagent sessions, guard state, trajectory telemetry, and changed-file tracking).
518
+
496
519
  The same accounting exists at the hard-guard layer: `guard.budget` resets per dispatch, with a cumulative ceiling of `guard.budget × 3` enforced as `cumulative_iteration_cap`.
497
520
 
498
521
  **If you never resume a subagent session, nothing changes** — a first dispatch's cumulative count equals its per-dispatch count, so the ceiling is unreachable and every banner is byte-identical to before.
@@ -594,6 +617,46 @@ Each tier (`@fast`, `@medium`, `@heavy`) has a system prompt that describes its
594
617
 
595
618
  Two wordings of every default prompt ship: the enumerated `tierPrompts` above, and a shorter goal-oriented set. Which one a tier gets is decided by `promptStyle`, which defaults to `auto` (goal-oriented for strong models). See [Prompt styles](docs/CONFIG_REFERENCE.md#prompt-styles-promptstyle) in the config reference — including which shipped presets are affected.
596
619
 
620
+ To replace a built-in goal-oriented prompt, set `tierPromptsGoalOriented` in the overrides
621
+ file. It is the goal-oriented twin of `tierPrompts`: an entry replaces the built-in default
622
+ for that tier name only, and tiers you do not list keep theirs.
623
+
624
+ ```jsonc
625
+ {
626
+ // Only affects tiers that resolve to the goal-oriented style.
627
+ "tierPromptsGoalOriented": {
628
+ "medium": "You are @medium. Ship the change described in the dispatch, match the surrounding code, and return the files you touched plus the verification you ran."
629
+ }
630
+ }
631
+ ```
632
+
633
+ #### `modelGenerations`
634
+
635
+ `modelGenerations` holds shared, case-insensitive substring patterns matched against a
636
+ tier's model ID. Two lists exist:
637
+
638
+ | List | Default | What it drives |
639
+ |------|---------|----------------|
640
+ | `strong` | `["claude-fable-5", "claude-mythos-5", "opus-4-8"]` | `promptStyle: "auto"` resolution — a match resolves to `goal-oriented`, everything else to `prescriptive` (`isStrongModel` in `src/router/prompts.ts`). |
641
+ | `claude5x` | `["claude-fable-5", "claude-mythos-5"]` | The Claude 5.x generation list. In code it seeds the default `strong` list (`DEFAULT_STRONG_MODEL_PATTERNS` in `src/router/config.ts`), so `strong` is a superset of it by construction. |
642
+
643
+ Only `strong` is read at match time, and setting it replaces the default list outright
644
+ rather than extending it — include the built-in patterns you still want. Claude-specific
645
+ prompt prefixes and the anti-narration detector do **not** use these lists; they match the
646
+ model ID directly (`isClaudeModel` in `src/router/protocol.ts`).
647
+
648
+ ```jsonc
649
+ {
650
+ "modelGenerations": {
651
+ // Keep the shipped patterns and add a locally-hosted strong model.
652
+ "strong": ["claude-fable-5", "claude-mythos-5", "opus-4-8", "my-org/big-coder"]
653
+ }
654
+ }
655
+ ```
656
+
657
+ See [Prompt styles](docs/CONFIG_REFERENCE.md#prompt-styles-promptstyle) in the config
658
+ reference for the full description.
659
+
597
660
  **When to customize:** if a specific provider/model in a preset needs different instructions (e.g. Gemini-specific tool format, tighter/looser caps for a weaker local model), add `"prompt": "..."` on that tier only. All other presets keep using the global.
598
661
 
599
662
  ```json
@@ -688,12 +751,45 @@ When `antiNarration` is enabled, the detector runs for all models (not only Clau
688
751
  | `costRatio` | number | Relative cost (1 = cheapest). Shown in prompt. |
689
752
  | `thinking` | object | Anthropic thinking: `{ "budgetTokens": 10000 }` |
690
753
  | `reasoning` | object | OpenAI reasoning: `{ "effort": "high", "summary": "detailed" }` |
754
+ | `effort` | string | Provider-agnostic reasoning effort: `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`. See [Per-tier `effort`](#per-tier-effort). |
755
+ | `color` | string | Optional agent colour passed through to the opencode agent registration. |
691
756
  | `description` | string | Shown in `/tiers` output |
692
757
  | `steps` | number | Max agent turns |
693
758
  | `prompt` | string | Optional per-tier system prompt override. Falls back to the style-appropriate default when omitted. |
694
759
  | `promptStyle` | string | `"prescriptive"`, `"goal-oriented"` or `"auto"` (default). Picks which default prompt the tier gets; ignored when `prompt` is set. |
695
760
  | `whenToUse` | string[] | Use cases (shown in `/tiers`, not in system prompt) |
696
761
 
762
+ ### Routing your own subagents (`subagentTiers`, opt-in)
763
+
764
+ If you already have custom subagents (`.opencode/agents/**`), they do **not** get routed by default. An agent that declares no `model` inherits the model of whoever invoked it, usually your orchestrator, so a cheap read-only helper quietly runs at orchestrator prices.
765
+
766
+ `subagentTiers` maps your agent names to tiers, and the plugin repoints them at the active preset's models:
767
+
768
+ ```jsonc
769
+ {
770
+ "subagentTiers": {
771
+ "ContextScout": "fast",
772
+ "CodeReviewer": "medium",
773
+ "SecurityReviewer": "heavy"
774
+ }
775
+ }
776
+ ```
777
+
778
+ The point of doing this here rather than in `opencode.json` is that these agents then **follow `/preset`**. Switch to `openai` and `ContextScout` moves to that preset's fast model along with `@fast`. No model IDs live in your agent files, and a committed project overrides file gives the whole team the same routing.
779
+
780
+ **Getting the names right.** The key is opencode's agent name: the frontmatter `name:` field when the agent declares one, otherwise the file's path-derived name (`agents/team/helper.md` becomes `team/helper`). Frontmatter wins, so an agent in `subagents/core/contextscout.md` with `name: ContextScout` is keyed `ContextScout`. Matching is case-sensitive.
781
+
782
+ **Rules, all deliberate:**
783
+
784
+ - **Opt-in.** No map, or an empty one, and nothing is touched.
785
+ - **The map wins over the agent's own `model`.** This is the point, and it is what lets you delete hardcoded model IDs from agent files. If you want an agent to keep its pinned model, leave it out of the map.
786
+ - **List subagents only.** Primary agents are the orchestrator, so pinning one to a tier defeats the routing. Agents already registered with a non-`subagent` mode are skipped, but a *markdown* agent's mode is not visible when the map is applied, so a primary agent listed there would still be repointed.
787
+ - **Unknown tier names are skipped**, not fatal. A map written for a preset that defines a tier this one does not must never break startup.
788
+ - **Tier names are never overwritten.** An entry keyed `fast`/`medium`/`heavy` is ignored so it cannot clobber the plugin's own agents.
789
+ - **Variants are set explicitly.** If the target tier has no `variant`, any variant already on the agent is removed rather than inherited. An inherited variant from another provider fails at dispatch, not at load.
790
+
791
+ Anything not listed is left exactly as opencode built it.
792
+
697
793
  ### Fallback
698
794
 
699
795
  Defines provider fallback order when a delegated task fails:
@@ -736,6 +832,53 @@ Advisory is the default. To change the level:
736
832
 
737
833
  > Enforcement applies to subagent/delegate sessions only. The orchestrator session is never hard-blocked.
738
834
 
835
+ **Per-tier override.** `enforcement.perTier` maps a tier name to `off`, `advisory` or
836
+ `enforced` and wins over the global `mode` for delegations to that tier — useful to keep
837
+ `@fast` advisory while `@medium` and `@heavy` are enforced:
838
+
839
+ ```jsonc
840
+ {
841
+ "enforcement": {
842
+ "mode": "enforced",
843
+ "perTier": { "fast": "advisory" }
844
+ }
845
+ }
846
+ ```
847
+
848
+ #### Time-boxes
849
+
850
+ Three ceilings bound the verification pipeline so a stuck model cannot hang a delegation
851
+ forever. All are integers in milliseconds, live under `enforcement.verify`, and ship
852
+ explicitly in `tiers.json`:
853
+
854
+ | Key | Bundled default | Bounds |
855
+ |-----|-----------------|--------|
856
+ | `delegateTimeoutMs` | `600000` (10 min) | One producer turn. |
857
+ | `graderTimeoutMs` | `60000` (1 min) | One grader turn. |
858
+ | `gateBudgetMs` | `90000` (90 s) | The whole acceptance gate. |
859
+
860
+ Each budget is per **ladder attempt**, not per delegation: a fast → medium → heavy
861
+ escalation gives every attempt its own fresh clock. On expiry the child session is
862
+ cancelled for real via `session.abort` rather than left running, and the attempt is
863
+ recorded as failed so the ladder advances — an expired budget never yields a fabricated
864
+ pass, only an honest `status: unmet`.
865
+
866
+ Raise a ceiling rather than removing it; `0` and negative values are rejected by
867
+ `validateConfig`, not read as "no timeout".
868
+
869
+ ```jsonc
870
+ {
871
+ "enforcement": {
872
+ "verify": {
873
+ // A slow local model needs longer than the 10-minute default.
874
+ "delegateTimeoutMs": 1800000
875
+ }
876
+ }
877
+ }
878
+ ```
879
+
880
+ Full field notes are in [docs/CONFIG_REFERENCE.md](docs/CONFIG_REFERENCE.md).
881
+
739
882
  ### Deep-dive documentation
740
883
 
741
884
  - `docs/ENFORCEMENT.md` — architecture, hook wiring, session lifecycle
@@ -750,14 +893,16 @@ Advisory is the default. To change the level:
750
893
 
751
894
  | Command | Description |
752
895
  |---------|-------------|
753
- | `/tiers` | Show active tier configuration, models, and rules |
896
+ | `/tiers` | Show active tier configuration, models, rules, and each tier's resolved prompt style |
754
897
  | `/preset` | List available presets |
755
898
  | `/preset <name>` | Switch preset (e.g., `/preset openai`) |
756
899
  | `/budget` | Show available modes and which is active |
757
900
  | `/budget <mode>` | Switch routing mode (`normal`, `budget`, `quality`, `deep`) |
758
901
  | `/annotate-plan [path]` | Annotate a plan file with `[tier:X]` tags for each step |
759
902
  | `/router overrides` | Show the global + project override file paths and merge precedence |
903
+ | `/router models [provider]` | List valid model ids from your configured providers (with defaults and deprecated flags) |
760
904
  | `/router enforce <off\|advisory\|enforced>` | Set delegation-enforcement mode (persisted) |
905
+ | `/router` | With no subcommand — or an unrecognized one — prints the `/router` help and the current enforcement mode |
761
906
  | `/bypass [on\|off]` | Toggle the router off/on for the session |
762
907
 
763
908
  ## Plan annotation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-model-router",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "OpenCode plugin that routes tasks to tiered subagents (fast/medium/heavy) based on complexity",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -41,7 +41,8 @@
41
41
  "src/",
42
42
  "tiers.json",
43
43
  "LICENSE",
44
- "README.md"
44
+ "README.md",
45
+ "CHANGELOG.md"
45
46
  ],
46
47
  "peerDependencies": {
47
48
  "@opencode-ai/plugin": ">=1.0.0"