opencode-model-router 1.12.1 → 1.13.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 CHANGED
@@ -5,6 +5,74 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.13.0] - 2026-09-24
9
+
10
+ A forced delegation of a request that carries no task produced a `task` call with no
11
+ prompt, which the harness rejected with a terse schema error. The router now repairs
12
+ such calls or refuses them readably. This release also gives the orchestrator's
13
+ read-only allowance a single consistent statement, and stops explicit thinking and
14
+ reasoning fields from reaching Claude models that cannot use them.
15
+
16
+ ### Added
17
+
18
+ - **`taskPromptRepair` fills in or refuses prompt-less `task` calls.** A forced
19
+ delegation of a request that carries no task — a bare greeting sent through an
20
+ explicit tier mention, say — made the model emit a `task` call with a description
21
+ and a tier but no prompt, and the harness rejected it with a bare schema error
22
+ naming the missing key. The `task` before-hook now repairs the call ahead of the
23
+ dispatch header: when `prompt` is absent, `null` or blank and `description` is a
24
+ non-empty string, the trimmed description becomes the prompt and the call proceeds
25
+ with the dispatch header applied normally. When there is no usable description the
26
+ call is refused with a `[router]` error saying that `task` needs a non-empty
27
+ `prompt`, and that a request carrying no task (a greeting, an acknowledgement)
28
+ should be answered directly rather than delegated. A prompt of a non-string type
29
+ is left for the harness, and frozen args that cannot be repaired are left alone.
30
+ The flag defaults to `true`; set `taskPromptRepair: false` to restore the previous
31
+ behaviour. Non-boolean values are rejected by `validateConfig`. See
32
+ `docs/CONFIG_REFERENCE.md`.
33
+
34
+ ### Changed
35
+
36
+ - **The orchestrator's read-only allowance is stated as one mechanism.** The injected
37
+ protocol gave the same rule three incompatible readings: the orchestrator line said
38
+ information-gathering should be dispatched to @fast rather than run directly, then
39
+ capped direct read-only calls at about two per turn, and the rules array added a
40
+ separate licence for trivial single-call work that acknowledged neither. Dispatch
41
+ is now the stated default, and direct calls are a named allowance for lookups that
42
+ settle a question outright; the trivial-work rules in the shipped `tiers.json` now
43
+ spend that allowance instead of competing with it, and the per-mode overrides are
44
+ reconciled the same way. No cap number moved: the base allowance is still two,
45
+ budget mode is still one, and the dispatch baselines are unchanged. Only the
46
+ protocol prose changed, so the injected prompt and the README's measured
47
+ prompt-size figures move by the length of the new wording. The README's sample
48
+ rules line is regenerated from the shipped configuration; it had shown eight rules
49
+ where the shipped array has ten.
50
+
51
+ ### Fixed
52
+
53
+ - **The invalid-effort warning goes through the plugin logger.** Every other
54
+ `buildAgentOptions` warning passed the plugin logger, but an unrecognised `effort`
55
+ value always went to `console.warn`, even when a logger was supplied. It now uses
56
+ the logger like its siblings; without one the behaviour is unchanged.
57
+
58
+ - **Explicit `thinking` and `reasoning` fields are gated for Claude models.**
59
+ `buildAgentOptions` emitted `budget_tokens` and `reasoning_effort` /
60
+ `reasoning_summary` without consulting the model, so a tier on an adaptive-only
61
+ model — the bundled `anthropic` preset's `@medium` is `anthropic/claude-opus-5-5` —
62
+ that also set `thinking.budgetTokens` registered a manual thinking budget on a model
63
+ that only accepts adaptive thinking (the HTTP 400 this is said to cause is reported,
64
+ not reproduced here; see the provider gate in `docs/CONFIG_REFERENCE.md`), and the
65
+ budget outranked the `effort` that would have applied. A Claude tier now never
66
+ registers `reasoning_*` (OpenAI parameters), and a tier on a model whose wire-compat
67
+ catalogue entry carries `rejects_disabled_thinking` (`claude-opus-5-5`,
68
+ `claude-fable-5`, `claude-fable-5-1`, `claude-mythos-5-1`, matched by the new
69
+ `isAdaptiveOnlyClaudeModel`) never registers `budget_tokens`; the budget is then
70
+ treated as unset, so `effort` still applies. Each drop warns once per tier.
71
+ Non-Claude tiers are unchanged. Ids of the form
72
+ `<provider>/<namespace>.claude-…`, such as `bedrock/us.anthropic.claude-…`, are not
73
+ recognised as Claude, so they get no Claude prompt prefix, no Anthropic effort
74
+ routing and no gate; the README had claimed they were detected and now says so.
75
+
8
76
  ## [1.12.1] - 2026-09-23
