dsh-model-router 0.2.0 → 0.3.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/README.md CHANGED
@@ -62,7 +62,10 @@ All configuration lives on the plugin row. Patch it in the profile's `cordis.pat
62
62
  executor: # subagent route
63
63
  provider: deepseek-official
64
64
  model: deepseek-v4-flash
65
- reasoningEffort: low
65
+ reasoningEffort: high
66
+ escalateOnError: true # after a failed step…
67
+ escalateTo: max # …bump effort for the next request
68
+ recoverySteps: 2 # …wearing off after N clean steps
66
69
  mode: strict # strict | plan (see below)
67
70
  promptSection: true # register the always-on routing section
68
71
  skill: true # register the pro-flash-routing skill
@@ -70,6 +73,8 @@ All configuration lives on the plugin row. Patch it in the profile's `cordis.pat
70
73
 
71
74
  `mode` controls how the root agent is treated: `strict` keeps it on the planner route always; `plan` sends the root to the executor route unless plan mode is active, reserving pro for real planning.
72
75
 
76
+ **Error-driven escalation** (`escalateOnError`): when a route's agent hits a failed tool step, the *next* request bumps to `escalateTo` and wears off after `recoverySteps` clean steps. It's deterministic and stateless — the router folds the session log per request, so only prior steps are considered (a failure can't escalate the very request that caused it). It's a per-route knob: enable it on the executor to make flash think harder after a flubbed execution step, without touching the baseline.
77
+
73
78
  The defaults are exactly the table at the top of this page. To switch the router off for a session, disable the row (`disabled: true`) or remove the plugin — `dsh plugin --profile web remove dsh-model-router`.
74
79
 
75
80
  ## Reduce pro token usage
package/cordis.patch.yml CHANGED
@@ -19,8 +19,11 @@
19
19
  executor:
20
20
  provider: deepseek-official
21
21
  model: deepseek-v4-flash
22
- # reasoningEffort: low
22
+ # reasoningEffort: high
23
23
  # maxTokens: 16384
24
+ # escalateOnError: true # v1: after a failed step, escalate effort
25
+ # escalateTo: max # to this level for the next request…
26
+ # recoverySteps: 2 # …wearing off after N clean steps
24
27
  # strict: root is always the planner (pro).
25
28
  # plan: root is pro only while plan mode is active; otherwise it
26
29
  # falls back to the executor route to reserve pro for planning.
package/lib/index.d.ts CHANGED
@@ -26,6 +26,17 @@ interface ModelRoute {
26
26
  reasoningEffort?: ReasoningEffort;
27
27
  /** Optional output-token cap for the role; omitted means inherit. */
28
28
  maxTokens?: number;
29
+ /**
30
+ * Error-driven escalation (v1): when true, a failed execution step bumps the
31
+ * next request's effort to `escalateTo`, wearing off after `recoverySteps`
32
+ * clean steps. Deterministic, stateless — the session log is folded per
33
+ * request, so only *prior* steps are ever considered.
34
+ */
35
+ escalateOnError?: boolean;
36
+ /** Effort used for the request after a failed step. */
37
+ escalateTo?: ReasoningEffort;
38
+ /** Clean steps before escalation wears off. Defaults to 2. */
39
+ recoverySteps?: number;
29
40
  }
30
41
  /** The two roles the router distinguishes. */
31
42
  type AgentRole = "planner" | "executor";
@@ -58,6 +69,33 @@ declare function roleFor(agent: unknown): AgentRole;
58
69
  * @returns the model route to stamp, or `undefined` to leave the request alone.
59
70
  */
60
71
  declare function routeFor(agent: unknown, config: RouterConfig, planModeActive?: boolean): ModelRoute | undefined;
72
+ /**
73
+ * Whether any of the last `recoverySteps` completed steps carried a failed
74
+ * tool result. A failure is a `tool/result` event whose data carries an
75
+ * `error` field (the harness records tool failures there).
76
+ *
77
+ * Steps are deduplicated by `turn:step`, and only *completed* steps count —
78
+ * events are scanned from the tail, so the current in-flight request is never
79
+ * considered.
80
+ *
81
+ * @param events - the agent's session event log (or `undefined`).
82
+ * @param recoverySteps - how many completed steps back to scan.
83
+ * @returns true when a failed step is within the window.
84
+ */
85
+ declare function recentStepsHadError(events: readonly unknown[] | undefined, recoverySteps?: number): boolean;
86
+ /**
87
+ * Resolve the reasoning effort to stamp for one request.
88
+ *
89
+ * Baseline is the route's `reasoningEffort`; when `escalateOnError` is enabled
90
+ * and a recent step failed, the effort bumps to `escalateTo` (falling back to
91
+ * the baseline when `escalateTo` is unset). Returns `undefined` to leave the
92
+ * request's effort alone (inherit the session selection).
93
+ *
94
+ * @param route - the resolved route for the agent.
95
+ * @param events - the agent's session event log.
96
+ * @returns the effort to stamp, or `undefined` to inherit.
97
+ */
98
+ declare function effortFor(route: ModelRoute, events: readonly unknown[] | undefined): ReasoningEffort | undefined;
61
99
 
62
100
  /**
63
101
  * dsh-model-router: role-based model routing for the DeepSeek Harness.
@@ -89,22 +127,34 @@ declare const Config: z<Schemastery.ObjectS<{
89
127
  model: z<string, string>;
90
128
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
91
129
  maxTokens: z<number, number>;
130
+ escalateOnError: z<boolean, boolean>;
131
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
132
+ recoverySteps: z<number, number>;
92
133
  }>, Schemastery.ObjectT<{
93
134
  provider: z<string, string>;
94
135
  model: z<string, string>;
95
136
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
96
137
  maxTokens: z<number, number>;
138
+ escalateOnError: z<boolean, boolean>;
139
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
140
+ recoverySteps: z<number, number>;
97
141
  }>>;
98
142
  executor: z<Schemastery.ObjectS<{
99
143
  provider: z<string, string>;
100
144
  model: z<string, string>;
101
145
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
102
146
  maxTokens: z<number, number>;
147
+ escalateOnError: z<boolean, boolean>;
148
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
149
+ recoverySteps: z<number, number>;
103
150
  }>, Schemastery.ObjectT<{
104
151
  provider: z<string, string>;
105
152
  model: z<string, string>;
106
153
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
107
154
  maxTokens: z<number, number>;
155
+ escalateOnError: z<boolean, boolean>;
156
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
157
+ recoverySteps: z<number, number>;
108
158
  }>>;
109
159
  mode: z<"strict" | "plan", "strict" | "plan">;
110
160
  promptSection: z<boolean, boolean>;
@@ -115,22 +165,34 @@ declare const Config: z<Schemastery.ObjectS<{
115
165
  model: z<string, string>;
116
166
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
117
167
  maxTokens: z<number, number>;
168
+ escalateOnError: z<boolean, boolean>;
169
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
170
+ recoverySteps: z<number, number>;
118
171
  }>, Schemastery.ObjectT<{
119
172
  provider: z<string, string>;
120
173
  model: z<string, string>;
121
174
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
122
175
  maxTokens: z<number, number>;
176
+ escalateOnError: z<boolean, boolean>;
177
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
178
+ recoverySteps: z<number, number>;
123
179
  }>>;
124
180
  executor: z<Schemastery.ObjectS<{
125
181
  provider: z<string, string>;
126
182
  model: z<string, string>;
127
183
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
128
184
  maxTokens: z<number, number>;
185
+ escalateOnError: z<boolean, boolean>;
186
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
187
+ recoverySteps: z<number, number>;
129
188
  }>, Schemastery.ObjectT<{
130
189
  provider: z<string, string>;
131
190
  model: z<string, string>;
132
191
  reasoningEffort: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
133
192
  maxTokens: z<number, number>;
193
+ escalateOnError: z<boolean, boolean>;
194
+ escalateTo: z<"off" | "low" | "high" | "max", "off" | "low" | "high" | "max">;
195
+ recoverySteps: z<number, number>;
134
196
  }>>;
135
197
  mode: z<"strict" | "plan", "strict" | "plan">;
136
198
  promptSection: z<boolean, boolean>;
@@ -151,4 +213,4 @@ declare class ModelRouter extends Service {
151
213
  constructor(ctx: Context, rawConfig?: unknown);
152
214
  }
153
215
 
154
- export { type AgentRole, Config, type ModelRoute, ModelRouter, ROW_ID, type ReasoningEffort, type RouterConfig, type RoutingMode, SKILL_CONTENT, SKILL_DESCRIPTION, SKILL_NAME, SKILL_WHEN_TO_USE, ModelRouter as default, name, roleFor, routeFor };
216
+ export { type AgentRole, Config, type ModelRoute, ModelRouter, ROW_ID, type ReasoningEffort, type RouterConfig, type RoutingMode, SKILL_CONTENT, SKILL_DESCRIPTION, SKILL_NAME, SKILL_WHEN_TO_USE, ModelRouter as default, effortFor, name, recentStepsHadError, roleFor, routeFor };
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@ import z from "@deepseek-ai/schemastery";
4
4
  import { foldPlanMode } from "@deepseek-ai/dsh-plan-mode";
5
5
 
6
6
  // src/policy.ts
7
+ var DEFAULT_RECOVERY_STEPS = 2;
7
8
  function roleFor(agent) {
8
9
  const options = agent?.options;
9
10
  const depth = options?.subagentDepth;
@@ -19,6 +20,29 @@ function routeFor(agent, config, planModeActive = false) {
19
20
  if (config.mode === "plan" && !planModeActive) return config.executor;
20
21
  return config.planner;
21
22
  }
23
+ function recentStepsHadError(events, recoverySteps = DEFAULT_RECOVERY_STEPS) {
24
+ if (!Array.isArray(events) || recoverySteps <= 0) return false;
25
+ const seen = /* @__PURE__ */ new Set();
26
+ let steps = 0;
27
+ for (let i = events.length - 1; i >= 0; i -= 1) {
28
+ const event = events[i];
29
+ if (event?.type !== "tool/result" || event.data === void 0) continue;
30
+ const key = `${event.data.turn}:${event.data.step}`;
31
+ if (!seen.has(key)) {
32
+ if (steps >= recoverySteps) break;
33
+ seen.add(key);
34
+ steps += 1;
35
+ }
36
+ if (event.data.error !== void 0 && event.data.error !== null) return true;
37
+ }
38
+ return false;
39
+ }
40
+ function effortFor(route, events) {
41
+ if (route.escalateOnError === true && recentStepsHadError(events, route.recoverySteps)) {
42
+ return route.escalateTo ?? route.reasoningEffort;
43
+ }
44
+ return route.reasoningEffort;
45
+ }
22
46
 
