@henryqw/pi-subagent 10.1.0 → 11.0.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/CONTEXT.md CHANGED
@@ -9,8 +9,8 @@ Provide validated built-in and user Roles, shared task-model Pi launch policy, g
9
9
  - **Main**: Pi session that plans and orchestrates delegated work.
10
10
  - **Subagent**: isolated Pi child process handling one task.
11
11
  - **Role**: package-shipped built-in or user-owned Markdown definition of a reusable responsibility, with a name, description, system instructions, required `tools`, `extensions`, and `skills` arrays, and optional isolation.
12
- - **Model Class**: `fast`, `balanced`, `frontier`, or `fav`, resolved through shared task-model settings; Main normally selects `fast`, may select `balanced` upfront for obvious complexity, and leaves direct model/thinking overrides to explicit user requests.
13
- - **Route**: configured model and thinking-level pair selected from a shared Model Class profile; the primary route precedes its optional fallback.
12
+ - **Model Class**: `fast`, `balanced`, `frontier`, or `fav`, resolved through shared task-model settings.
13
+ - **Route**: configured model and exact thinking-level pair selected from a shared Model Class profile; the primary route precedes its optional fallback. A direct model can replace only its model.
14
14
  - **Delegated Task**: one bounded work request sent from Main to one Role.
15
15
  - **Workflow**: generic orchestration of one or more Delegated Tasks; `delegate_task` owns its selected mode, while library callers compose executor runs in JavaScript.
16
16
  - **Workflow Mode**: `delegate_task` tool policy selected per call for `single`, `parallel`, or `chain` execution; not a Role property or executor API.
@@ -27,8 +27,8 @@ Provide validated built-in and user Roles, shared task-model Pi launch policy, g
27
27
  - Up to five active ephemeral `delegate_task` children run per Main by default, configurable via `maxSubagents` in `~/.pi/agent/config/pi-subagent/config.json` or the `PI_SUBAGENT_MAX_SUBAGENTS` environment variable; excess calls wait FIFO. Queued calls do not start a child or consume child timeout.
28
28
  - Ambient child extensions and Skills stay disabled. Every Role requires `tools`, `extensions`, and `skills` YAML arrays, and every launch installs the Role tool policy. `tools: []` activates no base built-ins but does activate all tools from explicitly selected trusted extension bundles and explicit caller tool additions; `skills: []` selects no separately named Role Skills but trusted selected extension Skills still load; `extensions: []` selects no Role extension bundle. A Role/caller explicitly selected extension is a trusted atomic capability bundle: all tools it registers and all Skills supplied through its Pi package metadata or dynamic `resources_discover` load alongside separately named Role Skills. This intentionally includes the extension's executable lifecycle/prompt behavior; pi-subagent does not infer or externally narrow undocumented dependencies, and loading an extension is not sandboxing. Scope children by selecting fewer trusted extensions; finer granularity requires separate entry points/configuration or an upstream split. Explicit Role/caller tool names still verify against the final filtered registry, while parent-only recursive orchestration tools remain excluded.
29
29
  - Role Skill names resolve through Main's effective Pi Skill registry; unavailable names warn and skip without blocking delegation. Explicit Role/caller tool names verify against the final filtered child registry after explicit provider `session_start` handlers, and unavailable names fail before the first turn.
30
- - Main policy populates direct `model` and `thinking` only for explicit user overrides; otherwise it selects only `modelClass` (`fast` normally, `balanced` upfront for obvious complexity). This has no provenance tracking or runtime enforcement. An omitted class uses pi-subagent's local `pi-subagent/delegateTask` Model Task declaration (default `fast`); library callers select a Role plus their own Model Task declaration.
31
- - The selected profile resolves primary then fallback only before launch when a route, model, or thinking level is unavailable. A missing local JSON config uses defaults quietly. Missing shared task-model config warns once per session because delegation needs a route. If neither route is usable, launch rejects with `Run /task-models`; a started child is never retried by this package.
30
+ - Main selects `modelClass`; an omitted class uses pi-subagent's local `pi-subagent/delegateTask` Model Task declaration (default `fast`). A direct model replaces only the selected route model and must honor its exact thinking level. Library callers select a Role plus their own Model Task declaration.
31
+ - The selected profile resolves primary then fallback only before launch when a route, model, or thinking level is unavailable. A direct model never changes the route level and fails before launch if it cannot honor it. A missing local JSON config uses defaults quietly. Missing shared task-model config warns once per session because delegation needs a route. If neither route is usable, launch rejects with `Run /task-models`; a started child is never retried by this package.
32
32
  - User Role Markdown files and Subagent JSON config (`config/pi-subagent/config.json`) live only in the user `config/pi-subagent` directory; model routes live in shared `config/pi-task-models/config.json`. Package-shipped built-in Roles (`implementer`, `reviewer`, `scout`) resolve from the package's own `examples/roles/` Markdown through the same parser; same-named user files override built-ins for `delegate_task`, while same-named `implementer` and `reviewer` files override Flow defaults. The `synthesizer` Markdown remains the only optional inert sample.