9
77
 
10
78
  The delegate instruction filter introduced in 1.12.0 never removed anything in a live
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **Use the cheapest model that can do the job. Automatically.**
6
6
 
7
- An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,120–5,111 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
7
+ An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,238–5,229 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
8
8
 
9
9
  ## Why it's different
10
10
 
@@ -14,7 +14,7 @@ Most AI coding tools give you one model for everything. You pay Opus prices to r
14
14
  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.
15
15
 
16
16
  **Inject a compressed, LLM-optimized routing protocol.**
17
- Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,120 characters; a Claude orchestrator receives 3,892 characters after its authority prefix (roughly 965–1,075 tokens at 3.6–4.0 characters per token). Every message, every session.
17
+ Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,238 characters; a Claude orchestrator receives 4,010 characters after its authority prefix (roughly 1,000–1,115 tokens at 3.6–4.0 characters per token). Every message, every session.
18
18
 
19
19
  **Match task to tier using a configurable taxonomy.**
20
20
  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.
@@ -67,7 +67,7 @@ opencode-model-router injects a **delegation protocol** into the system prompt t
67
67
  4. **Never over-qualify** — use the cheapest tier that can reliably handle the task
68
68
  5. **Fallback** across providers when one fails
69
69
 
70
- All of this adds 3,120 characters for a non-Claude orchestrator or 3,892 characters for a Claude orchestrator (roughly 770–1,075 tokens at 3.6–4.0 characters per token).
70
+ All of this adds 3,238 characters for a non-Claude orchestrator or 4,010 characters for a Claude orchestrator (roughly 810–1,115 tokens at 3.6–4.0 characters per token).
71
71
 
72
72
  ## Understanding how it works
73
73
 
@@ -168,7 +168,7 @@ Task distribution: 18 exploration (60%), 10 implementation (33%), 2 architecture
168
168
 
169
169
  ## How it works
170
170
 
171
- On every message, the plugin injects a 3,120-character routing protocol. A Claude orchestrator receives 3,892 characters after its authority prefix (roughly 965–1,075 tokens at 3.6–4.0 characters per token). 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.
171
+ On every message, the plugin injects a 3,238-character routing protocol. A Claude orchestrator receives 4,010 characters after its authority prefix (roughly 1,000–1,115 tokens at 3.6–4.0 characters per token). 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.
172
172
 
173
173
  What the orchestrator sees (Anthropic preset, normal mode):
174
174
 
@@ -177,7 +177,7 @@ What the orchestrator sees (Anthropic preset, normal mode):
177
177
  Preset: anthropic. Tiers: @fast=claude-sonnet-5(1x) @medium=claude-opus-5/high(5x) @heavy=claude-fable-5/max(20x). mode:normal
178
178
  R: @fast→search/grep/read/git-info/ls/lookup-docs/types/count/exists-check/rename @medium→impl-feature/refactor/write-tests/bugfix(≤2)/edit-logic/code-review/build-fix/create-file/db-migrate/api-endpoint/config-update @heavy→arch-design/debug(≥3fail)/sec-audit/perf-opt/migrate-strategy/multi-system-integration/tradeoff-analysis/rca
179
179
  Multi-phase: prefer explore(@fast)→execute(@medium) when phases are separable. Cheapest-first when practical.
