pi-subagent-manager 1.6.1 → 1.7.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/docs/settings.md +1 -1
- package/package.json +1 -1
- package/src/orch/runtime.ts +21 -43
- package/src/prefs/import-instructions.ts +3 -2
- package/src/ui/model-picker.ts +1 -1
- package/src/ui/settings-ui.ts +2 -2
package/docs/settings.md
CHANGED
|
@@ -189,7 +189,7 @@ Which model an agent gets when its session starts.
|
|
|
189
189
|
|
|
190
190
|
- Types with no `models` inherit the parent's model in both Pick First modes.
|
|
191
191
|
- Your list's order decides, not the scoped list's order.
|
|
192
|
-
- No match → spawn fails clearly. An empty `/scoped-models`
|
|
192
|
+
- No match → spawn fails clearly. An empty `/scoped-models` means unrestricted: all available models are eligible.
|
|
193
193
|
- `use-current` always uses the **main** session's model, even for nested or reopened agents. Thinking levels stay per-agent.
|
|
194
194
|
- `modelSuggestions` never affects this.
|
|
195
195
|
- Switching modes doesn't change already-open sessions.
|
package/package.json
CHANGED
package/src/orch/runtime.ts
CHANGED
|
@@ -36,12 +36,7 @@ import type {
|
|
|
36
36
|
SubagentExtensionSelection,
|
|
37
37
|
ToolFilteringMode,
|
|
38
38
|
} from "../prefs/settings.ts";
|
|
39
|
-
import {
|
|
40
|
-
modelIdentity,
|
|
41
|
-
getModelPreferences,
|
|
42
|
-
selectPreferredModel,
|
|
43
|
-
ModelPreferenceError,
|
|
44
|
-
} from "../prefs/models.ts";
|
|
39
|
+
import { modelIdentity, getModelPreferences, selectPreferredModel } from "../prefs/models.ts";
|
|
45
40
|
import {
|
|
46
41
|
THINKING_LEVELS,
|
|
47
42
|
type AgentType,
|
|
@@ -219,27 +214,18 @@ export function createDriverFactory(
|
|
|
219
214
|
const available = new Set(availableModelCandidates().map(({ model }) => modelIdentity(model)));
|
|
220
215
|
return scopedModels.filter(({ model }) => available.has(modelIdentity(model)));
|
|
221
216
|
};
|
|
217
|
+
// Pi represents an unrestricted scope with an empty array.
|
|
222
218
|
const selectTypeModelPreference = (
|
|
223
219
|
type: AgentType,
|
|
224
|
-
|
|
220
|
+
scopedModels: readonly ScopedModel[],
|
|
225
221
|
filtering: boolean,
|
|
226
222
|
) => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
error instanceof Error &&
|
|
234
|
-
!error.message.includes("[]")
|
|
235
|
-
) {
|
|
236
|
-
const message = `${error.message} Current /scoped-models scope: [].`;
|
|
237
|
-
throw error instanceof ModelPreferenceError
|
|
238
|
-
? new ModelPreferenceError(message, error.scopedModelFiltering)
|
|
239
|
-
: new Error(message);
|
|
240
|
-
}
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
223
|
+
const restricted = filtering && scopedModels.length > 0;
|
|
224
|
+
return selectPreferredModel(
|
|
225
|
+
type,
|
|
226
|
+
restricted ? availableScopedModels(scopedModels) : availableModelCandidates(),
|
|
227
|
+
restricted,
|
|
228
|
+
);
|
|
243
229
|
};
|
|
244
230
|
// Discovery and new/restored drivers share model selection and thinking inheritance.
|
|
245
231
|
const resolveInitialSettings = (
|
|
@@ -260,11 +246,8 @@ export function createDriverFactory(
|
|
|
260
246
|
id = ctx.model?.id;
|
|
261
247
|
} else if (preferences !== undefined) {
|
|
262
248
|
const filtering = mode === "pick-first-scoped";
|
|
263
|
-
const candidates = filtering
|
|
264
|
-
? availableScopedModels(normalizeScopedModels(ctx.scopedModels))
|
|
265
|
-
: availableModelCandidates();
|
|
266
249
|
({ provider, id } = parseModelIdentity(
|
|
267
|
-
selectTypeModelPreference(type,
|
|
250
|
+
selectTypeModelPreference(type, normalizeScopedModels(ctx.scopedModels), filtering)!,
|
|
268
251
|
));
|
|
269
252
|
} else if (restored?.model) {
|
|
270
253
|
provider = restored.model.provider;
|
|
@@ -372,9 +355,9 @@ export function createDriverFactory(
|
|
|
372
355
|
modelSelection === "use-current" ? undefined : getModelPreferences(options.type);
|
|
373
356
|
const filteringEnabled = () => getModelSelection() === "pick-first-scoped";
|
|
374
357
|
const selectModelPreference = (
|
|
375
|
-
|
|
358
|
+
scopedModels: readonly ScopedModel[],
|
|
376
359
|
filtering = filteringEnabled(),
|
|
377
|
-
) => selectTypeModelPreference(options.type,
|
|
360
|
+
) => selectTypeModelPreference(options.type, scopedModels, filtering);
|
|
378
361
|
const initialScopedModels = normalizeScopedModels(ctx.scopedModels);
|
|
379
362
|
const { provider, id, thinkingLevel } = resolveInitialSettings(
|
|
380
363
|
options.type,
|
|
@@ -721,10 +704,7 @@ export function createDriverFactory(
|
|
|
721
704
|
liveScopedModels: readonly ScopedModel[],
|
|
722
705
|
) => {
|
|
723
706
|
if (!filteringEnabled() || modelPreferences === undefined) return;
|
|
724
|
-
const preferredIdentity = selectModelPreference(
|
|
725
|
-
availableScopedModels(liveScopedModels),
|
|
726
|
-
true,
|
|
727
|
-
);
|
|
707
|
+
const preferredIdentity = selectModelPreference(liveScopedModels, true);
|
|
728
708
|
if (!preferredIdentity) return;
|
|
729
709
|
if (!currentIdentity) throw new Error(`Subagent ${options.path} has no selected model`);
|
|
730
710
|
if (currentIdentity !== preferredIdentity) {
|
|
@@ -751,10 +731,7 @@ export function createDriverFactory(
|
|
|
751
731
|
updateResolved();
|
|
752
732
|
return;
|
|
753
733
|
}
|
|
754
|
-
const preferredIdentity = selectModelPreference(
|
|
755
|
-
availableScopedModels(liveScopedModels),
|
|
756
|
-
true,
|
|
757
|
-
);
|
|
734
|
+
const preferredIdentity = selectModelPreference(liveScopedModels, true);
|
|
758
735
|
if (!preferredIdentity) {
|
|
759
736
|
updateResolved();
|
|
760
737
|
return;
|
|
@@ -862,7 +839,9 @@ export function createDriverFactory(
|
|
|
862
839
|
let disposed = false;
|
|
863
840
|
let running = false;
|
|
864
841
|
let aborted = false;
|
|
865
|
-
|
|
842
|
+
// Compaction can replace session.messages during a prompt, invalidating any saved index.
|
|
843
|
+
const promptResult: { lastAssistant?: AssistantMessage } = {};
|
|
844
|
+
const getLastAssistant = () => promptResult.lastAssistant;
|
|
866
845
|
// Subscribe after inherited/restored history is loaded; only new assistant events are counted.
|
|
867
846
|
let settledInput = 0;
|
|
868
847
|
let settledOutput = 0;
|
|
@@ -907,6 +886,8 @@ export function createDriverFactory(
|
|
|
907
886
|
);
|
|
908
887
|
const unsubscribe = session.subscribe((event) => {
|
|
909
888
|
transcript.accept(event);
|
|
889
|
+
if (running && event.type === "message_end" && event.message.role === "assistant")
|
|
890
|
+
promptResult.lastAssistant = event.message;
|
|
910
891
|
if (event.type === "tool_execution_start")
|
|
911
892
|
emit("activity", `Tool: ${event.toolName}`, toolArgumentSnippet(event.args));
|
|
912
893
|
if (event.type === "tool_execution_end")
|
|
@@ -967,17 +948,14 @@ export function createDriverFactory(
|
|
|
967
948
|
if (running) throw new Error("Subagent is already running; use steer instead");
|
|
968
949
|
running = true;
|
|
969
950
|
aborted = false;
|
|
970
|
-
|
|
951
|
+
promptResult.lastAssistant = undefined;
|
|
971
952
|
finalOutput = "";
|
|
972
953
|
try {
|
|
973
954
|
await enforceScopedModelPolicy();
|
|
974
955
|
await resumePending();
|
|
975
956
|
await session.prompt(message, { expandPromptTemplates: false });
|
|
976
957
|
await session.waitForIdle();
|
|
977
|
-
const last =
|
|
978
|
-
.slice(baseline)
|
|
979
|
-
.filter((msg) => msg.role === "assistant")
|
|
980
|
-
.at(-1);
|
|
958
|
+
const last = getLastAssistant();
|
|
981
959
|
if (aborted || last?.stopReason === "aborted") throw new Error("Subagent run aborted");
|
|
982
960
|
if (last?.stopReason === "error")
|
|
983
961
|
throw new Error(last.errorMessage || "Subagent model failed");
|
|
@@ -23,8 +23,9 @@ edit. Only these frontmatter keys are accepted:
|
|
|
23
23
|
- name: required safe ID matching /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.
|
|
24
24
|
- description: required nonempty routing description (what work this agent is for).
|
|
25
25
|
- models: optional NONEMPTY ordered YAML array of exact provider/model-id identities.
|
|
26
|
-
First preference
|
|
27
|
-
|
|
26
|
+
First available preference in the CURRENT /scoped-models list wins. An empty scope is
|
|
27
|
+
unrestricted, so any available model is eligible. Matching is verbatim, not fuzzy.
|
|
28
|
+
None matching fails; there is no provider fallback.
|
|
28
29
|
Models with API pi-virtual cannot run as target children, even if scoped. Check the supplied
|
|
29
30
|
model API metadata; never pin a virtual model or inherit a pi-virtual parent. Ask for approval
|
|
30
31
|
to choose a physical scoped model instead, otherwise skip the definition. Do not silently
|
package/src/ui/model-picker.ts
CHANGED
|
@@ -431,7 +431,7 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
431
431
|
|
|
432
432
|
private withScopeWarning(text: string): string {
|
|
433
433
|
if (this.scopedIdentities.size === 0) {
|
|
434
|
-
return `No
|
|
434
|
+
return `No scope restriction: Pick First (scoped) uses all available models. ${text}`;
|
|
435
435
|
}
|
|
436
436
|
return text;
|
|
437
437
|
}
|
package/src/ui/settings-ui.ts
CHANGED
|
@@ -408,7 +408,7 @@ const MODEL_SELECTION_OPTIONS = [
|
|
|
408
408
|
id: "pick-first-scoped",
|
|
409
409
|
label: "Pick First (scoped)",
|
|
410
410
|
value: "First available preference in the session scope",
|
|
411
|
-
help: "Pick First (scoped):\nPick the first available model in the agent's models list that is also selected in the current session's /scoped-models.\nSkip unavailable models and providers without credentials.",
|
|
411
|
+
help: "Pick First (scoped):\nPick the first available model in the agent's models list that is also selected in the current session's /scoped-models. An empty scope allows all available models.\nSkip unavailable models and providers without credentials.",
|
|
412
412
|
},
|
|
413
413
|
{
|
|
414
414
|
id: "use-current",
|
|
@@ -419,7 +419,7 @@ const MODEL_SELECTION_OPTIONS = [
|
|
|
419
419
|
] as const;
|
|
420
420
|
|
|
421
421
|
const MODEL_SELECTION_HELP =
|
|
422
|
-
"Pick First (available): first preference with an enabled, authenticated provider in Pi.\nPick First (scoped): same, limited to the current session's /scoped-models.\nUse Current: ignore models and use the main session's current model; keep the agent's thinking level.\nOnly the models list affects runtime picking; modelSuggestions are search hints.\nSave and apply to affect agents when their sessions start.";
|
|
422
|
+
"Pick First (available): first preference with an enabled, authenticated provider in Pi.\nPick First (scoped): same, limited to the current session's /scoped-models when non-empty.\nUse Current: ignore models and use the main session's current model; keep the agent's thinking level.\nOnly the models list affects runtime picking; modelSuggestions are search hints.\nSave and apply to affect agents when their sessions start.";
|
|
423
423
|
|
|
424
424
|
export async function configureAgents(
|
|
425
425
|
ctx: ExtensionCommandContext,
|