33
33
  - `delegate_flow` accepts 1–8 independent units with direct validation commands, optional `modelClass`, and optional non-empty `review` judgment text. Omitted classes use pi-subagent's local `pi-subagent/delegateTask` declaration (default `fast`); each unit's current class resolves through its shared profile route for its Implementer and, when `review` exists, Reviewer. At Flow start it always resolves/freezes the effective Implementer and resolves/freezes a Reviewer only when at least one requested unit has `review`. One active Flow creates every Unit Worktree before launching Implementers in parallel, then processes settled units in declared order. For each unit Flow rebases in place when earlier units advanced Main, inspects committed Git state, and runs declared validation. Validation is authoritative for objective verification: units without `review` fast-forward their exact validated tip; units with `review` send the exact Review Packet to the Reviewer in the same worktree and require exact `PASS` before the same guarded `git merge --ff-only` path.
34
34
  - Flow is memory-only. Only a post-rebase commit drop produces a no-op (`base === tip`); it validates, skips Reviewer and merge, then cleans up ordinarily. Initial zero-commit implementations block. Implementer, validation, or reviewer blocks allow one `delegate_flow_continue({ guidance, modelClass? })` repair in the same worktree; omission retains the Unit's current class and presence replaces it for that repair. A second block is terminal. Rebase and evidence/Reviewer/infrastructure failures retain worktrees. A reported fast-forward failure retains its worktree unless Main is clean at the exact integrated tip, which completes with the merge diagnostic as a warning. Cleanup uses non-forced worktree removal and branch deletion; cleanup refusal is a completion warning.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Main is the parent Pi session. It can delegate bounded single, parallel, and chained tasks, plus package-owned Git Flow work, to isolated Pi child roles.
4
4
 
5
+ ![Pi showing six delegated tasks running in parallel](./example.png)
6
+
5
7
  ## Why
6
8
 
7
9
  - **Created for**: Delegate bounded work to isolated child Pi processes without losing Main's context.
@@ -42,27 +44,25 @@ Select exactly one shape:
42
44
 
43
45
  ```text
44
46
  // Single
45
- { role, name, task, model?, modelClass?, thinking?, background? }
47
+ { role, name, task, model?, modelClass?, background? }
46
48
 
47
49
  // Parallel: 1–8 independent delegations
48
- { tasks: [{ role, name, task, model?, modelClass?, thinking? }], background? }
50
+ { tasks: [{ role, name, task, model?, modelClass? }], background? }
49
51
 
50
52
  // Chain: 1–8 dependent delegations
51
- { chain: [{ role, name, task, model?, modelClass?, thinking? }], background? }
53
+ { chain: [{ role, name, task, model?, modelClass? }], background? }
52
54
  ```
53
55
 
54
56
  Main supplies every delegation's required `name`: a short description of about five words and fewer than 30 characters. Names must not contain C0/C1 control characters, including newlines and terminal escape characters.
55
57
 
56
- #### Model precedence
58
+ #### Model routing
57
59
 
58
- 1. An explicit `model` is `provider/modelId` and overrides `modelClass`.
59
- 2. Main sets direct `model` and `thinking` only for an explicit user override.
60
- 3. Otherwise, Main selects `modelClass`: `fast` normally or `balanced` upfront for obviously complex work.
61
- 4. `modelClass` is `fast`, `balanced`, `frontier`, or `fav`.
62
- When omitted, it uses pi-subagent's local `pi-subagent/delegateTask` Model Task declaration.
63
- That declaration defaults to `fast` and shared config can explicitly override it.
60
+ 1. `modelClass` selects a route. It is `fast`, `balanced`, `frontier`, or `fav`.
61
+ 2. An omitted class uses pi-subagent's `pi-subagent/delegateTask` declaration. Its default is `fast`.
62
+ 3. The route supplies the model and exact thinking level.
63
+ 4. An explicit `model` is `provider/modelId`. It replaces only the route model and must support its thinking level.
64
64
 
