opencode-model-router 1.12.1 → 1.14.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,113 @@ 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.14.0] - 2026-09-26
9
+
10
+ Test baselines could saturate every core on a machine running several delegations: a
11
+ full test suite was started on every dispatch, and on Windows a timed-out suite kept
12
+ running as orphaned workers after the router had given up on it.
13
+
14
+ ### Changed
15
+
16
+ - **The bundled `anthropic` preset moves heavy to Opus 5.5 and lowers medium's
17
+ effort.** `heavy` is now `anthropic/claude-opus-5-5` at `xhigh` effort (was
18
+ `anthropic/claude-fable-5-1` at `max`), and `medium` stays on Opus 5.5 with
19
+ `effort`/`variant` `low` (was `high`). Tier descriptions state the new settings.
20
+ Presets overridden in `opencode-model-router.overrides.jsonc` are unaffected.
21
+
22
+ ### Fixed
23
+
24
+ - **A timed-out or aborted test baseline no longer leaves the suite running.**
25
+ Verification commands ran through `child_process.exec`, whose `timeout` and
26
+ `signal` only kill the shell it spawned. A test command is a process tree
27
+ (`cmd /c npm test` → npm → vitest → one worker per core), so on Windows the
28
+ 60-second baseline budget expired, the shell died, and every worker kept running
29
+ until the suite finished on its own. Commands now run through a helper that kills
30
+ the whole tree on timeout or abort: `taskkill /T /F` on Windows, the process group
31
+ on POSIX. This also covers `testsPass`, `buildPasses`, `lintClean` and `run`
32
+ checks.
33
+
34
+ - **Read-only dispatches no longer run the test suite.** Every `task` or `delegate`
35
+ dispatch started a baseline capture of the default test command to warm the cache,
36
+ including exploration fan-outs that are never judged by `testsPass`. Those captures
37
+ were almost always discarded, because any shell or edit tool in the directory
38
+ contaminates them, so each dispatch paid for a full suite and gained nothing. A
39
+ baseline is now captured only when the dispatch's DoD carries a `testsPass` check.
40
+
41
+ - **At most one baseline capture runs per directory and command.** Captures are
42
+ cached by tree fingerprint, which changes with every edit, so dispatches landing
43
+ while a suite was already running each started another. A dispatch that finds a
44
+ capture in flight for the same directory and command now gets no baseline — the
45
+ same `unverifiable` outcome as a contaminated capture — instead of a second suite.
46
+
47
+ ## [1.13.0] - 2026-09-24
48
+
49
+ A forced delegation of a request that carries no task produced a `task` call with no
50
+ prompt, which the harness rejected with a terse schema error. The router now repairs
51
+ such calls or refuses them readably. This release also gives the orchestrator's
52
+ read-only allowance a single consistent statement, and stops explicit thinking and
53
+ reasoning fields from reaching Claude models that cannot use them.
54
+
55
+ ### Added
56
+
57
+ - **`taskPromptRepair` fills in or refuses prompt-less `task` calls.** A forced
58
+ delegation of a request that carries no task — a bare greeting sent through an
59
+ explicit tier mention, say — made the model emit a `task` call with a description
60
+ and a tier but no prompt, and the harness rejected it with a bare schema error
61
+ naming the missing key. The `task` before-hook now repairs the call ahead of the
62
+ dispatch header: when `prompt` is absent, `null` or blank and `description` is a
63
+ non-empty string, the trimmed description becomes the prompt and the call proceeds
64
+ with the dispatch header applied normally. When there is no usable description the
65
+ call is refused with a `[router]` error saying that `task` needs a non-empty
66
+ `prompt`, and that a request carrying no task (a greeting, an acknowledgement)
67
+ should be answered directly rather than delegated. A prompt of a non-string type
68
+ is left for the harness, and frozen args that cannot be repaired are left alone.
69
+ The flag defaults to `true`; set `taskPromptRepair: false` to restore the previous
70
+ behaviour. Non-boolean values are rejected by `validateConfig`. See
71
+ `docs/CONFIG_REFERENCE.md`.
72
+
73
+ ### Changed
74
+
75
+ - **The orchestrator's read-only allowance is stated as one mechanism.** The injected
76
+ protocol gave the same rule three incompatible readings: the orchestrator line said
77
+ information-gathering should be dispatched to @fast rather than run directly, then
78
+ capped direct read-only calls at about two per turn, and the rules array added a
79
+ separate licence for trivial single-call work that acknowledged neither. Dispatch
80
+ is now the stated default, and direct calls are a named allowance for lookups that
81
+ settle a question outright; the trivial-work rules in the shipped `tiers.json` now
82
+ spend that allowance instead of competing with it, and the per-mode overrides are
83
+ reconciled the same way. No cap number moved: the base allowance is still two,
84
+ budget mode is still one, and the dispatch baselines are unchanged. Only the
85
+ protocol prose changed, so the injected prompt and the README's measured
86
+ prompt-size figures move by the length of the new wording. The README's sample
87
+ rules line is regenerated from the shipped configuration; it had shown eight rules
88
+ where the shipped array has ten.
89
+
90
+ ### Fixed
91
+
92
+ - **The invalid-effort warning goes through the plugin logger.** Every other
93
+ `buildAgentOptions` warning passed the plugin logger, but an unrecognised `effort`
94
+ value always went to `console.warn`, even when a logger was supplied. It now uses
95
+ the logger like its siblings; without one the behaviour is unchanged.
96
+
97
+ - **Explicit `thinking` and `reasoning` fields are gated for Claude models.**
98
+ `buildAgentOptions` emitted `budget_tokens` and `reasoning_effort` /
99
+ `reasoning_summary` without consulting the model, so a tier on an adaptive-only
100
+ model — the bundled `anthropic` preset's `@medium` is `anthropic/claude-opus-5-5` —
101
+ that also set `thinking.budgetTokens` registered a manual thinking budget on a model
102
+ that only accepts adaptive thinking (the HTTP 400 this is said to cause is reported,
103
+ not reproduced here; see the provider gate in `docs/CONFIG_REFERENCE.md`), and the
104
+ budget outranked the `effort` that would have applied. A Claude tier now never
105
+ registers `reasoning_*` (OpenAI parameters), and a tier on a model whose wire-compat
106
+ catalogue entry carries `rejects_disabled_thinking` (`claude-opus-5-5`,
107
+ `claude-fable-5`, `claude-fable-5-1`, `claude-mythos-5-1`, matched by the new
108
+ `isAdaptiveOnlyClaudeModel`) never registers `budget_tokens`; the budget is then
109
+ treated as unset, so `effort` still applies. Each drop warns once per tier.
110
+ Non-Claude tiers are unchanged. Ids of the form
111
+ `<provider>/<namespace>.claude-…`, such as `bedrock/us.anthropic.claude-…`, are not
112
+ recognised as Claude, so they get no Claude prompt prefix, no Anthropic effort
113
+ routing and no gate; the README had claimed they were detected and now says so.
114
+
8
115
  ## [1.12.1] - 2026-09-23