180
- 1.[tier:X] tag in plan→delegate X 2.plan:fast/cheap→@fast | plan:medium→@medium | plan:heavy→@heavy 3.default preference: read-only→@fast | implementation→@medium 4.orchestrate=self,execute=subagent 5.trivial(≤1 tool call,no expected follow-up)→direct,skip-delegate 6.before @heavy: gather context first(usually via @fast); if already sufficient, dispatch directly 7.if self is opus: skip-@heavy(do locally), still route broader read-only exploration to @fast 8.min(cost,adequate-tier)
180
+ 1.[tier:X] tag in plan → delegate to X 2.plan:fast/cheap→@fast | plan:medium→@medium | plan:heavy→@heavy 3.default preference: read-only work → @fast; implementation → @medium 4.orchestrate=self, execute=subagent (info-gathering IS execution, not orchestration) 5.trivial (≤1 tool call, no expected follow-up) → direct, spent from the orchestrator read-only allowance 6.orchestrator read-only allowance (TARGET): dispatch is default; ≤2 direct read-only calls per turn; 3rd need → dispatch @fast (exceed only with 1-line reason) 7.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) 8.before dispatching @heavy: gather context first (usually via @fast); if context is already sufficient, dispatch directly 9.if self is opus: skip-@heavy (do locally); still prefer routing broader read-only exploration to @fast 10.min(cost, adequate-tier)
181
181
  Err→retry-alt-tier→fail→direct. Chain: anthropic→openai→google→github-copilot
182
182
  Delegate with Task(subagent_type="fast|medium|heavy", prompt="...").
183
183
  Keep orchestration and final synthesis in the primary agent.
@@ -220,7 +220,7 @@ With router → split:
220
220
  | Cross-provider fallback | ✅ | ❌ | ❌ | ❌ | ❌ |
221
221
  | Cost ratio awareness | ✅ | ❌ | ❌ | ❌ | ❌ |
222
222
  | Plan annotation with tiers | ✅ | ❌ | ❌ | ❌ | ❌ |
223
- | Measured prompt overhead: 3,120–5,111 chars | ✅ | — | ❌ | ❌ | ❌ |
223
+ | Measured prompt overhead: 3,238–5,229 chars | ✅ | — | ❌ | ❌ | ❌ |
224
224
 
225
225
  **Claude native**: single model for everything, no cost routing. If you're using claude.ai or OpenCode without plugins, you're paying the same price for `grep` as for architecture design.
226
226
 
@@ -481,7 +481,7 @@ Switch with `/budget <mode>`. Mode is persisted across restarts.
481
481
  "default→@medium for implementation and multi-file changes",
482
482
  "@heavy for architecture/debug/security/tradeoff-analysis by default",
483
483
  "allow long heavy runs before fallback; avoid premature downshift",
484
- "trivial(grep/read/glob)→direct,no-delegate",
484
+ "trivial(grep/read/glob)→direct,spends orchestrator read-only allowance",
485
485
  "if task is composite and phases are separable: prefer explore@fast then execute@heavy"
486
486
  ]
487
487
  }
@@ -530,7 +530,7 @@ The `rules` array is injected verbatim (in compact form) into the system prompt.
530
530
  "plan:fast/cheap→@fast | plan:medium→@medium | plan:heavy→@heavy",
531
531
  "default preference: read-only work → @fast; implementation → @medium",
532
532
  "orchestrate=self,delegate=exec",
533
- "trivial (≤1 tool call, no expected follow-up) → direct, skip-delegate",
533
+ "trivial (≤1 tool call, no expected follow-up) → direct, spent from the orchestrator read-only allowance",
534
534
  "before dispatching @heavy: gather context first (usually via @fast); if context is already sufficient, dispatch directly",
535
535
  "if self is opus: skip-@heavy (do locally); still prefer routing broader read-only exploration to @fast",
536
536
  "min(cost,adequate-tier)"
@@ -544,7 +544,7 @@ Rules in `modes[x].overrideRules` replace this array entirely for that mode.
544
544
 
545
545
  Subagents carry a cap on their own read-only tool calls (grep/read/glob/ls) per dispatch. Enforcement is **two-layered**: prompt-level stop rules + runtime banners injected into tool results. Baselines (configurable via `tierCaps` — see below):
546
546
 
547
- | Tier | Baseline cap | Orchestrator self-cap |
547
+ | Tier | Baseline cap | Orchestrator allowance |
548
548
  |------|-------------:|----------------------:|
549
549
  | `@fast` | 8 | — |
550
550
  | `@medium` | 5 | — |
@@ -645,7 +645,7 @@ This keeps subagents from burning tokens on repeated lookups when they already h
645
645
 
646
646
  **Mode interactions:**
647
647
 
648
- | Mode | Dispatch directive | Orchestrator self-cap |
648
+ | Mode | Dispatch directive | Orchestrator allowance |
649
649
  |------|-------------------|-----------------------|
650
650
  | `normal` | baselines (omit directive) | ≤2 direct reads |