65
- This is Main policy only. The runtime records no provenance and does not enforce it. `background` applies to the whole selected mode and is never a per-delegation field.
65
+ `background` applies to the whole selected mode. It is never a per-delegation field.
66
66
 
67
67
  The transient status widget renders one line per child with: status glyph, bracketed uppercase role initial (`[I]` for `implementer`, `[R]` for `reviewer`, and likewise for custom Roles), Main-supplied short name, activity (thinking… or active tool with elapsed time and path basename), and metrics (completed turns, started tools, compact `model·thinking` pair, tokens, total duration). Rows are ordered active-first (working items first, stable insertion order for the rest). A hard six-physical-line maximum applies: when total items are six or fewer, all child rows render; above six, five child rows plus one status-aware overflow line render (`… N more · X working · Y complete · Z failed · W stopped`). Terminal rows clear on the next real user input; active rows persist until the child settles. It is separate from Pi's built-in tool-execution block.
68
68
 
package/dist/index.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare function loadBuiltinRole(name: BuiltinRoleName): Role;
54
54
  * user files are an error. Missing user directory returns the built-ins.
55
55
  */
56
56
  export declare function loadRoles(agentDir?: string): Role[];
57
- export declare function resolveTaskRoute(ctx: ExtensionContext, profileName: ProfileName, agentDir?: string, thinking?: ThinkingLevel): ResolvedTaskRoute;
57
+ export declare function resolveTaskRoute(ctx: ExtensionContext, profileName: ProfileName, agentDir?: string): ResolvedTaskRoute;
58
58
  export declare function resolveRoleSkills(pi: Pick<ExtensionAPI, "getCommands">, role: Role): ResolvedRoleSkills;
59
59
  export declare function createRoleLaunch(pi: Pick<ExtensionAPI, "getCommands">, ctx: Pick<ExtensionContext, "isProjectTrusted">, input: CreateRoleLaunchInput): ResolvedRoleLaunch;
60
60
  export declare function resolveRoleLaunch(pi: Pick<ExtensionAPI, "getCommands">, ctx: ExtensionContext, input: ResolveRoleLaunchInput): ResolvedRoleLaunch;
package/dist/index.js CHANGED
@@ -117,7 +117,7 @@ export function loadRoles(agentDir = getAgentDir()) {
117
117
  }
118
118
  return [...byName.values()];
119
119
  }
