@henryqw/pi-subagent 2.3.5 → 2.4.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 +3 -1
- package/extensions/subagent.ts +28 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,9 @@ pi install npm:@henryqw/pi-subagent
|
|
|
21
21
|
|
|
22
22
|
| Surface | Type | Purpose |
|
|
23
23
|
| --- | --- | --- |
|
|
24
|
-
| `delegate_task` | tool | Start one isolated child for `role`, `task`, and optional `modelClass`. |
|
|
24
|
+
| `delegate_task` | tool | Start one isolated child for `role`, `task`, and optional `model` or `modelClass`. |
|
|
25
|
+
|
|
26
|
+
An explicit `model` (`provider/modelId`) overrides `modelClass` and resolves against the currently available text models; an unknown reference rejects with the list of available models. Thinking level defaults to `medium` when supported, otherwise the highest supported level.
|
|
25
27
|
|
|
26
28
|
`modelClass` is `fast`, `balanced`, or `frontier`. Omitted class uses the shared `pi-subagent/delegateTask` assignment, which defaults to `balanced`. Primary route is resolved against current scoped text models; fallback is tried only before launch. If no route is usable, delegation rejects with `Run /task-models`. A started child is never retried.
|
|
27
29
|
|
package/extensions/subagent.ts
CHANGED
|
@@ -4,7 +4,15 @@ import { basename } from "node:path";
|
|
|
4
4
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
5
5
|
import { type ExtensionAPI, type ExtensionContext, type Theme } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { type Component, truncateToWidth, type TUI, visibleWidth } from "@earendil-works/pi-tui";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
availableTaskModels,
|
|
9
|
+
modelReference,
|
|
10
|
+
PROFILE_NAMES,
|
|
11
|
+
type ProfileName,
|
|
12
|
+
resolveAvailableModel,
|
|
13
|
+
type ResolvedTaskRoute,
|
|
14
|
+
taskThinkingLevels,
|
|
15
|
+
} from "@henryqw/pi-task-models";
|
|
8
16
|
import { Type } from "typebox";
|
|
9
17
|
import { createRoleLaunch, isProfileName, loadRoles, resolveRoleLaunch, resolveTaskRoute } from "@henryqw/pi-subagent";
|
|
10
18
|
|
|
@@ -415,11 +423,24 @@ const Parameters = Type.Object({
|
|
|
415
423
|
task: Type.String({
|
|
416
424
|
description: "Bounded task packet: objective; exact scope and exclusions; relevant context and constraints; expected deliverable; validation. Never the whole parent request.",
|
|
417
425
|
}),
|
|
426
|
+
model: Type.Optional(Type.String({
|
|
427
|
+
description: "Designated model as provider/modelId; overrides modelClass. Unknown references reject with the list of available models.",
|
|
428
|
+
})),
|
|
418
429
|
modelClass: Type.Optional(StringEnum(MODEL_CLASSES, {
|
|
419
430
|
description: "Classify task complexity: fast for narrow lookups or mechanical edits; balanced for normal bounded work; frontier for ambiguous, cross-cutting, or high-risk reasoning. Defaults to the shared pi-subagent/delegateTask assignment.",
|
|
420
431
|
})),
|
|
421
432
|
});
|
|
422
433
|
|
|
434
|
+
function resolveDesignatedRoute(ctx: ExtensionContext, reference: string): ResolvedTaskRoute {
|
|
435
|
+
const models = availableTaskModels(ctx);
|
|
436
|
+
const model = resolveAvailableModel(models, reference, ctx.model?.provider);
|
|
437
|
+
if (!model) {
|
|
438
|
+
throw new Error(`Unknown delegate_task model: ${reference}. Available models: ${models.map((candidate) => modelReference(candidate)).join(", ") || "none"}.`);
|
|
439
|
+
}
|
|
440
|
+
const levels = taskThinkingLevels(ctx, model);
|
|
441
|
+
return { model, thinkingLevel: levels.includes("medium") ? "medium" : levels.at(-1)! };
|
|
442
|
+
}
|
|
443
|
+
|
|
423
444
|
const roleSummary = (): string => {
|
|
424
445
|
try {
|
|
425
446
|
const roles = loadRoles();
|
|
@@ -553,7 +574,7 @@ export default function subagentExtension(
|
|
|
553
574
|
pi.registerTool({
|
|
554
575
|
name: "delegate_task",
|
|
555
576
|
label: "Subagent",
|
|
556
|
-
description: `Delegate one bounded, independently executable task to one isolated Pi Subagent. Roles: ${roleSummary()}. Choose fast for narrow work, balanced for normal work, or frontier for ambiguous and high-risk work; omit modelClass to use shared task-model settings.`,
|
|
577
|
+
description: `Delegate one bounded, independently executable task to one isolated Pi Subagent. Roles: ${roleSummary()}. Choose fast for narrow work, balanced for normal work, or frontier for ambiguous and high-risk work; omit modelClass to use shared task-model settings. When the user designates a specific model, pass it as provider/modelId in model.`,
|
|
557
578
|
promptSnippet: "Delegate one bounded, independently executable task to an isolated role",
|
|
558
579
|
promptGuidelines: [
|
|
559
580
|
"Before calling delegate_task, split broad work into the smallest independent bounded tasks; keep integration and cross-cutting decisions in Main.",
|
|
@@ -573,9 +594,11 @@ export default function subagentExtension(
|
|
|
573
594
|
if (params.modelClass !== undefined && !isModelClass(params.modelClass)) {
|
|
574
595
|
throw new Error("delegate_task modelClass must be fast, balanced, or frontier.");
|
|
575
596
|
}
|
|
576
|
-
const launch = params.
|
|
577
|
-
?
|
|
578
|
-
:
|
|
597
|
+
const launch = params.model !== undefined
|
|
598
|
+
? createRoleLaunch(pi, ctx, { role, route: resolveDesignatedRoute(ctx, cleanText(params.model, "model", "delegate_task")) })
|
|
599
|
+
: params.modelClass === undefined
|
|
600
|
+
? resolveRoleLaunch(pi, ctx, { role, taskId: SUBAGENT_TASK })
|
|
601
|
+
: createRoleLaunch(pi, ctx, { role, route: resolveTaskRoute(ctx, params.modelClass) });
|
|
579
602
|
const modelReferenceValue = modelReference(launch.model);
|
|
580
603
|
const thinkingLevel = launch.thinkingLevel;
|
|
581
604
|
if (launch.missingSkills.length) {
|