@ferris1225/pi-subagents 4.3.33 → 4.3.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +11 -3
- package/package.json +1 -1
- package/skills/workflow/SKILL.md +8 -4
- package/src/lifecycle/thread-lifecycle.ts +10 -1
- package/src/workflow/engine.ts +35 -0
- package/src/workflow/tool.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
Release notes for `@ferris1225/pi-subagents`. Only the most recent releases
|
|
4
4
|
are kept here; every published version is preserved as a GitHub Release.
|
|
5
5
|
|
|
6
|
+
## 4.3.34
|
|
7
|
+
|
|
8
|
+
- Reject a workflow that would reuse a phase this session already owns, before
|
|
9
|
+
any node starts, and name each owning run with the way out. A settled phase
|
|
10
|
+
stays owned once it settles, and an interrupted one keeps its claim across
|
|
11
|
+
reloads, so "re-run it in a new session" was wrong: the graph previously failed
|
|
12
|
+
its first node and blocked the rest.
|
|
13
|
+
- Say the same thing for a per-run duplicate: a parked owner is told to retire
|
|
14
|
+
the phase with `subagent_stop({ id })` instead of being told to let it finish.
|
|
15
|
+
|
|
6
16
|
## 4.3.33
|
|
7
17
|
|
|
8
18
|
- Add `subagent_workflow`: declare a graph of phases with `dependsOn` and the
|
package/README.md
CHANGED
|
@@ -13,6 +13,12 @@ self-contained — parallel phases usually beat a serialized main.
|
|
|
13
13
|
|
|
14
14
|
## What's new
|
|
15
15
|
|
|
16
|
+
**4.3.34** — a workflow that would reuse a phase this session already owns (a
|
|
17
|
+
settled run, or an interrupted one retained from an earlier session) is now
|
|
18
|
+
rejected before any node starts, naming each owning run and the way out; the
|
|
19
|
+
per-run duplicate message says the same for a parked owner instead of asking you
|
|
20
|
+
to "let it finish".
|
|
21
|
+
|
|
16
22
|
**4.3.33** — dependency graphs for multi-phase work. `subagent_workflow` declares
|
|
17
23
|
nodes with `dependsOn`, validates the graph before any child starts, dispatches
|
|
18
24
|
each node as its prerequisites settle, and reports the whole graph once. Saved
|
|
@@ -268,9 +274,11 @@ object or a bare node array. The package also ships a `workflow` skill
|
|
|
268
274
|
(`skills/workflow/SKILL.md`) with the authoring guidance: when a graph is worth
|
|
269
275
|
its cost, how to slice phases, how to write briefs, and the anti-patterns.
|
|
270
276
|
|
|
271
|
-
Derived phase ids are `<workflow-slug>.<node-id>`, and a
|
|
272
|
-
|
|
273
|
-
|
|
277
|
+
Derived phase ids are `<workflow-slug>.<node-id>`, and a phase stays owned after it
|
|
278
|
+
settles and across reloads — an interrupted run keeps its claim until it is retired.
|
|
279
|
+
A graph that reuses one is rejected before any node starts, naming each owning run;
|
|
280
|
+
retire the owner with `subagent_stop({ id })`, or give those nodes different ids or
|
|
281
|
+
`phaseId`s, or run the graph under a different name.
|
|
274
282
|
|
|
275
283
|
`subagent_status({ workflow: id })` reports nodes and their wait reasons;
|
|
276
284
|
`subagent_stop({ workflow: id })` stops a graph without starting its idle
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ferris1225/pi-subagents",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.34",
|
|
4
4
|
"description": "A managed sub-agent team for pi: lightweight scout research and artisan implementation, one-shot runs, read-only status, and Git worktree isolation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/skills/workflow/SKILL.md
CHANGED
|
@@ -172,10 +172,14 @@ Save a graph when it will run again, when a reviewer should read the plan before
|
|
|
172
172
|
it runs, or when the phases are long enough that you want them in version
|
|
173
173
|
control. Run it by name; do not restate it inline.
|
|
174
174
|
|
|
175
|
-
**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
**A phase stays owned after it settles, and across reloads.** Derived phase ids
|
|
176
|
+
are `<workflow-slug>.<node-id>`; an interrupted run keeps its claim until it is
|
|
177
|
+
retired. Re-running the same shape is therefore rejected **before any node
|
|
178
|
+
starts**, naming the owning runs. Three ways forward: retire the owner with
|
|
179
|
+
`subagent_stop({ id })` (destructive — it drops that run's retained session),
|
|
180
|
+
give the reused nodes different ids or `phaseId`s, or run the graph under a
|
|
181
|
+
different name. A new session alone does not help: a retained interrupted run is
|
|
182
|
+
restored with its claim intact.
|
|
179
183
|
|
|
180
184
|
## 9. Cost
|
|
181
185
|
|
|
@@ -125,8 +125,17 @@ export function createBackgroundDispatcher(options: BackgroundDispatcherOptions)
|
|
|
125
125
|
}
|
|
126
126
|
const duplicate = findDuplicateDispatch(runtime.threads.values(), task, originalCwd, phaseId);
|
|
127
127
|
if (duplicate) {
|
|
128
|
+
// A phase stays owned across reloads: an interrupted run keeps its claim
|
|
129
|
+
// until it is retired, so "let it finish" is wrong advice for a parked
|
|
130
|
+
// owner and leaves the caller with no way forward.
|
|
131
|
+
const owner = duplicate.source;
|
|
132
|
+
const remedy = owner.state === "parked" || owner.retired
|
|
133
|
+
? `That run was interrupted (possibly in an earlier session) and keeps the phase claimed; retire it with subagent_stop({ id: ${owner.id} }) to reuse the phase, or give this work a different phaseId. Main handles follow-up work.`
|
|
134
|
+
: owner.state === "completed" || owner.state === "failed"
|
|
135
|
+
? "Inspect it with subagent_status; a different deliverable needs a different phaseId. Main handles follow-up work."
|
|
136
|
+
: "Do not redispatch it; inspect its result or let it finish. Main handles follow-up work.";
|
|
128
137
|
return failedStartResult(agentName, task,
|
|
129
|
-
`Run #${
|
|
138
|
+
`Run #${owner.id} (${owner.agentName}) already owns this logical phase (${owner.state}). ${remedy}`);
|
|
130
139
|
}
|
|
131
140
|
if (writeCapable && scope) {
|
|
132
141
|
const conflict = findWriterLeaseScopeOverlap(scope, runtime.threads.values());
|
package/src/workflow/engine.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { formatDuration, formatTaskSummary, monitor } from "../presentation/moni
|
|
|
20
20
|
import { perModelTotals, type CompletionMessageItem } from "../lifecycle/completion.ts";
|
|
21
21
|
import type { SubagentRuntime } from "../lifecycle/runtime.ts";
|
|
22
22
|
import type { StartBackgroundInternal } from "../lifecycle/thread-shared.ts";
|
|
23
|
+
import { findDuplicateDispatch } from "../delegation/prompt.ts";
|
|
23
24
|
import { defaultPhaseId, renderNodeTask, type CompiledWorkflow, type UpstreamOutput } from "./plan.ts";
|
|
24
25
|
import {
|
|
25
26
|
readWorkflowRecords,
|
|
@@ -394,6 +395,40 @@ async function settle(ctx: RunContext): Promise<void> {
|
|
|
394
395
|
runtime.sendCompletionGroup([item]);
|
|
395
396
|
}
|
|
396
397
|
|
|
398
|
+
/** A phase a live or retained thread already owns. */
|
|
399
|
+
export interface OwnedPhase {
|
|
400
|
+
nodeId: string;
|
|
401
|
+
phaseId: string;
|
|
402
|
+
runId: number;
|
|
403
|
+
agent: string;
|
|
404
|
+
state: string;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Phases this session already owns, checked before the graph starts.
|
|
409
|
+
*
|
|
410
|
+
* A phase is owned by the parent session, not by one graph: an interrupted or
|
|
411
|
+
* settled owner keeps its claim until it is retired. Checking every node up
|
|
412
|
+
* front turns "the first node failed and the rest never ran" into one message
|
|
413
|
+
* that names the owners and the way out, at the cost of no child process.
|
|
414
|
+
*/
|
|
415
|
+
export function findOwnedPhases(runtime: SubagentRuntime, workflow: CompiledWorkflow): OwnedPhase[] {
|
|
416
|
+
const owned: OwnedPhase[] = [];
|
|
417
|
+
for (const node of workflow.nodes) {
|
|
418
|
+
const phaseId = node.phaseId ?? defaultPhaseId(workflow, node);
|
|
419
|
+
const duplicate = findDuplicateDispatch(runtime.threads.values(), node.task, node.cwd, phaseId);
|
|
420
|
+
if (!duplicate) continue;
|
|
421
|
+
owned.push({
|
|
422
|
+
nodeId: node.id,
|
|
423
|
+
phaseId,
|
|
424
|
+
runId: duplicate.source.id,
|
|
425
|
+
agent: duplicate.source.agentName,
|
|
426
|
+
state: duplicate.source.lifecycleOperation === "settle" ? "settling" : duplicate.source.state,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
return owned;
|
|
430
|
+
}
|
|
431
|
+
|
|
397
432
|
/** Start a compiled graph. Nodes dispatch as their prerequisites settle. */
|
|
398
433
|
export function startWorkflow(deps: WorkflowRunDeps, workflow: CompiledWorkflow): WorkflowHandle {
|
|
399
434
|
const runtime = deps.runtime;
|
package/src/workflow/tool.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { projectResultsRoot } from "../lifecycle/thread-shared.ts";
|
|
|
20
20
|
import { formatTaskSummary, monitor } from "../presentation/monitor.ts";
|
|
21
21
|
import { pruneWorkflowRecords } from "./durable.ts";
|
|
22
22
|
import {
|
|
23
|
+
findOwnedPhases,
|
|
23
24
|
persistInterruptedWorkflows,
|
|
24
25
|
readRetainedWorkflows,
|
|
25
26
|
startWorkflow,
|
|
@@ -199,6 +200,22 @@ export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
199
200
|
);
|
|
200
201
|
}
|
|
201
202
|
|
|
203
|
+
// Re-using a phase another owner holds fails the first node and blocks the
|
|
204
|
+
// rest; reject the whole graph instead, with the owners named.
|
|
205
|
+
const owned = findOwnedPhases(runtime, workflow);
|
|
206
|
+
if (owned.length > 0) {
|
|
207
|
+
const lines = owned.map((owner) =>
|
|
208
|
+
"- node \"" + owner.nodeId + "\" → phase \"" + owner.phaseId + "\" is already owned by run #" + owner.runId +
|
|
209
|
+
" (" + owner.agent + ", " + owner.state + ")",
|
|
210
|
+
);
|
|
211
|
+
throw new Error(
|
|
212
|
+
"Workflow \"" + workflow.name + "\" was not started: " + owned.length + " of " + workflow.nodes.length +
|
|
213
|
+
" node" + (owned.length === 1 ? " reuses" : "s reuse") + " a phase this session already owns.\n" +
|
|
214
|
+
lines.join("\n") +
|
|
215
|
+
"\nRetire the owner with subagent_stop({ id: <run id> }) (destructive: it drops that run's retained session), give those nodes different ids or phaseIds, or run the graph under a different name. No nodes were started.",
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
202
219
|
const handle = startWorkflow(
|
|
203
220
|
{
|
|
204
221
|
runtime,
|