120
- export function resolveTaskRoute(ctx, profileName, agentDir = getAgentDir(), thinking) {
120
+ export function resolveTaskRoute(ctx, profileName, agentDir = getAgentDir()) {
121
121
  let config;
122
122
  try {
123
123
  config = loadTaskModelsConfig(agentDir).value;
@@ -125,17 +125,17 @@ export function resolveTaskRoute(ctx, profileName, agentDir = getAgentDir(), thi
125
125
  catch {
126
126
  throw new Error("Couldn't read task model config. Run /task-models.");
127
127
  }
128
- return resolveConfiguredRoute(ctx, profileName, config.profiles[profileName], agentDir, thinking);
128
+ return resolveConfiguredRoute(ctx, profileName, config.profiles[profileName], agentDir);
129
129
  }
130
- function resolveConfiguredRoute(ctx, profileName, profile, agentDir = getAgentDir(), thinking) {
130
+ function resolveConfiguredRoute(ctx, profileName, profile, agentDir = getAgentDir()) {
131
131
  if (!profile)
132
132
  throw new Error(`No ${profileName} task model profile is configured. Run /task-models.`);
133
133
  for (const route of orderedProfileRoutes(profile)) {
134
- const resolved = resolveTaskModelRoute(ctx, route, agentDir, thinking);
134
+ const resolved = resolveTaskModelRoute(ctx, route, agentDir);
135
135
  if (resolved)
136
136
  return resolved;
137
137
  }
138
- throw new Error(`No usable ${profileName} task model route${thinking ? ` supporting thinking ${thinking}` : ""}. Run /task-models.`);
138
+ throw new Error(`No usable ${profileName} task model route. Run /task-models.`);
139
139
  }
140
140
  export function resolveRoleSkills(pi, role) {
141
141
  const skills = new Map(pi.getCommands()
@@ -14,7 +14,7 @@ Resource Policy is split at launch preparation:
14
14
 
15
15
  Built-in `implementer`, `reviewer`, and `scout` Roles ship as Markdown in `examples/roles/` and use the same parser as user Roles. For generic delegation, a same-named user Role explicitly overrides a built-in. The package does not install, copy, or write user configuration.
16
16
 
17
- Main populates direct `model` and `thinking` only for explicit user overrides; otherwise it chooses only `modelClass` (`fast` normally, `balanced` upfront for obvious complexity). This is tool policy, not executor provenance tracking or runtime enforcement.
17
+ `modelClass` selects a task-model route. The route owns its exact thinking level. A direct `model` replaces only the route model and must honor that level.
18
18
 
19
19
  ## Scope boundary
20
20
 
@@ -9,7 +9,7 @@ delegate_flow({ units: [{ id, task, modelClass?, validation: [{ command, args }]
9
9
  delegate_flow_continue({ guidance, modelClass? });
10
10
  ```
11
11
 
12
- A Flow accepts 1–8 independent units with unique IDs. `modelClass` is optional and otherwise uses the shared `pi-subagent/delegateTask` assignment; its class resolves through the existing `pi-task-models` profile model-and-thinking route for the unit's Implementer and, when applicable, Reviewer. `review` is optional non-empty text for the explicit judgment that declared validation cannot establish.
12
+ A Flow accepts 1–8 independent units with unique IDs. `modelClass` is optional and otherwise uses the shared `pi-subagent/delegateTask` assignment. The class resolves through the existing `pi-task-models` profile model-and-thinking route for the unit's Implementer and, when applicable, Reviewer. `review` is optional non-empty text for the explicit judgment that declared validation cannot establish.
13
13
 
14
14
  Only one memory-only Flow may be active. At start it resolves/freezes the effective `implementer` Role, including a same-named user override. It resolves/freezes the effective `reviewer` Role only when at least one requested unit has `review`. It requires a clean committed attached Main branch and creates one Unit Worktree per unit before launching Implementers in parallel. All started Implementers settle; Flow then processes units in declared order.
15
15
 
@@ -26,7 +26,6 @@ A call selects exactly one of these shapes. Unknown properties and nested modes
26
26
  "name": "Inspect authentication flow",
27
27
  "task": "One bounded task packet",
28
28
  "modelClass": "balanced",
29
- "thinking": "high",
30
29
  "background": false
31
30
  }
32
31
  ```
@@ -69,11 +68,10 @@ Single mode puts one delegation's fields at the top level.
69
68
  | `role` | yes | Name of a Role in the user's effective `config/pi-subagent` directory or a package-shipped built-in (`implementer`, `reviewer`, `scout`); a same-named user file overrides the built-in. |
70
69
  | `name` | yes | Main-supplied short task name: about five words and fewer than 30 characters; C0/C1 control characters are rejected. |
71
70
  | `task` | yes | Non-empty bounded task packet. |
72
- | `model` | no | Designated `provider/modelId`; takes precedence over `modelClass`, and Main supplies it only for an explicit user override. |
73
- | `modelClass` | no | `fast`, `balanced`, `frontier`, or `fav`; Main normally chooses `fast`, may choose `balanced` upfront for obvious complexity, and omission uses pi-subagent's local Model Task declaration. |
74
- | `thinking` | no | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`; Main supplies it only for an explicit user override. Route selection skips models that cannot honor it. |
71
+ | `model` | no | Designated `provider/modelId`; replaces only the selected route model and must support that route's thinking level. |
72
+ | `modelClass` | no | `fast`, `balanced`, `frontier`, or `fav`; selects the route. Main prioritizes `fast` for straightforward work and `balanced` for complex work. It reserves `frontier` for exceptionally complex or tricky work. Omission uses pi-subagent's local Model Task declaration. |
75
73
 
76
- Those six fields are the complete delegation object. The direct-model/thinking rule is Main-facing policy only: the runtime adds no provenance tracking or enforcement. `tasks`, `chain`, and `background` cannot be nested. Route fallback occurs only before launch; a started child is never retried by this package.
74
+ Those five fields are the complete delegation object. Routes set exact thinking levels. A direct model never changes that level and fails before launch if it cannot support it. `tasks`, `chain`, and `background` cannot be nested. Route fallback occurs only before launch; a started child is never retried by this package.
77
75
 
78
76
  ### Background, failures, and transport
79
77
 
@@ -87,7 +85,7 @@ All Main-visible text for one tool call shares one aggregate 50 KiB UTF-8 transp
87
85
 
88
86
  `delegate_flow({ units })` accepts 1–8 units with unique non-empty `id`, a required Main-supplied short `name` (about five words and fewer than 30 characters, without C0/C1 control characters), a non-empty `task`, one or more direct `{command, args}` validation commands, optional `modelClass`, and optional non-empty `review` text. `delegate_flow_continue({ guidance, modelClass? })` is available only for the one blocked unit of the active Flow.
89
87
 
90
- A Flow is memory-only and permits one active Flow. At start it always resolves/freezes the effective `implementer` Role, including a same-named user override. It resolves/freezes the effective `reviewer` only if at least one requested unit declares `review`. Omitted unit classes use pi-subagent's local `pi-subagent/delegateTask` declaration (default `fast`); a selected class resolves through its existing `pi-task-models` profile model-and-thinking route for the unit's Implementer and, when applicable, Reviewer. It requires clean committed Git Main and creates every Unit Worktree before launching work; setup failure launches no Implementer. Each unit gets exactly one worktree and one Implementer. Implementers run in parallel and all settle. Flow then processes units in declared order:
88
+ A Flow is memory-only and permits one active Flow. At start it always resolves/freezes the effective `implementer` Role, including a same-named user override. It resolves/freezes the effective `reviewer` only if at least one requested unit declares `review`. Omitted unit classes use pi-subagent's local `pi-subagent/delegateTask` declaration (default `fast`). A selected class resolves through its existing `pi-task-models` profile model-and-thinking route for the unit's Implementer and, when applicable, Reviewer. It requires clean committed Git Main and creates every Unit Worktree before launching work; setup failure launches no Implementer. Each unit gets exactly one worktree and one Implementer. Implementers run in parallel and all settle. Flow then processes units in declared order:
91
89
 
92
90
  ```text
93
91
  Implementers (parallel, one Unit Worktree each)
@@ -19,8 +19,9 @@ import {
19
19
  } from "@henryqw/pi-subagent";
20
20
  import { Type, type Static } from "typebox";
21
21
  import { Check } from "typebox/value";
22
- import { TASK_NAME_CONTRACT, TaskNameSchema, normalizeTaskName } from "./task-name.ts";
23
22
  import { runDelegation } from "./delegation.ts";
23
+ import { MODEL_CLASS_GUIDANCE } from "./model-class-policy.ts";
24
+ import { TASK_NAME_CONTRACT, TaskNameSchema, normalizeTaskName } from "./task-name.ts";
24
25
 
25
26
  const MAX_UNITS = 8;
26
27
  const GIT_TIMEOUT_MS = 30_000;
@@ -764,6 +765,7 @@ export function registerDelegateFlow(pi: ExtensionAPI, runtime: DelegateFlowRunt
764
765
  promptGuidelines: [
765
766
  "Use delegate_flow only for cohesive units expected to commute: split independent outcomes into units, sequence dependent work outside delegate_flow, and never divide one invariant across multiple units. Combine work that overlaps files, APIs, schemas, generated output, package metadata, lockfiles, or invariants.",
766
767
  `${TASK_NAME_CONTRACT.promptGuidance} Each delegate_flow unit must own one concrete outcome with one focused validation story: include explicit bounded requirements and its authoritative direct command/argument validation gate. If the affected flow or scope is not yet known, perform bounded read-only discovery first. Add review only for an explicit judgment that validation cannot establish.`,
768
+ `For each delegate_flow unit, ${MODEL_CLASS_GUIDANCE}`,
767
769
  "If a Flow blocks, inspect its classification and call delegate_flow_continue once with explicit repair guidance; modelClass may replace that one repair's current class.",
768
770
  ],
769
771
  parameters: DelegateFlowSchema,
@@ -0,0 +1 @@
1
+ export const MODEL_CLASS_GUIDANCE = "Prioritize modelClass fast for straightforward work and balanced for complex work. Reserve frontier for exceptionally complex or tricky work.";
@@ -5,7 +5,6 @@ import { type Component, type TUI, truncateToWidth } from "@earendil-works/pi-tu
5
5
  import {
6
6
  availableTaskModels,
7
7
  loadTaskModelsConfig,
8
- type ThinkingLevel,
9
8
  modelReference,
10
9
  registerModelTask,
11
10
  resolveAvailableModel,
@@ -36,6 +35,7 @@ import {
36
35
  import { DEFAULT_TIMEOUT_CONFIG, readSubagentConfig, type SubagentTimeoutConfig } from "./config.ts";
37
36
  import { registerDelegateFlow } from "./delegate-flow.ts";
38
37
  import { runDelegation } from "./delegation.ts";
38
+ import { MODEL_CLASS_GUIDANCE } from "./model-class-policy.ts";
39
39
  import {
40
40
  formatBackgroundWorkflowResult,
41
41
  formatWorkflowResult,
@@ -182,23 +182,17 @@ function renderWidgetRows(
182
182
  return lines;
183
183
  }
184
184
 
185
- function resolveDesignatedRoute(ctx: ExtensionContext, reference: string, thinking?: ThinkingLevel): ResolvedTaskRoute {
185
+ function replaceRouteModel(ctx: ExtensionContext, reference: string, route: ResolvedTaskRoute): ResolvedTaskRoute {
186
186
  const models = availableTaskModels(ctx);
187
187
  const model = resolveAvailableModel(models, reference, ctx.model?.provider);
188
188
  if (!model) {
189
189
  throw new Error(`Unknown delegate_task model: ${reference}. Available models: ${models.map((candidate) => modelReference(candidate)).join(", ") || "none"}.`);
190
190
  }
191
191
  const levels = taskThinkingLevels(ctx, model);
192
- if (thinking !== undefined) {
193
- if (!levels.includes(thinking)) {
194
- throw new Error(`delegate_task thinking ${thinking} is not usable for ${modelReference(model)} in this session. Usable levels here: ${levels.join(", ") || "none"}.`);
195
- }
196
- return { model, thinkingLevel: thinking };
197
- }
198
- if (!levels.length) {
199
- throw new Error(`${modelReference(model)} has no usable thinking level in this session; pick another model or adjust the scoped thinking pin.`);
192
+ if (!levels.includes(route.thinkingLevel)) {
193
+ throw new Error(`delegate_task model ${modelReference(model)} cannot use route thinking ${route.thinkingLevel} in this session. Usable levels here: ${levels.join(", ") || "none"}.`);
200
194
  }
201
- return { model, thinkingLevel: levels.includes("medium") ? "medium" : levels.at(-1)! };
195
+ return { model, thinkingLevel: route.thinkingLevel };
202
196
  }
203
197
 
204
198
  const BACKGROUND_RESULT_TYPE = "subagent-background-result";
@@ -538,7 +532,7 @@ export default function subagentExtension(
538
532
  promptGuidelines: [
539
533
  "Call delegate_task with exactly one mode: role+name+task for one task, tasks for 1–8 independent parallel tasks, or chain for 1–8 dependent sequential tasks using {previous} for the immediately preceding assistant output; split independent, commuting outcomes into parallel entries, sequence dependent work in chain entries, and never divide one invariant across multiple entries.",
540
534
  `${TASK_NAME_CONTRACT.promptGuidance} Every delegate_task entry must own one concrete outcome with one focused validation story: state its objective, exact scope and exclusions, relevant context and constraints, expected deliverable, and validation; if the affected flow or scope is not yet known, perform bounded read-only discovery first; never pass the parent request unchanged.`,
541
- "For each delegate_task entry, populate model and thinking only for an explicit user override; otherwise choose only modelClass: fast normally, or balanced upfront for obviously complex work. This is Main policy, not runtime enforcement.",
535
+ `For each delegate_task entry, ${MODEL_CLASS_GUIDANCE} A direct model replaces only the selected route's model; its thinking level stays unchanged.`,
542
536
  "Parallel delegate_task entries must own non-overlapping files. Keep integration and cross-cutting decisions in Main, and use the minimum number of Subagents needed.",
543
537
  "delegate_task background applies to the whole selected workflow and returns before results exist; use it only when the user explicitly asks for non-blocking work.",
544
538
  ],
@@ -577,14 +571,16 @@ export default function subagentExtension(
577
571
 
578
572
  // Resolve against the latest known session context after each FIFO permit.
579
573
  const launchCtx = () => latestCtx ?? ctx;
580
- const resolveLaunch = (role: Role, delegation: Delegation) => createRoleLaunch(pi, launchCtx(), {
581
- role,
582
- route: delegation.model !== undefined
583
- ? resolveDesignatedRoute(launchCtx(), delegation.model, delegation.thinking)
584
- : delegation.modelClass === undefined
585
- ? resolveConfiguredTaskRoute(launchCtx(), DELEGATE_TASK, undefined, delegation.thinking)
586
- : resolveTaskRoute(launchCtx(), delegation.modelClass, undefined, delegation.thinking),
587
- });
574
+ const resolveLaunch = (role: Role, delegation: Delegation) => {
575
+ const context = launchCtx();
576
+ const route = delegation.modelClass === undefined
577
+ ? resolveConfiguredTaskRoute(context, DELEGATE_TASK)
578
+ : resolveTaskRoute(context, delegation.modelClass);
579
+ return createRoleLaunch(pi, context, {
580
+ role,
581
+ route: delegation.model === undefined ? route : replaceRouteModel(context, delegation.model, route),
582
+ });
583
+ };
588
584
  const notifyMissingSkills = (role: Role, launch: ReturnType<typeof resolveLaunch>) => {
589
585
  if (launch.missingSkills.length) {
590
586
  ctx.ui.notify(
@@ -1,5 +1,5 @@
1
1
  import { StringEnum } from "@earendil-works/pi-ai";
2
- import { PROFILE_NAMES, THINKING_LEVELS } from "@henryqw/pi-task-models";
2
+ import { PROFILE_NAMES } from "@henryqw/pi-task-models";
3
3
  import { Type, type Static } from "typebox";
4
4
  import { Check } from "typebox/value";
5
5
  import { TaskNameSchema, normalizeTaskName } from "./task-name.ts";
@@ -8,9 +8,8 @@ export const MAX_WORKFLOW_ENTRIES = 8;
8
8
 
9
9
  const RoleSchema = Type.String({ minLength: 1, description: "Configured Subagent role name" });
10
10
  const TaskSchema = Type.String({ minLength: 1, description: "Bounded task packet" });
11
- const ModelSchema = Type.String({ minLength: 1, description: "Designated model as provider/modelId; overrides modelClass" });
11
+ const ModelSchema = Type.String({ minLength: 1, description: "Designated model as provider/modelId; replaces the selected route model" });
12
12
  const ModelClassSchema = StringEnum(PROFILE_NAMES, { description: "Task model profile" });
13
- const ThinkingSchema = StringEnum(THINKING_LEVELS, { description: "Task thinking-level override" });
14
13
 
15
14
  export const DelegationSchema = Type.Object({
16
15
  role: RoleSchema,
@@ -18,7 +17,6 @@ export const DelegationSchema = Type.Object({
18
17
  task: TaskSchema,
19
18
  model: Type.Optional(ModelSchema),
20
19
  modelClass: Type.Optional(ModelClassSchema),
21
- thinking: Type.Optional(ThinkingSchema),
22
20
  }, { additionalProperties: false });
23
21
 
24
22
  export const WorkflowSchema = Type.Object({
@@ -27,7 +25,6 @@ export const WorkflowSchema = Type.Object({
27
25
  task: Type.Optional(TaskSchema),
28
26
  model: Type.Optional(ModelSchema),
29
27
  modelClass: Type.Optional(ModelClassSchema),
30
- thinking: Type.Optional(ThinkingSchema),
31
28
  tasks: Type.Optional(Type.Array(DelegationSchema, {
32
29
  minItems: 1,
33
30
  maxItems: MAX_WORKFLOW_ENTRIES,
@@ -53,7 +50,7 @@ export type ParsedWorkflow =
53
50
 
54
51
  type WorkflowInput = Static<typeof WorkflowSchema>;
55
52
 
56
- const DELEGATION_KEYS = ["role", "name", "task", "model", "modelClass", "thinking"] as const;
53
+ const DELEGATION_KEYS = ["role", "name", "task", "model", "modelClass"] as const;
57
54
 
58
55
  function text(value: string, path: string): string {
59
56
  const normalized = value.trim();
@@ -68,7 +65,6 @@ function normalizeDelegation(value: Delegation, path: string): Delegation {
68
65
  task: text(value.task, `${path}.task`),
69
66
  ...(value.model === undefined ? {} : { model: text(value.model, `${path}.model`) }),
70
67
  ...(value.modelClass === undefined ? {} : { modelClass: value.modelClass }),
71
- ...(value.thinking === undefined ? {} : { thinking: value.thinking }),
72
68
  };
73
69
  }
74
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-subagent",
3
- "version": "10.1.0",
3
+ "version": "11.0.0",
4
4
  "description": "Delegate bounded single, parallel, or chained tasks to isolated Pi roles.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "repository": {
48
48
  "type": "git",
49
- "url": "git+https://github.com/HenryQW/pi-packages.git",
50
- "directory": "packages/pi-subagent"
49
+ "url": "git+https://github.com/HenryQW/pi-harness.git",
50
+ "directory": "extensions/pi-subagent"
51
51
  },
52
52
  "bugs": {
53
- "url": "https://github.com/HenryQW/pi-packages/issues"
53
+ "url": "https://github.com/HenryQW/pi-harness/issues"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -61,7 +61,8 @@
61
61
  ],
62
62
  "skills": [
63
63
  "./skills"
64
- ]
64
+ ],
65
+ "image": "https://raw.githubusercontent.com/HenryQW/pi-harness/main/extensions/pi-subagent/example.png"
65
66
  },
66
67
  "dependencies": {
67
68
  "@henryqw/pi-config-store": "^0.1.0",
@@ -13,7 +13,7 @@ Before slicing, identify applicable repository prohibitions. If the request or p
13
13
 
14
14
  Use the fewest cohesive units. `delegate_flow` is for independent units expected to commute: split independent outcomes into units, combine or sequence work that overlaps files, APIs, schemas, generated output, package metadata, lockfiles, or invariants, and never divide one invariant across multiple units. Dependent work remains outside Flow; sequence it in one task or ordinary caller-controlled sequencing.
15
15
 
16
- Give every unit a bounded objective, owned scope and exclusions, and its direct validation command/argument array; each delegation must own one concrete outcome with one focused validation story. If the affected flow or scope is not yet known, perform bounded read-only discovery first. Do not pass the parent request unchanged. Use `modelClass: "fast"` normally; use `"balanced"` upfront only for obviously complex work. Add non-empty `review` only for an explicit judgment that automated validation cannot establish. Call `delegate_flow` with 1–8 units; the runtime always supplies the effective Implementer and supplies the Reviewer only when a unit needs review.
16
+ Give every unit a bounded objective, owned scope and exclusions, and its direct validation command/argument array; each delegation must own one concrete outcome with one focused validation story. If the affected flow or scope is not yet known, perform bounded read-only discovery first. Do not pass the parent request unchanged. Choose `modelClass` according to the delegation tool's guidance. Add non-empty `review` only for an explicit judgment that automated validation cannot establish. Call `delegate_flow` with 1–8 units; the runtime always supplies the effective Implementer and supplies the Reviewer only when a unit needs review.
17
17
 
18
18
  ## Runtime Flow
19
19
 
@@ -31,4 +31,4 @@ Make the guidance specific to the reported implementation, validation, or review
31
31
 
32
32
  ## Ordinary delegation
33
33
 
34
- Use `delegate_task` for a single bounded task, independent parallel tasks, or dependent chain work that is not a Flow. Give each entry its objective, exact scope and exclusions, relevant context and constraints, expected deliverable, and focused validation. Populate direct `model` and `thinking` only when the user explicitly asks for those overrides; otherwise choose only `modelClass` (`fast` normally, `balanced` upfront for obviously complex work). Keep integration and cross-cutting decisions in Main, and use the minimum number of Subagents needed.
34
+ Use `delegate_task` for a single bounded task, independent parallel tasks, or dependent chain work that is not a Flow. Give each entry its objective, exact scope and exclusions, relevant context and constraints, expected deliverable, and focused validation. Choose `modelClass` according to the delegation tool's guidance. A direct `model` replaces only the selected route's model. The route keeps its thinking level. Keep integration and cross-cutting decisions in Main, and use the minimum number of Subagents needed.