651
651
  | `budget` | `CAP:5` @fast, `CAP:2` @medium, `CAP:2` @heavy | ≤1 direct read |
@@ -765,7 +765,7 @@ Detection is by model string, not preset. A `hybrid` preset that mixes providers
765
765
 
766
766
  - `anthropic/<anything>` → Claude
767
767
  - `<provider>/claude-<anything>` (e.g. `github-copilot/claude-sonnet-4-6`) → Claude
768
- - `<provider>/<namespace>.claude-<anything>` (e.g. `bedrock/us.anthropic.claude-3-5-sonnet-...`) → Claude
768
+ - `<provider>/<namespace>.claude-<anything>` (e.g. `bedrock/us.anthropic.claude-3-5-sonnet-...`) → **not** detected: the dot before `claude-` does not satisfy the rule, so such tiers are treated as non-Claude (no Claude prefix, no Anthropic `effort` routing, no provider gate)
769
769
  - Everything else → untouched
770
770
 
771
771
  No configuration is needed — the prefixes are always applied for Claude-backed tiers. If you want to disable them, override the tier's `prompt` field (per-tier overrides replace the whole prompt, including the prefix).
@@ -995,7 +995,7 @@ After `/annotate-plan`:
995
995
 
996
996
  ## Token overhead
997
997
 
998
- Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,120 characters for a non-Claude orchestrator. A Claude orchestrator receives 3,892 characters after its authority prefix, or 5,111 characters when the 1,219-character DoD/enforcement section is enabled. That is roughly 780–1,420 tokens across the three paths at 3.6–4.0 characters per token. The optional anti-narration clause adds another 650 characters to the Claude path.
998
+ Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,238 characters for a non-Claude orchestrator. A Claude orchestrator receives 4,010 characters after its authority prefix, or 5,229 characters when the 1,219-character DoD/enforcement section is enabled. That is roughly 810–1,450 tokens across the three paths at 3.6–4.0 characters per token. The optional anti-narration clause adds another 650 characters to the Claude path.
999
999
 
1000
1000
  These are character counts of the prompts the shipped config actually produces, so they move whenever the protocol text does. `test/unit/docs-drift.test.ts` recomputes all three from `tiers.json` on every run and fails unless this section still quotes them, so a change that grows the protocol cannot land without updating these numbers.
1001
1001
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-model-router",
3
- "version": "1.12.1",
3
+ "version": "1.13.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",
package/src/index.ts CHANGED
@@ -899,6 +899,37 @@ const ModelRouterPlugin: Plugin = async (ctx: PluginInput) => {
899
899
  }));
900
900
  }
901
901
  }
902
+ // A task call with no prompt (typically a forced delegation of a bare
903
+ // greeting) is otherwise rejected by the harness with a terse schema
904
+ // error. Repair it from the description, or refuse it readably. The
905
+ // refusal is computed inside the best-effort try and thrown outside it,
906
+ // so the catch can never swallow it.
907
+ let promptRefusal: string | null = null;
908
+ try {
909
+ if (input?.tool === "task" && cfg.taskPromptRepair !== false) {
910
+ const rawArgs: unknown = output?.args;
911
+ if (rawArgs && typeof rawArgs === "object" && !Array.isArray(rawArgs)) {
912
+ const args = rawArgs as Record<string, unknown>;
913
+ // Only an absent or blank prompt is repaired; a non-string prompt of
914
+ // some other type is a different malformation left to the harness.
915
+ const rawPrompt = args.prompt;
916
+ if (rawPrompt === undefined || rawPrompt === null || (typeof rawPrompt === "string" && rawPrompt.trim() === "")) {
917
+ const description = typeof args.description === "string" ? args.description.trim() : "";
918
+ if (description) {
919
+ args.prompt = description;
920
+ } else {
921
+ promptRefusal = "[router] This task call carried no prompt, and the task tool needs a non-empty `prompt` " +
922
+ "stating the work for the delegate. Re-issue the call with the work restated as an instruction in " +
923
+ "`prompt`. If the request carries no task at all (a greeting, an acknowledgement), do not delegate: " +
924
+ "answer it directly instead.";
925
+ }
926
+ }
927
+ }
928
+ }
929
+ } catch {
930
+ // Best-effort: malformed or frozen args must never break a dispatch.
931
+ }
932
+ if (promptRefusal) throw new Error(promptRefusal);
902
933
  // Dispatch hygiene is independent of subagent guard enforcement below.