23
47
  // src/index.ts
24
48
  var name = "model-router";
@@ -26,7 +50,10 @@ var ModelRouteSchema = z.object({
26
50
  provider: z.string().min(1),
27
51
  model: z.string().min(1),
28
52
  reasoningEffort: z.union(["off", "low", "high", "max"]),
29
- maxTokens: z.number().min(1)
53
+ maxTokens: z.number().min(1),
54
+ escalateOnError: z.boolean(),
55
+ escalateTo: z.union(["off", "low", "high", "max"]),
56
+ recoverySteps: z.number().min(1)
30
57
  });
31
58
  var Config = z.object({
32
59
  planner: ModelRouteSchema.default({
@@ -114,8 +141,9 @@ var ModelRouter = class extends Service {
114
141
  provider: route.provider,
115
142
  model: route.model
116
143
  };
117
- if (route.reasoningEffort !== void 0) stamped.reasoningEffort = route.reasoningEffort;
118
144
  if (route.maxTokens !== void 0) stamped.maxTokens = route.maxTokens;
145
+ const effort = effortFor(route, agent.session?.events);
146
+ if (effort !== void 0) stamped.reasoningEffort = effort;
119
147
  return stamped;
120
148
  },
121
149
  { prepend: true }
@@ -154,7 +182,9 @@ export {
154
182
  SKILL_NAME,
155
183
  SKILL_WHEN_TO_USE,
156
184
  ModelRouter as default,
185
+ effortFor,
157
186
  name,
187
+ recentStepsHadError,
158
188
  roleFor,
159
189
  routeFor
160
190
  };
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/policy.ts"],"sourcesContent":["/**\n * dsh-model-router: role-based model routing for the DeepSeek Harness.\n *\n * The planner (the session's root agent) runs on `deepseek-v4-pro`; delegated\n * executor subagents run on `deepseek-v4-flash`. Enforcement is a per-agent\n * `agent/request` rewrite registered when the agent is created, so it applies\n * in every mode (web / headless / tui) and every agent preset, including\n * subagents the delegation tools create.\n *\n * Each role route may also pin `reasoningEffort` and `maxTokens`; when set,\n * they override the session's selection for that role. A `mode` switch lets a\n * deployment reserve the planner route for actual planning.\n *\n * The plugin also publishes:\n * - a system-prompt section stating the planner/executor convention, and\n * - the `pro-flash-routing` skill teaching the agent to plan itself and\n * delegate code execution to flash subagents.\n *\n * @module dsh-model-router\n */\nimport { Context, Service } from \"@deepseek-ai/cordis\";\nimport z from \"@deepseek-ai/schemastery\";\nimport { foldPlanMode } from \"@deepseek-ai/dsh-plan-mode\";\nimport { roleFor, routeFor, type RouterConfig } from \"./policy.js\";\n\n/** Plugin row id; the bundle patch inserts it under this id. */\nconst name = \"model-router\";\n\n/** One provider/model pair, with defaults and optional effort/token caps. */\nconst ModelRouteSchema = z.object({\n provider: z.string().min(1),\n model: z.string().min(1),\n reasoningEffort: z.union([\"off\", \"low\", \"high\", \"max\"]),\n maxTokens: z.number().min(1),\n});\n\n/** The plugin's public config, validated at row load. */\nconst Config = z.object({\n planner: ModelRouteSchema.default({\n provider: \"deepseek-official\",\n model: \"deepseek-v4-pro\",\n } as never),\n executor: ModelRouteSchema.default({\n provider: \"deepseek-official\",\n model: \"deepseek-v4-flash\",\n } as never),\n mode: z.union([\"strict\", \"plan\"]).default(\"strict\"),\n promptSection: z.boolean().default(true),\n skill: z.boolean().default(true),\n});\n\n/**\n * Resolve raw row config into the internal shape, failing loud on garbage.\n * Schemastery schemas are callable: invoking validates and applies defaults.\n * @param raw - the row's config object.\n * @returns the validated RouterConfig.\n */\nfunction resolveConfig(raw: unknown): RouterConfig {\n const parsed = Config(raw ?? {});\n return {\n planner: parsed.planner,\n executor: parsed.executor,\n mode: parsed.mode,\n promptSection: parsed.promptSection,\n skill: parsed.skill,\n };\n}\n\n/**\n * Always-on guidance section. Negative order renders before the persona, so\n * the convention is established before the agent's identity line.\n */\nconst SECTION_ORDER = -50;\n\nconst SECTION_TEXT = `Model routing is role-based. Planning runs on {PLANNER_MODEL}; implementation runs on {EXECUTOR_MODEL}. You are the root agent: plan, design, review subagent output, and write the final answer here. Delegate implementation — writing code, running commands, builds, tests — to subagents with complete, self-contained prompts, preferring background delegation for independent work. Keep plans and replies concise. Do not hand-write large amounts of code or run long executions here; delegate instead.`;\n\nconst SKILL_NAME = \"pro-flash-routing\";\n\nconst SKILL_DESCRIPTION =\n \"Route planning and code execution across models: plan on the pro planner agent, delegate implementation to flash executor subagents.\";\n\nconst SKILL_WHEN_TO_USE = `Use when a task combines planning and implementation: before writing code, after a plan is approved, when delegating execution work, or when the user asks about the pro/flash routing convention.`;\n\nconst SKILL_CONTENT = `# Pro planner / Flash executor routing\n\nThis session routes models by role:\n\n- **Planner (this agent)** — \\`deepseek-v4-pro\\`. Planning, design decisions, reviewing delegated output, and user-facing synthesis happen here.\n- **Executors (every subagent)** — \\`deepseek-v4-flash\\`. Implementation work happens there: writing code, running commands, builds, and tests. The harness forces the model automatically; you do not select it.\n\n## Working rhythm\n\n1. **Plan here.** Explore, decide the approach, and (when plan mode is on) submit the plan with \\`exit_plan_mode\\`. The plan stays on this agent.\n2. **Delegate the execution.** Once a plan is approved, hand each self-contained chunk of implementation to a subagent with a complete prompt: exact files to touch, the change to make, and how to verify. Subagents are automatically routed to \\`deepseek-v4-flash\\`, so keep them execution-focused: give them the decision, not the decision to make.\n3. **Review here.** Read the subagent's result on this agent, verify it yourself (tests, diffs, logs), and iterate with follow-up messages to the same subagent when available.\n4. **Report here.** Summaries, plans, and answers to the user come from this agent.\n\n## Keep this agent's context lean\n\nInput tokens are the expensive part of the planner. Don't re-read large files or full transcripts on this agent — trust the subagent's final report. Prefer targeted reads (offset/limit) over whole files. When the context grows, compact rather than re-sending everything.\n\n## Delegation guidelines\n\n- Start independent delegations together in one assistant message and continue useful work while they run (background mode by default).\n- Prefer \\`subagent\\` for self-contained work and \\`workflow\\` when many independent pieces need fan-out; their workers run on flash as well.\n- Do not delegate design: subagents execute decisions already made.\n- If a subagent's task grows into design work, pull it back to this agent and re-delegate the narrowed execution.\n\n## Verification\n\n- Executor output was produced by \\`deepseek-v4-flash\\`; planner output by \\`deepseek-v4-pro\\`. If you need to confirm, check the session log's model metadata.\n- If routing ever looks wrong, the \\`model-router\\` plugin row in the profile composition is the single place that owns it.`;\n\n/** The plugin row id the bundle patch must insert. */\nconst ROW_ID = \"model-router\";\n\n/** Minimal structural view of the live agent object the router reads. */\ninterface AgentLike {\n ctx: AgentScopedContext;\n options?: { subagentDepth?: number };\n session?: { header?: { origin?: string }; events?: unknown[] };\n}\n\n/** The agent-scoped context's waterfall surface the router uses. */\ninterface AgentScopedContext {\n on(\n event: \"agent/request\",\n listener: (\n payload: Record<string, unknown>,\n next: () => Promise<Record<string, unknown>>,\n ) => Promise<Record<string, unknown>>,\n options?: { prepend?: boolean },\n ): () => void;\n}\n\n/** Host-plane surface the router consumes (events, prompt registry, skills). */\ninterface HarnessContext {\n on(\n event: \"agent/created\",\n listener: (payload: { agent: AgentLike }) => void,\n ): () => void;\n on(event: \"agent/disposed\", listener: (agent: unknown) => void): () => void;\n systemPrompt: {\n section(section: { name: string; order: number; text: string }): unknown;\n };\n skills: {\n register(skill: {\n name: string;\n description: string;\n whenToUse?: string;\n content: string;\n source: string;\n }): unknown;\n };\n}\n\n/** Fold plan-mode state for an agent without trusting the agent's exact shape. */\nfunction isPlanModeActive(agent: AgentLike): boolean {\n const events = agent.session?.events;\n if (!Array.isArray(events)) return false;\n try {\n return foldPlanMode(events as Parameters<typeof foldPlanMode>[0]);\n } catch {\n return false;\n }\n}\n\n/**\n * Cordis service: per-agent request routing plus the convention surface.\n */\nclass ModelRouter extends Service {\n static inject = [\"skills\", \"systemPrompt\"];\n\n config: RouterConfig;\n\n constructor(ctx: Context, rawConfig: unknown = {}) {\n super(ctx, \"modelRouter\");\n this.config = resolveConfig(rawConfig);\n const harness = ctx as unknown as HarnessContext;\n\n // Every agent that gets created — root sessions, delegation children,\n // workflow workers, ralph rounds — passes through here.\n harness.on(\"agent/created\", ({ agent }) => {\n // `prepend` puts this listener OUTERMOST in the `agent/request`\n // waterfall: the harness's model-selection listener runs inside it, so\n // this rewrite is applied LAST and wins over the session's selected\n // model (which dsh-base defaults to deepseek-v4-flash and the user\n // settings or UI can change).\n const dispose = agent.ctx.on(\n \"agent/request\",\n async (payload, next) => {\n const resolved = await next();\n const route = routeFor(agent, this.config, isPlanModeActive(agent));\n if (route === undefined) return resolved;\n const stamped: Record<string, unknown> = {\n ...resolved,\n provider: route.provider,\n model: route.model,\n };\n if (route.reasoningEffort !== undefined) stamped.reasoningEffort = route.reasoningEffort;\n if (route.maxTokens !== undefined) stamped.maxTokens = route.maxTokens;\n return stamped;\n },\n { prepend: true },\n );\n harness.on(\"agent/disposed\", (disposed) => {\n if (disposed === agent) dispose();\n });\n });\n\n if (this.config.promptSection) {\n harness.systemPrompt.section({\n name: ROW_ID,\n order: SECTION_ORDER,\n text: SECTION_TEXT.replaceAll(\"{PLANNER_MODEL}\", this.config.planner.model).replaceAll(\n \"{EXECUTOR_MODEL}\",\n this.config.executor.model,\n ),\n });\n }\n\n if (this.config.skill) {\n harness.skills.register({\n name: SKILL_NAME,\n description: SKILL_DESCRIPTION,\n whenToUse: SKILL_WHEN_TO_USE,\n content: SKILL_CONTENT,\n source: \"runtime\",\n });\n }\n }\n}\n\nexport {\n Config,\n ModelRouter,\n ModelRouter as default,\n name,\n ROW_ID,\n SKILL_CONTENT,\n SKILL_DESCRIPTION,\n SKILL_NAME,\n SKILL_WHEN_TO_USE,\n roleFor,\n routeFor,\n};\nexport type {\n AgentRole,\n ModelRoute,\n ReasoningEffort,\n RoutingMode,\n RouterConfig,\n} from \"./policy.js\";\n","/**\n * Pure routing policy for dsh-model-router: which model each agent role gets.\n * Kept free of Cordis imports so the policy is trivially unit-testable.\n * @module dsh-model-router/policy\n */\n\n/** Reasoning-effort levels a route may pin (mirrors the harness vocabulary). */\nexport type ReasoningEffort = \"off\" | \"low\" | \"high\" | \"max\";\n\n/**\n * How the router treats the root agent.\n * - `strict`: the root agent is always the planner (pro).\n * - `plan`: the root agent is pro only while plan mode is active; otherwise it\n * falls back to the executor route, reserving pro for real planning.\n */\nexport type RoutingMode = \"strict\" | \"plan\";\n\n/** One route: a provider/model pair stamped onto an agent request. */\nexport interface ModelRoute {\n provider: string;\n model: string;\n /**\n * Optional reasoning-effort override. When omitted, the request inherits the\n * session's own selection; when set, the router pins it for that role.\n */\n reasoningEffort?: ReasoningEffort;\n /** Optional output-token cap for the role; omitted means inherit. */\n maxTokens?: number;\n}\n\n/** The two roles the router distinguishes. */\nexport type AgentRole = \"planner\" | \"executor\";\n\n/** Resolved router configuration: one route per role plus routing mode. */\nexport interface RouterConfig {\n planner: ModelRoute;\n executor: ModelRoute;\n mode: RoutingMode;\n promptSection: boolean;\n skill: boolean;\n}\n\n/**\n * Classify an agent as planner or executor.\n *\n * The main (root) agent of a session is the planner. Every agent created as a\n * delegation child — `subagent`, `subagent_fork`, workflow workers, ralph\n * rounds — is an executor. The harness stamps two durable facts on children:\n * `options.subagentDepth` (>= 1) and the session header `origin: \"subagent\"`.\n *\n * @param agent - the live agent (any subset of the runtime shape).\n * @returns the role the agent should be routed as.\n */\nexport function roleFor(agent: unknown): AgentRole {\n const options = (agent as { options?: unknown })?.options;\n const depth = (options as { subagentDepth?: unknown })?.subagentDepth;\n if (typeof depth === \"number\" && depth >= 1) return \"executor\";\n const session = (agent as { session?: unknown })?.session;\n const origin = (session as { header?: unknown })?.header\n ? ((session as { header: { origin?: unknown } }).header.origin)\n : undefined;\n if (origin === \"subagent\") return \"executor\";\n return \"planner\";\n}\n\n/**\n * Resolve the route for one agent.\n * @param agent - the live agent.\n * @param config - the resolved router configuration.\n * @param planModeActive - whether plan mode is currently folded active for the\n * agent's session; consulted only in `plan` routing mode.\n * @returns the model route to stamp, or `undefined` to leave the request alone.\n */\nexport function routeFor(\n agent: unknown,\n config: RouterConfig,\n planModeActive = false,\n): ModelRoute | undefined {\n const role = roleFor(agent);\n if (role === \"executor\") return config.executor;\n // Root agent. In `plan` mode, reserve the planner route for actual planning;\n // otherwise the root falls back to the executor route.\n if (config.mode === \"plan\" && !planModeActive) return config.executor;\n return config.planner;\n}\n"],"mappings":";AAoBA,SAAkB,eAAe;AACjC,OAAO,OAAO;AACd,SAAS,oBAAoB;;;AC+BtB,SAAS,QAAQ,OAA2B;AACjD,QAAM,UAAW,OAAiC;AAClD,QAAM,QAAS,SAAyC;AACxD,MAAI,OAAO,UAAU,YAAY,SAAS,EAAG,QAAO;AACpD,QAAM,UAAW,OAAiC;AAClD,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A,MAClC,CAAC;AAAA,IACH,CAAC;AAED,QAAI,KAAK,OAAO,eAAe;AAC7B,cAAQ,aAAa,QAAQ;AAAA,QAC3B,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM,aAAa,WAAW,mBAAmB,KAAK,OAAO,QAAQ,KAAK,EAAE;AAAA,UAC1E;AAAA,UACA,KAAK,OAAO,SAAS;AAAA,QACvB;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,KAAK,OAAO,OAAO;AACrB,cAAQ,OAAO,SAAS;AAAA,QACtB,MAAM;AAAA,QACN,aAAa;AAAA,QACb,WAAW;AAAA,QACX,SAAS;AAAA,QACT,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/policy.ts"],"sourcesContent":["/**\n * dsh-model-router: role-based model routing for the DeepSeek Harness.\n *\n * The planner (the session's root agent) runs on `deepseek-v4-pro`; delegated\n * executor subagents run on `deepseek-v4-flash`. Enforcement is a per-agent\n * `agent/request` rewrite registered when the agent is created, so it applies\n * in every mode (web / headless / tui) and every agent preset, including\n * subagents the delegation tools create.\n *\n * Each role route may also pin `reasoningEffort` and `maxTokens`; when set,\n * they override the session's selection for that role. A `mode` switch lets a\n * deployment reserve the planner route for actual planning.\n *\n * The plugin also publishes:\n * - a system-prompt section stating the planner/executor convention, and\n * - the `pro-flash-routing` skill teaching the agent to plan itself and\n * delegate code execution to flash subagents.\n *\n * @module dsh-model-router\n */\nimport { Context, Service } from \"@deepseek-ai/cordis\";\nimport z from \"@deepseek-ai/schemastery\";\nimport { foldPlanMode } from \"@deepseek-ai/dsh-plan-mode\";\nimport { effortFor, recentStepsHadError, roleFor, routeFor, type RouterConfig } from \"./policy.js\";\n\n/** Plugin row id; the bundle patch inserts it under this id. */\nconst name = \"model-router\";\n\n/** One provider/model pair, with defaults and optional effort/token caps. */\nconst ModelRouteSchema = z.object({\n provider: z.string().min(1),\n model: z.string().min(1),\n reasoningEffort: z.union([\"off\", \"low\", \"high\", \"max\"]),\n maxTokens: z.number().min(1),\n escalateOnError: z.boolean(),\n escalateTo: z.union([\"off\", \"low\", \"high\", \"max\"]),\n recoverySteps: z.number().min(1),\n});\n\n/** The plugin's public config, validated at row load. */\nconst Config = z.object({\n planner: ModelRouteSchema.default({\n provider: \"deepseek-official\",\n model: \"deepseek-v4-pro\",\n } as never),\n executor: ModelRouteSchema.default({\n provider: \"deepseek-official\",\n model: \"deepseek-v4-flash\",\n } as never),\n mode: z.union([\"strict\", \"plan\"]).default(\"strict\"),\n promptSection: z.boolean().default(true),\n skill: z.boolean().default(true),\n});\n\n/**\n * Resolve raw row config into the internal shape, failing loud on garbage.\n * Schemastery schemas are callable: invoking validates and applies defaults.\n * @param raw - the row's config object.\n * @returns the validated RouterConfig.\n */\nfunction resolveConfig(raw: unknown): RouterConfig {\n const parsed = Config(raw ?? {});\n return {\n planner: parsed.planner,\n executor: parsed.executor,\n mode: parsed.mode,\n promptSection: parsed.promptSection,\n skill: parsed.skill,\n };\n}\n\n/**\n * Always-on guidance section. Negative order renders before the persona, so\n * the convention is established before the agent's identity line.\n */\nconst SECTION_ORDER = -50;\n\nconst SECTION_TEXT = `Model routing is role-based. Planning runs on {PLANNER_MODEL}; implementation runs on {EXECUTOR_MODEL}. You are the root agent: plan, design, review subagent output, and write the final answer here. Delegate implementation — writing code, running commands, builds, tests — to subagents with complete, self-contained prompts, preferring background delegation for independent work. Keep plans and replies concise. Do not hand-write large amounts of code or run long executions here; delegate instead.`;\n\nconst SKILL_NAME = \"pro-flash-routing\";\n\nconst SKILL_DESCRIPTION =\n \"Route planning and code execution across models: plan on the pro planner agent, delegate implementation to flash executor subagents.\";\n\nconst SKILL_WHEN_TO_USE = `Use when a task combines planning and implementation: before writing code, after a plan is approved, when delegating execution work, or when the user asks about the pro/flash routing convention.`;\n\nconst SKILL_CONTENT = `# Pro planner / Flash executor routing\n\nThis session routes models by role:\n\n- **Planner (this agent)** — \\`deepseek-v4-pro\\`. Planning, design decisions, reviewing delegated output, and user-facing synthesis happen here.\n- **Executors (every subagent)** — \\`deepseek-v4-flash\\`. Implementation work happens there: writing code, running commands, builds, and tests. The harness forces the model automatically; you do not select it.\n\n## Working rhythm\n\n1. **Plan here.** Explore, decide the approach, and (when plan mode is on) submit the plan with \\`exit_plan_mode\\`. The plan stays on this agent.\n2. **Delegate the execution.** Once a plan is approved, hand each self-contained chunk of implementation to a subagent with a complete prompt: exact files to touch, the change to make, and how to verify. Subagents are automatically routed to \\`deepseek-v4-flash\\`, so keep them execution-focused: give them the decision, not the decision to make.\n3. **Review here.** Read the subagent's result on this agent, verify it yourself (tests, diffs, logs), and iterate with follow-up messages to the same subagent when available.\n4. **Report here.** Summaries, plans, and answers to the user come from this agent.\n\n## Keep this agent's context lean\n\nInput tokens are the expensive part of the planner. Don't re-read large files or full transcripts on this agent — trust the subagent's final report. Prefer targeted reads (offset/limit) over whole files. When the context grows, compact rather than re-sending everything.\n\n## Delegation guidelines\n\n- Start independent delegations together in one assistant message and continue useful work while they run (background mode by default).\n- Prefer \\`subagent\\` for self-contained work and \\`workflow\\` when many independent pieces need fan-out; their workers run on flash as well.\n- Do not delegate design: subagents execute decisions already made.\n- If a subagent's task grows into design work, pull it back to this agent and re-delegate the narrowed execution.\n\n## Verification\n\n- Executor output was produced by \\`deepseek-v4-flash\\`; planner output by \\`deepseek-v4-pro\\`. If you need to confirm, check the session log's model metadata.\n- If routing ever looks wrong, the \\`model-router\\` plugin row in the profile composition is the single place that owns it.`;\n\n/** The plugin row id the bundle patch must insert. */\nconst ROW_ID = \"model-router\";\n\n/** Minimal structural view of the live agent object the router reads. */\ninterface AgentLike {\n ctx: AgentScopedContext;\n options?: { subagentDepth?: number };\n session?: { header?: { origin?: string }; events?: unknown[] };\n}\n\n/** The agent-scoped context's waterfall surface the router uses. */\ninterface AgentScopedContext {\n on(\n event: \"agent/request\",\n listener: (\n payload: Record<string, unknown>,\n next: () => Promise<Record<string, unknown>>,\n ) => Promise<Record<string, unknown>>,\n options?: { prepend?: boolean },\n ): () => void;\n}\n\n/** Host-plane surface the router consumes (events, prompt registry, skills). */\ninterface HarnessContext {\n on(\n event: \"agent/created\",\n listener: (payload: { agent: AgentLike }) => void,\n ): () => void;\n on(event: \"agent/disposed\", listener: (agent: unknown) => void): () => void;\n systemPrompt: {\n section(section: { name: string; order: number; text: string }): unknown;\n };\n skills: {\n register(skill: {\n name: string;\n description: string;\n whenToUse?: string;\n content: string;\n source: string;\n }): unknown;\n };\n}\n\n/** Fold plan-mode state for an agent without trusting the agent's exact shape. */\nfunction isPlanModeActive(agent: AgentLike): boolean {\n const events = agent.session?.events;\n if (!Array.isArray(events)) return false;\n try {\n return foldPlanMode(events as Parameters<typeof foldPlanMode>[0]);\n } catch {\n return false;\n }\n}\n\n/**\n * Cordis service: per-agent request routing plus the convention surface.\n */\nclass ModelRouter extends Service {\n static inject = [\"skills\", \"systemPrompt\"];\n\n config: RouterConfig;\n\n constructor(ctx: Context, rawConfig: unknown = {}) {\n super(ctx, \"modelRouter\");\n this.config = resolveConfig(rawConfig);\n const harness = ctx as unknown as HarnessContext;\n\n // Every agent that gets created — root sessions, delegation children,\n // workflow workers, ralph rounds — passes through here.\n harness.on(\"agent/created\", ({ agent }) => {\n // `prepend` puts this listener OUTERMOST in the `agent/request`\n // waterfall: the harness's model-selection listener runs inside it, so\n // this rewrite is applied LAST and wins over the session's selected\n // model (which dsh-base defaults to deepseek-v4-flash and the user\n // settings or UI can change).\n const dispose = agent.ctx.on(\n \"agent/request\",\n async (payload, next) => {\n const resolved = await next();\n const route = routeFor(agent, this.config, isPlanModeActive(agent));\n if (route === undefined) return resolved;\n const stamped: Record<string, unknown> = {\n ...resolved,\n provider: route.provider,\n model: route.model,\n };\n if (route.maxTokens !== undefined) stamped.maxTokens = route.maxTokens;\n const effort = effortFor(route, agent.session?.events);\n if (effort !== undefined) stamped.reasoningEffort = effort;\n return stamped;\n },\n { prepend: true },\n );\n harness.on(\"agent/disposed\", (disposed) => {\n if (disposed === agent) dispose();\n });\n });\n\n if (this.config.promptSection) {\n harness.systemPrompt.section({\n name: ROW_ID,\n order: SECTION_ORDER,\n text: SECTION_TEXT.replaceAll(\"{PLANNER_MODEL}\", this.config.planner.model).replaceAll(\n \"{EXECUTOR_MODEL}\",\n this.config.executor.model,\n ),\n });\n }\n\n if (this.config.skill) {\n harness.skills.register({\n name: SKILL_NAME,\n description: SKILL_DESCRIPTION,\n whenToUse: SKILL_WHEN_TO_USE,\n content: SKILL_CONTENT,\n source: \"runtime\",\n });\n }\n }\n}\n\nexport {\n Config,\n ModelRouter,\n ModelRouter as default,\n name,\n ROW_ID,\n SKILL_CONTENT,\n SKILL_DESCRIPTION,\n SKILL_NAME,\n SKILL_WHEN_TO_USE,\n effortFor,\n recentStepsHadError,\n roleFor,\n routeFor,\n};\nexport type {\n AgentRole,\n ModelRoute,\n ReasoningEffort,\n RoutingMode,\n RouterConfig,\n} from \"./policy.js\";\n","/**\n * Pure routing policy for dsh-model-router: which model each agent role gets.\n * Kept free of Cordis imports so the policy is trivially unit-testable.\n * @module dsh-model-router/policy\n */\n\n/** Reasoning-effort levels a route may pin (mirrors the harness vocabulary). */\nexport type ReasoningEffort = \"off\" | \"low\" | \"high\" | \"max\";\n\n/**\n * How the router treats the root agent.\n * - `strict`: the root agent is always the planner (pro).\n * - `plan`: the root agent is pro only while plan mode is active; otherwise it\n * falls back to the executor route, reserving pro for real planning.\n */\nexport type RoutingMode = \"strict\" | \"plan\";\n\n/** One route: a provider/model pair stamped onto an agent request. */\nexport interface ModelRoute {\n provider: string;\n model: string;\n /**\n * Optional reasoning-effort override. When omitted, the request inherits the\n * session's own selection; when set, the router pins it for that role.\n */\n reasoningEffort?: ReasoningEffort;\n /** Optional output-token cap for the role; omitted means inherit. */\n maxTokens?: number;\n /**\n * Error-driven escalation (v1): when true, a failed execution step bumps the\n * next request's effort to `escalateTo`, wearing off after `recoverySteps`\n * clean steps. Deterministic, stateless — the session log is folded per\n * request, so only *prior* steps are ever considered.\n */\n escalateOnError?: boolean;\n /** Effort used for the request after a failed step. */\n escalateTo?: ReasoningEffort;\n /** Clean steps before escalation wears off. Defaults to 2. */\n recoverySteps?: number;\n}\n\n/** The two roles the router distinguishes. */\nexport type AgentRole = \"planner\" | \"executor\";\n\n/** Resolved router configuration: one route per role plus routing mode. */\nexport interface RouterConfig {\n planner: ModelRoute;\n executor: ModelRoute;\n mode: RoutingMode;\n promptSection: boolean;\n skill: boolean;\n}\n\n/** Default recovery window: an error escalates for the next two completed steps. */\nexport const DEFAULT_RECOVERY_STEPS = 2;\n\n/**\n * Classify an agent as planner or executor.\n *\n * The main (root) agent of a session is the planner. Every agent created as a\n * delegation child — `subagent`, `subagent_fork`, workflow workers, ralph\n * rounds — is an executor. The harness stamps two durable facts on children:\n * `options.subagentDepth` (>= 1) and the session header `origin: \"subagent\"`.\n *\n * @param agent - the live agent (any subset of the runtime shape).\n * @returns the role the agent should be routed as.\n */\nexport function roleFor(agent: unknown): AgentRole {\n const options = (agent as { options?: unknown })?.options;\n const depth = (options as { subagentDepth?: unknown })?.subagentDepth;\n if (typeof depth === \"number\" && depth >= 1) return \"executor\";\n const session = (agent as { session?: unknown })?.session;\n const origin = (session as { header?: unknown })?.header\n ? ((session as { header: { origin?: unknown } }).header.origin)\n : undefined;\n if (origin === \"subagent\") return \"executor\";\n return \"planner\";\n}\n\n/**\n * Resolve the route for one agent.\n * @param agent - the live agent.\n * @param config - the resolved router configuration.\n * @param planModeActive - whether plan mode is currently folded active for the\n * agent's session; consulted only in `plan` routing mode.\n * @returns the model route to stamp, or `undefined` to leave the request alone.\n */\nexport function routeFor(\n agent: unknown,\n config: RouterConfig,\n planModeActive = false,\n): ModelRoute | undefined {\n const role = roleFor(agent);\n if (role === \"executor\") return config.executor;\n // Root agent. In `plan` mode, reserve the planner route for actual planning;\n // otherwise the root falls back to the executor route.\n if (config.mode === \"plan\" && !planModeActive) return config.executor;\n return config.planner;\n}\n\n/**\n * Whether any of the last `recoverySteps` completed steps carried a failed\n * tool result. A failure is a `tool/result` event whose data carries an\n * `error` field (the harness records tool failures there).\n *\n * Steps are deduplicated by `turn:step`, and only *completed* steps count —\n * events are scanned from the tail, so the current in-flight request is never\n * considered.\n *\n * @param events - the agent's session event log (or `undefined`).\n * @param recoverySteps - how many completed steps back to scan.\n * @returns true when a failed step is within the window.\n */\nexport function recentStepsHadError(\n events: readonly unknown[] | undefined,\n recoverySteps: number = DEFAULT_RECOVERY_STEPS,\n): boolean {\n if (!Array.isArray(events) || recoverySteps <= 0) return false;\n const seen = new Set<string>();\n let steps = 0;\n for (let i = events.length - 1; i >= 0; i -= 1) {\n const event = events[i] as\n | { type?: string; data?: { turn?: number; step?: number; error?: unknown } }\n | undefined;\n if (event?.type !== \"tool/result\" || event.data === undefined) continue;\n const key = `${event.data.turn}:${event.data.step}`;\n if (!seen.has(key)) {\n // A new step beyond the recovery window ends the scan; events for steps\n // already inside the window are still checked below.\n if (steps >= recoverySteps) break;\n seen.add(key);\n steps += 1;\n }\n if (event.data.error !== undefined && event.data.error !== null) return true;\n }\n return false;\n}\n\n/**\n * Resolve the reasoning effort to stamp for one request.\n *\n * Baseline is the route's `reasoningEffort`; when `escalateOnError` is enabled\n * and a recent step failed, the effort bumps to `escalateTo` (falling back to\n * the baseline when `escalateTo` is unset). Returns `undefined` to leave the\n * request's effort alone (inherit the session selection).\n *\n * @param route - the resolved route for the agent.\n * @param events - the agent's session event log.\n * @returns the effort to stamp, or `undefined` to inherit.\n */\nexport function effortFor(\n route: ModelRoute,\n events: readonly unknown[] | undefined,\n): ReasoningEffort | undefined {\n if (route.escalateOnError === true && recentStepsHadError(events, route.recoverySteps)) {\n return route.escalateTo ?? route.reasoningEffort;\n }\n return route.reasoningEffort;\n}\n"],"mappings":";AAoBA,SAAkB,eAAe;AACjC,OAAO,OAAO;AACd,SAAS,oBAAoB;;;ACgCtB,IAAM,yBAAyB;AAa/B,SAAS,QAAQ,OAA2B;AACjD,QAAM,UA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,UAC1E;AAAA,UACA,KAAK,OAAO,SAAS;AAAA,QACvB;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,KAAK,OAAO,OAAO;AACrB,cAAQ,OAAO,SAAS;AAAA,QACtB,MAAM;AAAA,QACN,aAAa;AAAA,QACb,WAAW;AAAA,QACX,SAAS;AAAA,QACT,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-model-router",
3
3
  "description": "DeepSeek Harness plugin: role-based model routing — the planner agent runs on deepseek-v4-pro, delegated executor subagents run on deepseek-v4-flash.",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },