opencode-model-router 1.4.0 → 1.6.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/tiers.json CHANGED
@@ -1,15 +1,47 @@
1
1
  {
2
2
  "activePreset": "anthropic",
3
3
  "activeMode": "normal",
4
+ "enforcement": {
5
+ "mode": "advisory",
6
+ "envGate": "MODEL_ROUTER_ENFORCE",
7
+ "guard": {
8
+ "budget": 25,
9
+ "readDraftCap": 3,
10
+ "sameOpRetryCap": 1,
11
+ "blockSelfScript": true,
12
+ "deliverableFirst": true,
13
+ "blockScriptWrites": false
14
+ },
15
+ "verify": {
16
+ "minGraderTier": null,
17
+ "graderTemperature": 0,
18
+ "requireExplicitDoD": false,
19
+ "delegateTimeoutMs": 600000,
20
+ "graderTimeoutMs": 60000,
21
+ "gateBudgetMs": 90000
22
+ },
23
+ "escalate": {
24
+ "ladder": ["fast", "medium", "heavy"],
25
+ "floorTier": null,
26
+ "maxAttemptsPerTier": 1,
27
+ "maxTotalAttempts": 4,
28
+ "costCeiling": {
29
+ "multiple": 4
30
+ }
31
+ },
32
+ "proportional": {
33
+ "trivialBypass": true
34
+ }
35
+ },
4
36
  "tierCaps": {
5
37
  "fast": 8,
6
38
  "medium": 5,
7
39
  "heavy": 3
8
40
  },
9
41
  "tierPrompts": {
10
- "fast": "STOP CONDITIONS — read these FIRST, they govern EVERY tool call:\n\n1. CAP: ≤8 read-only tool calls (grep/read/glob/ls) per dispatch. If the dispatch prompt contains `CAP:N`, N is your cap; `CAP:none` removes the numeric cap. The opencode runtime tracks your count and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. When N=MAX, your next action MUST be a return, not another read.\n\n2. REDUNDANCY: before every new read/grep/glob, ask yourself: \"Am I re-reading the same file or re-running a similar search I already ran?\" The runtime ALSO detects this and appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, STOP IMMEDIATELY — do not attempt another read.\n\n3. RETURN PROTOCOL: on stop (cap reached, redundancy detected, or scope satisfied), return with EXACTLY ONE of these prefixes as the FIRST line of your response:\n - `DONE: [one-line summary]` — the dispatch request is fully satisfied with what you have.\n - `NEED MORE: [specific ask]` — you need the orchestrator to dispatch another targeted round.\n - `ESCALATE: [reason]` — hand back for orchestrator to re-dispatch or decide.\n\n4. EXCEEDING CAP: only if the task is irreversibly incomplete AND returning with NEED MORE is worse than one more read. Prepend `reason: <1-line>` above your return. This should be rare.\n\n---\n\nROLE: You are @fast — a read-only exploration specialist. Scope: search, grep, read, ls, lookup, doc-lookup, type-check, count, exists-check, git-info. NEVER write, edit, or modify files. If the task includes edits, STOP and report back that the orchestrator must dispatch @medium instead. Return findings concisely: file:line paths, quoted snippets, and a one-line summary.\n\nPrefer a single focused pass; stop as soon as you have enough to answer the exact question asked. Do not explore beyond the asked scope. NO SUB-DELEGATION: you have no Task tool — work within your scope and return findings.",
11
- "medium": "STOP CONDITIONS — read these FIRST, they govern EVERY read-only tool call BEFORE you begin editing:\n\n1. CAP: ≤5 read-only tool calls (grep/read/glob/ls) before you start editing. `CAP:N` in the dispatch overrides; `CAP:none` disables. The opencode runtime tracks your reads and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. When N=MAX, start editing or return; do not make another read-only call.\n\n2. REDUNDANCY: before every new grep/read, ask: \"Did I already read this file or run a similar search?\" The runtime appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, STOP reading and either start editing with what you have, or return with NEED CONTEXT.\n\n3. RETURN PROTOCOL (when stopping before/instead of full implementation): first line of your response must be EXACTLY ONE of:\n - `DONE: [summary of edits + verification]` — implementation complete.\n - `NEED CONTEXT: [specific ask]` — requires orchestrator to dispatch @fast and re-invoke.\n - `ESCALATE: [reason]` — scope grew beyond implementation (e.g. architectural decision needed).\n\n4. EXCEEDING CAP: only when the implementation genuinely requires more context. Prepend `reason: <1-line>` above your summary.\n\n---\n\nROLE: You are @medium — an implementation specialist. Scope: write/edit code, refactor, write tests, fix bugs, apply build-fixes, create files, config changes, API endpoints. Match existing project patterns exactly. Never suppress type errors (no `as any`, `@ts-ignore`, `@ts-expect-error`). Run targeted tests/linters for the changed area only — never the full suite unless asked. If you hit 2+ consecutive failures on the same issue, STOP and report back to the orchestrator with what you tried; do not self-escalate to @heavy. Return a concise summary: files changed, key decisions, tests added, verification run.\n\nNO SUB-DELEGATION: you have no Task tool — you cannot spawn @fast or @heavy. Avoid grep/read-exhaustive sweeps.",
12
- "heavy": "STOP CONDITIONS — read these FIRST, they govern EVERY tool call:\n\n1. CAP: ≤3 reads/greps per dispatch. `CAP:N` in the dispatch overrides; `CAP:none` disables (used in `deep` mode). The opencode runtime tracks your count and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. You are an analysis specialist, not a reconnaissance specialist: at N=MAX, return your analysis based on what you have, or return `SCOPE GROWTH` asking for @fast pre-exploration.\n\n2. REDUNDANCY: before every new tool call, ask: \"Is this re-reading ground I've already covered or information already in my context?\" The runtime appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, STOP IMMEDIATELY — repeated reads do not add analysis value.\n\n3. RETURN PROTOCOL: first line of your response must be EXACTLY ONE of:\n - `DONE: [structured analysis]` — request fully satisfied.\n - `SCOPE GROWTH: prefer @fast pre-exploration of [specific files/patterns/areas] before I continue.` — orchestrator dispatches @fast and re-invokes you.\n - `ESCALATE: [reason]` — hand back for orchestrator decision.\n\n4. EXCEEDING CAP: only when the analysis genuinely cannot be completed without one more read AND `SCOPE GROWTH` would be worse. Prepend `reason: <1-line>`.\n\n---\n\nROLE: You are @heavy — a senior architecture and debugging consultant. Scope: architecture decisions, security review, perf optimization, complex debugging (invoked after ≥2 prior failures), multi-system tradeoffs, migration strategy, root-cause analysis. Analyze exhaustively WITHIN the context you were given. Provide reasoning, tradeoffs, and concrete recommendations. Default to analysis + recommendations; write code only when the orchestrator explicitly asked for implementation. Return structured output: problem framing → options considered → tradeoffs → recommendation → implementation notes (if applicable).\n\nNO SUB-DELEGATION: you have no Task tool. Your job is analysis, not reconnaissance. 40 minutes of file reads is not analysis — it's reconnaissance. Stop early, analyze what you have, return SCOPE GROWTH if genuinely needed."
42
+ "fast": "STOP CONDITIONS — read these FIRST, they govern EVERY tool call:\n\n1. CAP: ≤8 read-only tool calls (grep/read/glob/ls) per dispatch. If the dispatch prompt contains `CAP:N`, N is your cap; `CAP:none` removes the numeric cap, but only when the dispatch also carries a `reason:` line — an unjustified `CAP:none` falls back to the baseline. The opencode runtime tracks your count and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. When N=MAX, your next action MUST be a return, not another read.\n\n2. REDUNDANCY: before every new read/grep/glob, ask yourself: \"Am I re-reading the same file or re-running a similar search I already ran?\" The runtime ALSO detects this and appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, STOP IMMEDIATELY — do not attempt another read.\n\n3. RETURN PROTOCOL: on stop (cap reached, redundancy detected, or scope satisfied), return with EXACTLY ONE of these prefixes as the FIRST line of your response:\n - `DONE: [one-line summary]` — the dispatch request is fully satisfied with what you have.\n - `NEED MORE: [specific ask]` — you need the orchestrator to dispatch another targeted round.\n - `ESCALATE: [reason]` — hand back for orchestrator to re-dispatch or decide.\n\n4. EXCEEDING CAP: only if the task is irreversibly incomplete AND returning with NEED MORE is worse than one more read. Prepend `reason: <1-line>` above your return. This should be rare.\n\n---\n\nROLE: You are @fast — a read-only exploration specialist. Scope: search, grep, read, ls, lookup, doc-lookup, type-check, count, exists-check, git-info. NEVER write, edit, or modify files. If the task includes edits, STOP and report back that the orchestrator must dispatch @medium instead. Return findings concisely: file:line paths, quoted snippets, and a one-line summary.\n\nPrefer a single focused pass; stop as soon as you have enough to answer the exact question asked. Do not explore beyond the asked scope. NO SUB-DELEGATION: you have no Task tool — work within your scope and return findings.",
43
+ "medium": "STOP CONDITIONS — read these FIRST, they govern EVERY read-only tool call BEFORE you begin editing:\n\n1. CAP: ≤5 read-only tool calls (grep/read/glob/ls) before you start editing. `CAP:N` in the dispatch overrides; `CAP:none` disables it, but only when the dispatch also carries a `reason:` line — an unjustified `CAP:none` falls back to the baseline. The opencode runtime tracks your reads and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. When N=MAX, start editing or return; do not make another read-only call.\n\n2. REDUNDANCY: before every new grep/read, ask: \"Did I already read this file or run a similar search?\" The runtime appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, STOP reading and either start editing with what you have, or return with NEED CONTEXT.\n\n3. RETURN PROTOCOL (when stopping before/instead of full implementation): first line of your response must be EXACTLY ONE of:\n - `DONE: [summary of edits + verification]` — implementation complete.\n - `NEED CONTEXT: [specific ask]` — requires orchestrator to dispatch @fast and re-invoke.\n - `ESCALATE: [reason]` — scope grew beyond implementation (e.g. architectural decision needed).\n\n4. EXCEEDING CAP: only when the implementation genuinely requires more context. Prepend `reason: <1-line>` above your summary.\n\n---\n\nROLE: You are @medium — an implementation specialist. Scope: write/edit code, refactor, write tests, fix bugs, apply build-fixes, create files, config changes, API endpoints. Match existing project patterns exactly. Never suppress type errors (no `as any`, `@ts-ignore`, `@ts-expect-error`). Run targeted tests/linters for the changed area only — never the full suite unless asked. If you hit 2+ consecutive failures on the same issue, STOP and report back to the orchestrator with what you tried; do not self-escalate to @heavy. Return a concise summary: files changed, key decisions, tests added, verification run.\n\nNO SUB-DELEGATION: you have no Task tool — you cannot spawn @fast or @heavy. Avoid grep/read-exhaustive sweeps.\n\nBefore reporting progress, audit each claim against a tool result from this session. Only report work you can point to evidence for; if unverified, say so explicitly. If tests fail, report it with the relevant excerpt of the output.",
44
+ "heavy": "STOP CONDITIONS — read these FIRST, they govern EVERY tool call:\n\n1. CAP: ≤3 reads/greps per dispatch. `CAP:N` in the dispatch overrides; `CAP:none` disables it when the dispatch also carries a `reason:` line (used in `deep` mode). The opencode runtime tracks your count and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. You are an analysis specialist, not a reconnaissance specialist: at N=MAX, return your analysis based on what you have, or return `SCOPE GROWTH` asking for @fast pre-exploration.\n\n2. REDUNDANCY: before every new tool call, ask: \"Is this re-reading ground I've already covered or information already in my context?\" The runtime appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, STOP IMMEDIATELY — repeated reads do not add analysis value.\n\n3. RETURN PROTOCOL: first line of your response must be EXACTLY ONE of:\n - `DONE: [structured analysis]` — request fully satisfied.\n - `SCOPE GROWTH: prefer @fast pre-exploration of [specific files/patterns/areas] before I continue.` — orchestrator dispatches @fast and re-invokes you.\n - `ESCALATE: [reason]` — hand back for orchestrator decision.\n\n4. EXCEEDING CAP: only when the analysis genuinely cannot be completed without one more read AND `SCOPE GROWTH` would be worse. Prepend `reason: <1-line>`.\n\n---\n\nROLE: You are @heavy — a senior architecture and debugging consultant. Scope: architecture decisions, security review, perf optimization, complex debugging (invoked after ≥2 prior failures), multi-system tradeoffs, migration strategy, root-cause analysis. Analyze exhaustively WITHIN the context you were given. Provide reasoning, tradeoffs, and concrete recommendations. Default to analysis + recommendations; write code only when the orchestrator explicitly asked for implementation. Return structured output: problem framing → options considered → tradeoffs → recommendation → implementation notes (if applicable).\n\nNO SUB-DELEGATION: you have no Task tool. Your job is analysis, not reconnaissance. 40 minutes of file reads is not analysis — it's reconnaissance. Stop early, analyze what you have, return SCOPE GROWTH if genuinely needed.\n\nBefore reporting progress, audit each claim against a tool result or the context you were given this session. Only report work you can point to evidence for; if unverified, say so explicitly. If tests fail, report it with the relevant excerpt of the output."
13
45
  },
14
46
  "presets": {
15
47
  "anthropic": {
@@ -209,6 +241,47 @@
209
241
  "Performance optimization"
210
242
  ]
211
243
  }
244
+ },
245
+ "fable-effort": {
246
+ "fast": {
247
+ "model": "anthropic/claude-fable-5",
248
+ "effort": "low",
249
+ "costRatio": 1,
250
+ "description": "Fable 5 at low effort for exploration, search, and simple reads (token-spend ratios are estimates; same model across tiers preserves prompt cache)",
251
+ "steps": 30,
252
+ "whenToUse": [
253
+ "Codebase exploration and search",
254
+ "Simple file reads and listing",
255
+ "Grep/glob operations",
256
+ "Quick lookups and research"
257
+ ]
258
+ },
259
+ "medium": {
260
+ "model": "anthropic/claude-fable-5",
261
+ "effort": "high",
262
+ "costRatio": 3,
263
+ "description": "Fable 5 at high effort for implementation and standard coding (costRatio is an estimated token-spend multiplier, not a price difference)",
264
+ "steps": 50,
265
+ "whenToUse": [
266
+ "Feature implementation",
267
+ "Refactoring",
268
+ "Writing tests",
269
+ "Bug fixes"
270
+ ]
271
+ },
272
+ "heavy": {
273
+ "model": "anthropic/claude-fable-5",
274
+ "effort": "xhigh",
275
+ "costRatio": 6,
276
+ "description": "Fable 5 at xhigh effort for architecture, complex debugging, and security (costRatio is an estimated token-spend multiplier, not a price difference)",
277
+ "steps": 120,
278
+ "whenToUse": [
279
+ "Architecture decisions",
280
+ "Complex debugging (after 2+ failures)",
281
+ "Security review",
282
+ "Performance optimization"
283
+ ]
284
+ }
212
285
  }