903
934
  // The plugin API declares generic args, not a task-specific argument shape.
904
935
  try {
@@ -14,7 +14,7 @@ import type { PluginLogger } from "./logger";
14
14
  */
15
15
  import type { TierConfig } from "./config";
16
16
  import { EFFORT_LEVELS } from "./config";
17
- import { isClaudeModel } from "./protocol";
17
+ import { isAdaptiveOnlyClaudeModel, isClaudeModel } from "./protocol";
18
18
 
19
19
  // ---------------------------------------------------------------------------
20
20
  // Warn-once
@@ -61,7 +61,13 @@ function isOpenAIModel(model: string): boolean {
61
61
  * Precedence, highest first: explicit `thinking` with a truthy `budgetTokens`
62
62
  * (Anthropic) or explicit `reasoning.effort` (OpenAI), then the
63
63
  * provider-agnostic `effort`. A `budgetTokens` of 0 asks for nothing and so
64
- * loses to `effort`, with a one-time notice per tier. A key is
64
+ * loses to `effort`, with a one-time notice per tier.
65
+ *
66
+ * Explicit fields are gated by model: a Claude model never receives
67
+ * `reasoning_effort` / `reasoning_summary`, and an adaptive-only Claude model
68
+ * (`isAdaptiveOnlyClaudeModel`) never receives `budget_tokens` — the budget is
69
+ * then ignored as if unset, so `effort` still applies. Each drop warns once
70
+ * per tier. A key is
65
71
  * only ever present when something asked for it — an unset `effort` leaves no
66
72
  * trace in the returned object.
67
73
  */
@@ -76,8 +82,19 @@ export function buildAgentOptions(
76
82
  // all, so it is neither emitted nor treated as an explicit thinking config
77
83
  // below — `hasThinkingBudget` is the single notion of "thinking was asked
78
84
  // for", shared by the emission and the effort precedence check.
79
- const hasThinkingBudget = Boolean(tier.thinking?.budgetTokens);
80
- if (hasThinkingBudget) {
85
+ // An adaptive-only Claude model rejects a manual budget outright, so the
86
+ // budget is dropped and — for the effort precedence below — treated as never
87
+ // having been set, which lets a sibling `effort` through.
88
+ const isClaude = isClaudeModel(tier.model);
89
+ let hasThinkingBudget = Boolean(tier.thinking?.budgetTokens);
90
+ if (hasThinkingBudget && isAdaptiveOnlyClaudeModel(tier.model)) {
91
+ hasThinkingBudget = false;
92
+ warnAgentOptionsEffortOnce(
93
+ `thinking-adaptive-only:${tierName}`,
94
+ `tier ${tierName}: model '${tier.model}' only accepts adaptive thinking and rejects a manual budget, so thinking.budgetTokens is ignored; use effort instead`,
95
+ logger,
96
+ );
97
+ } else if (hasThinkingBudget) {
81
98
  opts.budget_tokens = tier.thinking?.budgetTokens;
82
99
  } else if (tier.thinking?.budgetTokens === 0) {
83
100
  warnAgentOptionsEffortOnce(
@@ -87,8 +104,17 @@ export function buildAgentOptions(
87
104
  );
88
105
  }
89
106
 
90
- // OpenAI reasoning config
91
- if (tier.reasoning) {
107
+ // OpenAI reasoning config. Claude models have no such parameters, so they
108
+ // are dropped there rather than sent to a provider that cannot read them.
109
+ if (tier.reasoning && isClaude) {
110
+ if (tier.reasoning.effort || tier.reasoning.summary) {
111
+ warnAgentOptionsEffortOnce(
112
+ `reasoning-claude:${tierName}`,
113
+ `tier ${tierName}: reasoning.effort and reasoning.summary are OpenAI parameters and are ignored for Claude model '${tier.model}'; use effort instead`,
114
+ logger,
115
+ );
116
+ }
117
+ } else if (tier.reasoning) {
92
118
  if (tier.reasoning.effort) {
93
119
  opts.reasoning_effort = tier.reasoning.effort;
94
120
  }
@@ -106,8 +132,9 @@ export function buildAgentOptions(
106
132
  warnAgentOptionsEffortOnce(
107
133
  `invalid:${tierName}:${String(effort)}`,
108
134
  `tier ${tierName}: invalid effort '${String(effort)}' ignored`,
135
+ logger,
109
136
  );
110
- } else if (isClaudeModel(tier.model)) {
137
+ } else if (isClaude) {
111
138
  if (hasThinkingBudget) {
112
139
  warnAgentOptionsEffortOnce(
113
140
  `anthropic-conflict:${tierName}`,
@@ -156,6 +156,14 @@ export interface RouterConfig {
156
156
  * orchestrator remembered to write it.
157
157
  */
158
158
  dispatchHeader?: boolean;
159
+ /**
160
+ * Repair a task dispatch that arrives without a prompt: copy a non-empty
161
+ * description into the prompt, or refuse the call with a readable
162
+ * explanation when neither carries any work. Defaults to true. Set false to
163
+ * restore the pre-feature behaviour where the harness rejected such a call
164
+ * with a bare schema error.
165
+ */
166
+ taskPromptRepair?: boolean;
159
167
  /**
160
168
  * DELEGATE sessions only, never the orchestrator. `strip-global` (default)
161
169
  * removes instruction files outside the project, where orchestrator personas
@@ -512,6 +520,12 @@ function validateDispatchHeader(obj: Record<string, unknown>): void {
512
520
  }
513
521
  }
514
522
 
523
+ function validateTaskPromptRepair(obj: Record<string, unknown>): void {
524
+ if (obj.taskPromptRepair !== undefined && typeof obj.taskPromptRepair !== "boolean") {
525
+ throw new Error("tiers.json: 'taskPromptRepair' must be a boolean");
526
+ }
527
+ }
528
+
515
529
  function validateFalseRefusalDetection(obj: Record<string, unknown>): void {
516
530
  if (obj.falseRefusalDetection !== undefined && typeof obj.falseRefusalDetection !== "boolean") {
517
531
  throw new Error("tiers.json: 'falseRefusalDetection' must be a boolean");
@@ -923,6 +937,7 @@ export function validateConfig(raw: unknown): RouterConfig {
923
937
  validateEnforcement(obj);
924
938
  validateDelegateInstructions(obj);
925
939
  validateDispatchHeader(obj);
940
+ validateTaskPromptRepair(obj);
926
941
  validateFalseRefusalDetection(obj);
927
942
 
928
943
  return raw as RouterConfig;
@@ -113,7 +113,7 @@ export function buildDelegationProtocol(cfg: RouterConfig): string {
113
113
  return [
114
114
  `## Model Delegation Protocol (MANDATORY)`,
115
115
  ``,
116
- `You are the orchestrator: route each task to the right tier and delegate it with \`Task(subagent_type="fast"|"medium"|"heavy", prompt="...")\`. Information-gathering (grep, read, glob, ls) is execution, so dispatch it to @fast rather than running it yourself; cap yourself at about 2 direct read-only calls per turn and dispatch @fast on the 3rd. Synthesize the subagents' results and answer the user yourself.`,
116
+ `You are the orchestrator: route each task to the right tier and delegate it with \`Task(subagent_type="fast"|"medium"|"heavy", prompt="...")\`. Information-gathering (grep, read, glob, ls) is execution and goes to @fast by default; your one exception is an allowance of about 2 direct read-only calls per turn for lookups that settle a question outright, so dispatch @fast once you would exceed it. Synthesize the subagents' results and answer the user yourself.`,
117
117
  ``,
118
118
  `Preset: ${cfg.activePreset}. Tiers: ${tierLine}.${modeSuffix}`,
119
119
  ``,
@@ -153,6 +153,33 @@ export function isClaudeModel(modelID: string | undefined): boolean {
153
153
  return /\/claude-/.test(s) || /(^|[\/\-])claude-/.test(s);
154
154
  }
155
155
 
156
+ /**
157
+ * Claude models that only accept adaptive thinking: a manually supplied
158
+ * thinking budget (and `{"type": "disabled"}`) is rejected. The list mirrors
159
+ * the catalogue entries carrying `rejects_disabled_thinking` in
160
+ * claude-code-wire-compat's 2.1.280 profile. Neighbours are deliberately not
161
+ * covered: `claude-opus-5` and `claude-mythos-5` still accept a budget.
162
+ */
163
+ const ADAPTIVE_ONLY_CLAUDE_MODELS = [
164
+ "claude-opus-5-5",
165
+ "claude-fable-5",
166
+ "claude-fable-5-1",
167
+ "claude-mythos-5-1",
168
+ ];
169
+
170
+ export function isAdaptiveOnlyClaudeModel(modelID: string | undefined): boolean {
171
+ if (!modelID || !isClaudeModel(modelID)) return false;
172
+ // Same family matching as isClaudeModel, plus dots folded to dashes so a
173
+ // provider re-spelling (`claude-fable-5.1`) lands on the catalogue id. The
174
+ // id must end at the model name, optionally followed by a date stamp
175
+ // (`-YYYYMMDD`, or the Vertex `@YYYYMMDD` form) and a bracketed tag (`[1m]`),
176
+ // so `claude-opus-5` never matches `claude-opus-5-5` and vice versa.
177
+ const s = modelID.toLowerCase().replace(/\./g, "-");
178
+ return ADAPTIVE_ONLY_CLAUDE_MODELS.some((id) =>
179
+ new RegExp(`(^|[\\/\\-])${id}([-@]\\d{8})?(\\[[^\\]]*\\])?$`).test(s),
180
+ );
181
+ }
182
+
156
183
  /** Per-tier adversarial openers. @fast/@medium use Tom 2 (scoping); @heavy uses Tom 1 (override). */
157
184
  export const CLAUDE_TIER_PREFIX: Record<string, string> = {
158
185
  fast: [
package/tiers.json CHANGED
@@ -375,11 +375,11 @@
375
375
  "default→@fast unless edits/complex-reasoning needed",
376
376
  "@medium ONLY: multi-file-edit/refactor/test-suite/build-fix",
377
377
  "@heavy ONLY: user-requested OR ≥2 @medium failures",
378
- "trivial(grep/read/glob)→direct,no-delegate",
378
+ "trivial(grep/read/glob)→direct,spends orchestrator read-only allowance",
379
379
  "batch related searches→single @fast",
380
380
  "uncertain @fast vs @medium→@fast,escalate on fail",
381
381
  "dispatch caps (tighter): always include CAP:5 when dispatching @fast, CAP:2 for @medium, CAP:2 for @heavy",
382
- "orchestrator self-cap: ≤1 direct read-only call per turn; 2nd need → dispatch @fast"
382
+ "orchestrator read-only allowance: dispatch is default; ≤1 direct read-only call per turn; 2nd need → dispatch @fast"
383
383
  ]
384
384
  },
385
385
  "quality": {
@@ -401,7 +401,7 @@
401
401
  "default→@medium for implementation and multi-file changes",
402
402
  "@heavy for architecture/debug/security/tradeoff-analysis by default",
403
403
  "allow long heavy runs before fallback; avoid premature downshift",
404
- "trivial(grep/read/glob)→direct,no-delegate",
404
+ "trivial one-off lookup(grep/read/glob) that settles the question→direct; further reads→@fast",
405
405
  "if task is composite: explore@fast then execute@heavy",
406
406
  "dispatch caps: CAP:none (with a `reason:` line) for @heavy only; @fast=CAP:8 and @medium=CAP:5 baselines apply",
407
407
  "subagents still run redundancy check; CAP:none only lifts the numeric cap"
@@ -442,8 +442,8 @@
442
442
  "plan:fast/cheap→@fast | plan:medium→@medium | plan:heavy→@heavy",
443
443
  "default preference: read-only work → @fast; implementation → @medium",
444
444
  "orchestrate=self, execute=subagent (info-gathering IS execution, not orchestration)",
445
- "trivial (≤1 tool call, no expected follow-up) → direct, skip-delegate",
446
- "orchestrator self-cap (TARGET): ≤2 direct read-only calls per turn; 3rd need → dispatch @fast (exceed only with 1-line reason)",
445
+ "trivial (≤1 tool call, no expected follow-up) → direct, spent from the orchestrator read-only allowance",
446
+ "orchestrator read-only allowance (TARGET): dispatch is default; ≤2 direct read-only calls per turn; 3rd need → dispatch @fast (exceed only with 1-line reason)",
447
447
  "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)",
448
448
  "before dispatching @heavy: gather context first (usually via @fast); if context is already sufficient, dispatch directly",
449
449
  "if self is opus: skip-@heavy (do locally); still prefer routing broader read-only exploration to @fast",