oira666_pi-subagent 0.2.0 → 0.2.1
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/index.ts +27 -17
- package/package.json +1 -1
- package/shared.ts +1 -1
package/index.ts
CHANGED
|
@@ -21,7 +21,12 @@ import { type AgentConfig, discoverAgents } from "./agents.js";
|
|
|
21
21
|
import { renderCall, renderResult } from "./render.js";
|
|
22
22
|
import { runAgentSubprocess, executeParallelSubprocess } from "./runner.js";
|
|
23
23
|
import { runAgentSameProcess, executeParallelSameProcess } from "./runner-sdk.js";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
DEFAULT_MAX_PARALLEL_TASKS,
|
|
26
|
+
SUBAGENT_MAX_PARALLEL_TASKS_ENV,
|
|
27
|
+
parseNonNegativeInt,
|
|
28
|
+
subagentContext,
|
|
29
|
+
} from "./shared.js";
|
|
25
30
|
|
|
26
31
|
import {
|
|
27
32
|
type DelegationMode,
|
|
@@ -409,6 +414,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
409
414
|
const { currentDepth, maxDepth, canDelegate, ancestorAgentStack, preventCycles } =
|
|
410
415
|
depthConfig;
|
|
411
416
|
const subagentMode = getSubagentMode();
|
|
417
|
+
const maxParallelTasks =
|
|
418
|
+
parseNonNegativeInt(process.env[SUBAGENT_MAX_PARALLEL_TASKS_ENV]) ??
|
|
419
|
+
DEFAULT_MAX_PARALLEL_TASKS;
|
|
412
420
|
|
|
413
421
|
let discoveredAgents: AgentConfig[] = [];
|
|
414
422
|
const approvedProjectAgentDirsForSession = new Set<string>();
|
|
@@ -456,26 +464,25 @@ ${agentList}
|
|
|
456
464
|
|
|
457
465
|
Each subagent runs in an **isolated process**.
|
|
458
466
|
|
|
459
|
-
|
|
460
|
-
-
|
|
461
|
-
-
|
|
467
|
+
Pass a \`tasks\` array. **Every task in the same call runs in parallel.**
|
|
468
|
+
- 1 task -> single delegation
|
|
469
|
+
- N tasks -> all N run concurrently in one call
|
|
470
|
+
|
|
471
|
+
For **sequential** work (task B needs task A's output), make separate tool
|
|
472
|
+
calls one after another. Do NOT put dependent tasks in the same array.
|
|
462
473
|
|
|
463
|
-
**Single
|
|
474
|
+
**Single (1 agent)**:
|
|
464
475
|
\`\`\`json
|
|
465
476
|
{ "tasks": [{ "agent": "agent-name", "task": "Detailed task..." }] }
|
|
466
477
|
\`\`\`
|
|
467
478
|
|
|
468
|
-
**
|
|
479
|
+
**Parallel (N agents at once)**:
|
|
469
480
|
\`\`\`json
|
|
470
|
-
{ "tasks": [{ "agent": "agent-
|
|
481
|
+
{ "tasks": [{ "agent": "agent-a", "task": "..." }, { "agent": "agent-b", "task": "..." }] }
|
|
471
482
|
\`\`\`
|
|
472
483
|
|
|
473
|
-
### Runtime delegation guards
|
|
474
|
-
|
|
475
484
|
- Max depth: current depth ${currentDepth}, max depth ${maxDepth}
|
|
476
|
-
-
|
|
477
|
-
- Current delegation stack: ${ancestorAgentStack.length > 0 ? ancestorAgentStack.join(" -> ") : "(root)"}
|
|
478
|
-
- Execution mode: ${subagentMode === "sdk" ? "in-process SDK" : "subprocess"}
|
|
485
|
+
- Max subagents per tool call: ${maxParallelTasks}
|
|
479
486
|
`,
|
|
480
487
|
};
|
|
481
488
|
} catch (err) {
|
|
@@ -493,12 +500,15 @@ The tool always accepts a \`tasks\` array:
|
|
|
493
500
|
subagentMode === "sdk" ? "in-process SDK sessions" : "isolated pi processes"
|
|
494
501
|
}.`,
|
|
495
502
|
"",
|
|
496
|
-
"
|
|
497
|
-
" -
|
|
498
|
-
" -
|
|
503
|
+
"Pass a `tasks` array. Every task in the same call runs IN PARALLEL.",
|
|
504
|
+
" - 1 task -> single delegation",
|
|
505
|
+
" - N tasks -> all N run concurrently in one call",
|
|
506
|
+
"",
|
|
507
|
+
"For sequential work (task B depends on task A's output), make separate",
|
|
508
|
+
"tool calls one after another. Do NOT put dependent tasks in the same array.",
|
|
499
509
|
"",
|
|
500
|
-
'
|
|
501
|
-
'
|
|
510
|
+
'Single: { tasks: [{ agent: "writer", task: "Rewrite README.md" }] }',
|
|
511
|
+
'Parallel: { tasks: [{ agent: "writer", task: "..." }, { agent: "tester", task: "..." }] }',
|
|
502
512
|
].join("\n"),
|
|
503
513
|
parameters: SubagentParams,
|
|
504
514
|
|
package/package.json
CHANGED
package/shared.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const subagentContext = new AsyncLocalStorage<SubagentSessionContext>();
|
|
|
31
31
|
// Parallel execution limits
|
|
32
32
|
// ---------------------------------------------------------------------------
|
|
33
33
|
|
|
34
|
-
export const DEFAULT_MAX_PARALLEL_TASKS =
|
|
34
|
+
export const DEFAULT_MAX_PARALLEL_TASKS = 30;
|
|
35
35
|
export const DEFAULT_MAX_CONCURRENCY = 8;
|
|
36
36
|
export const PARALLEL_HEARTBEAT_MS = 1000;
|
|
37
37
|
export const SUBAGENT_MAX_PARALLEL_TASKS_ENV = "PI_SUBAGENT_MAX_PARALLEL_TASKS";
|