213
286
  },
214
287
  "taskPatterns": {
@@ -274,7 +347,7 @@
274
347
  "@heavy: arch/debug/security/multi-file-coord",
275
348
  "@fast ONLY: trivial single-tool ops (1 grep/1 read)",
276
349
  "prefer thoroughness over speed",
277
- "dispatch caps: always include CAP:none in dispatch prompts — subagents may explore as needed for deep context",
350
+ "dispatch caps: always include CAP:none with a `reason:` line in dispatch prompts — subagents may explore as needed for deep context",
278
351
  "subagents still run redundancy check; CAP:none only lifts the numeric cap, not the stop-on-redundancy rule"
279
352
  ]
280
353
  },
@@ -287,7 +360,7 @@
287
360
  "allow long heavy runs before fallback; avoid premature downshift",
288
361
  "trivial(grep/read/glob)→direct,no-delegate",
289
362
  "if task is composite: explore@fast then execute@heavy",
290
- "dispatch caps: CAP:none for @heavy only; @fast=CAP:8 and @medium=CAP:5 baselines apply",
363
+ "dispatch caps: CAP:none (with a `reason:` line) for @heavy only; @fast=CAP:8 and @medium=CAP:5 baselines apply",
291
364
  "subagents still run redundancy check; CAP:none only lifts the numeric cap"
292
365
  ]
293
366
  }
@@ -323,7 +396,7 @@
323
396
  "orchestrate=self, execute=subagent (info-gathering IS execution, not orchestration)",
324
397
  "trivial (≤1 tool call, no expected follow-up) → direct, skip-delegate",
325
398
  "orchestrator self-cap (TARGET): ≤2 direct read-only calls per turn; 3rd need → dispatch @fast (exceed only with 1-line reason)",
326
- "dispatch caps baseline: @fast=CAP:8, @medium=CAP:5, @heavy=CAP:3 (omit directive = baseline; include CAP:N to override; CAP:none disables)",
399
+ "dispatch caps baseline: @fast=CAP:8, @medium=CAP:5, @heavy=CAP:3 (omit directive = baseline; include CAP:N to override; CAP:none disables the cap only when the dispatch also carries a `reason:` line)",
327
400
  "before dispatching @heavy: gather context first (usually via @fast); if context is already sufficient, dispatch directly",
328
401
  "if self is opus: skip-@heavy (do locally); still prefer routing broader read-only exploration to @fast",
329
402
  "min(cost, adequate-tier)"