9
116
 
10
117
  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.14.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: [
@@ -83,7 +83,7 @@ export function createChangedFileStore(options: ChangedFileStoreOptions = {}) {
83
83
  baselines: Map<string, Promise<TestBaseline | undefined>>;
84
84
  }>();
85
85
  const cache = new Map<string, {
86
- cwd: string; pending: boolean; contaminated: boolean; stamp: number;
86
+ cwd: string; command: string; pending: boolean; contaminated: boolean; stamp: number;
87
87
  controller: AbortController; result: Promise<TestBaseline | undefined>;
88
88
  }>();
89
89
 
@@ -124,9 +124,13 @@ export function createChangedFileStore(options: ChangedFileStoreOptions = {}) {
124
124
  for (const command of new Set(commands)) {
125
125
  const key = JSON.stringify([pathKey(snapshot.cwd), snapshot.head, snapshot.fingerprint, command]);
126
126
  let entry = cache.get(key);
127
+ // A suite already running in this directory is not started again under a new
128
+ // fingerprint: concurrent full suites saturate every core, and the dispatch
129
+ // falls back to the same "no baseline" path as a contaminated capture.
130
+ if (!entry && [...cache.values()].some(c => c.pending && c.command === command && pathKey(c.cwd) === pathKey(cwd))) continue;
127
131
  if (!entry) {
128
132
  const capture = {
129
- cwd, pending: true, contaminated: false, stamp: now(),
133
+ cwd, command, pending: true, contaminated: false, stamp: now(),
130
134
  controller: new AbortController(), result: Promise.resolve<TestBaseline | undefined>(undefined),
131
135
  };
132
136
  cache.set(key, capture);
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Run a shell command with a deadline that actually ends the work.
3
+ *
4
+ * `child_process.exec` with `timeout` (or `signal`) only signals the shell it
5
+ * spawned. Test commands are process trees — `cmd /c npm test` -> npm -> vitest
6
+ * -> one worker per core — so killing the shell orphans everything below it,
7
+ * and the "aborted" baseline keeps every core busy until the suite finishes on
8
+ * its own. On a timeout or abort this kills the whole tree instead: `taskkill
9
+ * /T` on Windows, the process group on POSIX.
10
+ */
11
+ import { execFile, spawn, type ChildProcess } from "node:child_process";
12
+
13
+ export interface ShellResult {
14
+ code: number;
15
+ stdout: string;
16
+ stderr: string;
17
+ /** True when the deadline or the abort signal ended the command. */
18
+ timedOut: boolean;
19
+ }
20
+
21
+ export function runShell(
22
+ command: string,
23
+ opts: { cwd: string; timeoutMs: number; signal?: AbortSignal; maxBuffer?: number },
24
+ ): Promise<ShellResult> {
25
+ if (opts.signal?.aborted) return Promise.resolve({ code: 1, stdout: "", stderr: "", timedOut: true });
26
+ return new Promise((resolve) => {
27
+ const limit = opts.maxBuffer ?? 10 * 1024 * 1024;
28
+ let stdout = "";
29
+ let stderr = "";
30
+ let killed = false;
31
+ let settled = false;
32
+ let child: ChildProcess;
33
+ try {
34
+ child = spawn(command, {
35
+ cwd: opts.cwd,
36
+ shell: true,
37
+ windowsHide: true,
38
+ // Its own process group on POSIX, so the whole tree can be signalled at once.
39
+ detached: process.platform !== "win32",
40
+ stdio: ["ignore", "pipe", "pipe"],
41
+ });
42
+ } catch (err) {
43
+ resolve({ code: 1, stdout: "", stderr: `exec failed: ${String(err)}`, timedOut: false });
44
+ return;
45
+ }
46
+ // Output past the cap is dropped rather than failing the run; the verdict
47
+ // is parsed from the summary lines, which runners print last only when the
48
+ // run completes, so truncation degrades to "unknown output", never a pass.
49
+ child.stdout?.on("data", (chunk) => { if (stdout.length < limit) stdout += String(chunk); });
50
+ child.stderr?.on("data", (chunk) => { if (stderr.length < limit) stderr += String(chunk); });
51
+
52
+ const kill = () => {
53
+ if (killed || settled) return;
54
+ killed = true;
55
+ killTree(child);
56
+ };
57
+ const timer = setTimeout(kill, opts.timeoutMs);
58
+ opts.signal?.addEventListener("abort", kill, { once: true });
59
+
60
+ const finish = (code: number | null, error?: unknown) => {
61
+ if (settled) return;
62
+ settled = true;
63
+ clearTimeout(timer);
64
+ opts.signal?.removeEventListener("abort", kill);
65
+ if (error) stderr += String(error);
66
+ resolve({ code: killed ? code || 1 : code ?? 1, stdout, stderr, timedOut: killed });
67
+ };
68
+ child.on("error", (err) => finish(1, err));
69
+ child.on("close", (code) => finish(code));
70
+ });
71
+ }
72
+
73
+ function killTree(child: ChildProcess): void {
74
+ const pid = child.pid;
75
+ if (!pid) {
76
+ child.kill("SIGKILL");
77
+ return;
78
+ }
79
+ if (process.platform === "win32") {
80
+ execFile("taskkill", ["/pid", String(pid), "/T", "/F"], { windowsHide: true }, (err) => {
81
+ // taskkill fails when the tree already exited; the direct kill is then a no-op.
82
+ if (err) child.kill();
83
+ });
84
+ return;
85
+ }
86
+ try {
87
+ process.kill(-pid, "SIGKILL");
88
+ } catch {
89
+ // No group (already reaped or never detached): fall back to the direct child.
90
+ child.kill("SIGKILL");
91
+ }
92
+ }
@@ -13,11 +13,11 @@
13
13
  * settings that were active when the plugin loaded, and `/preset` would
14
14
  * silently stop applying to graded work.
15
15
  */
16
- import { exec as nodeExec } from "node:child_process";
17
16
  import { access, readFile as fsReadFile } from "node:fs/promises";
18
17
  import { isAbsolute, join, resolve } from "node:path";
19
18
  import { createMutexRegistry, DEFAULT_ALLOWLIST, isCommandAllowed, resolveRepoCommand } from "./deterministic";
20
19
  import { tierModel, type createChangedFileStore } from "./dispatch";
20
+ import { runShell } from "./exec";
21
21
  import { snapshotTree } from "./tree";
22
22
  import type { DoD } from "./dod";
23
23
  import type { DeterministicDeps } from "./types";
@@ -107,32 +107,10 @@ export function createVerificationWiring(deps: {
107
107
  command: string,
108
108
  opts?: { cwd?: string; timeoutMs?: number; signal?: AbortSignal },
109
109
  ): Promise<ExecResult> =>
110
- new Promise((resolve) => {
111
- try {
112
- nodeExec(
113
- command,
114
- {
115
- cwd: opts?.cwd ?? directory,
116
- timeout: opts?.timeoutMs ?? 120000,
117
- maxBuffer: 10 * 1024 * 1024,
118
- windowsHide: true,
119
- signal: opts?.signal,
120
- },
121
- (err: any, stdout: any, stderr: any) => {
122
- const timedOut = !!(err && err.killed && err.signal === "SIGTERM");
123
- const code =
124
- err && typeof err.code === "number" ? err.code : err ? 1 : 0;
125
- resolve({
126
- code,
127
- stdout: String(stdout ?? ""),
128
- stderr: String(stderr ?? ""),
129
- timedOut,
130
- });
131
- },
132
- );
133
- } catch {
134
- resolve({ code: 1, stdout: "", stderr: "exec failed", timedOut: false });
135
- }
110
+ runShell(command, {
111
+ cwd: opts?.cwd ?? directory,
112
+ timeoutMs: opts?.timeoutMs ?? 120000,
113
+ signal: opts?.signal,
136
114
  });
137
115
 
138
116
  const fsSeam = {
@@ -268,9 +246,12 @@ export function createVerificationWiring(deps: {
268
246
  beginVerification(store, id, cwd, dod) {
269
247
  const verify = getConfig().enforcement?.verify;
270
248
  const base = resolve(directory, cwd || ".");
271
- const checks = dod.checks.filter(c => c.kind === "testsPass");
272
- // Read-only dispatches warm the default-command cache for later producers.
273
- const commands = (checks.length ? checks : [{ kind: "testsPass" as const }])
249
+ // Only a dispatch that will be judged by testsPass captures a baseline. Warming
250
+ // the cache from read-only dispatches ran the full suite on every exploration
251
+ // fan-out, and the capture was almost always discarded anyway: any shell or
252
+ // edit tool in the directory contaminates it.
253
+ const commands = dod.checks
254
+ .filter(c => c.kind === "testsPass")
274
255
  .map(c => resolveRepoCommand(c, "testsPass", undefined))
275
256
  .filter(c => isCommandAllowed(c, DEFAULT_ALLOWLIST));
276
257
  const budget = verify?.baselineTimeoutMs ?? 60000;
package/tiers.json CHANGED
@@ -59,10 +59,10 @@
59
59
  },
60
60
  "medium": {
61
61
  "model": "anthropic/claude-opus-5-5",
62
- "variant": "high",
63
- "effort": "high",
62
+ "variant": "low",
63
+ "effort": "low",
64
64
  "costRatio": 5,
65
- "description": "Opus 5.5 high for implementation, refactoring, and tests",
65
+ "description": "Opus 5.5 low for implementation, refactoring, and tests",
66
66
  "steps": 50,
67
67
  "whenToUse": [
68
68
  "Feature implementation",
@@ -73,10 +73,11 @@
73
73
  ]
74
74
  },
75
75
  "heavy": {
76
- "model": "anthropic/claude-fable-5-1",
77
- "variant": "max",
76
+ "model": "anthropic/claude-opus-5-5",
77
+ "variant": "xhigh",
78
+ "effort": "xhigh",
78
79
  "costRatio": 20,
79
- "description": "Fable 5.1 max for architecture, complex debugging, and security",
80
+ "description": "Opus 5.5 xhigh for architecture, complex debugging, and security",
80
81
  "steps": 120,
81
82
  "whenToUse": [
82
83
  "Architecture decisions",
@@ -375,11 +376,11 @@
375
376
  "default→@fast unless edits/complex-reasoning needed",
376
377
  "@medium ONLY: multi-file-edit/refactor/test-suite/build-fix",
377
378
  "@heavy ONLY: user-requested OR ≥2 @medium failures",
378
- "trivial(grep/read/glob)→direct,no-delegate",
379
+ "trivial(grep/read/glob)→direct,spends orchestrator read-only allowance",
379
380
  "batch related searches→single @fast",
380
381
  "uncertain @fast vs @medium→@fast,escalate on fail",
381
382
  "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"
383
+ "orchestrator read-only allowance: dispatch is default; ≤1 direct read-only call per turn; 2nd need → dispatch @fast"
383
384
  ]
384
385
  },
385
386
  "quality": {
@@ -401,7 +402,7 @@
401
402
  "default→@medium for implementation and multi-file changes",
402
403
  "@heavy for architecture/debug/security/tradeoff-analysis by default",
403
404
  "allow long heavy runs before fallback; avoid premature downshift",
404
- "trivial(grep/read/glob)→direct,no-delegate",
405
+ "trivial one-off lookup(grep/read/glob) that settles the question→direct; further reads→@fast",
405
406
  "if task is composite: explore@fast then execute@heavy",
406
407
  "dispatch caps: CAP:none (with a `reason:` line) for @heavy only; @fast=CAP:8 and @medium=CAP:5 baselines apply",
407
408
  "subagents still run redundancy check; CAP:none only lifts the numeric cap"
@@ -442,8 +443,8 @@
442
443
  "plan:fast/cheap→@fast | plan:medium→@medium | plan:heavy→@heavy",
443
444
  "default preference: read-only work → @fast; implementation → @medium",
444
445
  "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)",
446
+ "trivial (≤1 tool call, no expected follow-up) → direct, spent from the orchestrator read-only allowance",
447
+ "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
448
  "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
449
  "before dispatching @heavy: gather context first (usually via @fast); if context is already sufficient, dispatch directly",
449
450
  "if self is opus: skip-@heavy (do locally); still prefer routing broader read-only exploration to @fast",