pi-better-subagents 0.17.0 → 0.18.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/delegation.ts CHANGED
@@ -15,7 +15,7 @@ export function normalizeDelegationMode(value: unknown): DelegationMode {
15
15
  export function delegationPrompt(mode: DelegationMode): string {
16
16
  switch (mode) {
17
17
  case "manual":
18
- return "Delegation mode: manual. Do not proactively delegate work. Use subagents only when the user explicitly asks for delegation or an active workflow explicitly requires it. A structured plan or plan mode does not override this restriction; perform planned work in the foreground unless explicitly required otherwise.";
18
+ return "Delegation mode: manual. Do not proactively delegate work to subagents. Use subagents only when the user explicitly asks for delegation or an active workflow explicitly requires it. A structured plan or plan mode does not override this restriction. This restricts subagent delegation, not execution concurrency: independent foreground tools and background tasks still follow the Harness execution policy.";
19
19
  case "coordinator":
20
20
  return "Delegation mode: coordinator. The foreground coordinates, integrates, and verifies. Call agents_catalog to discover current available roles and inspect their descriptions. Pass a role to subagent_spawn by its short name, as listed (role: \"developer\"). Delegate every nontrivial task covered by an available role according to its current description; do not assume bundled roles are unchanged. Keep orchestration, cross-role decisions, unowned or ambiguous work, integration, and final verification in the foreground. Inspect results and failures before concluding; do not poll for running children.";
21
21
  case "adaptive":
package/index.ts CHANGED
@@ -54,6 +54,7 @@ import {
54
54
  } from "./timing.ts";
55
55
  import { readAppendedLines, type LogCursor } from "./log-cursor.ts";
56
56
  import { DELEGATION_MODES, DELEGATION_MODE_REQUEST, delegationPrompt, isDelegationMode, normalizeDelegationMode, type DelegationMode } from "./delegation.ts";
57
+ import { appendExecutionPolicy } from "./shared-execution-policy.ts";
57
58
  import { resolveExtensions, extensionArgs } from "./extensions.ts";
58
59
  import { prepareTaskRuntime } from "./task-policy.ts";
59
60
  import { canonicalizePath, takeRecoverySnapshot } from "./shared-sandbox-core.ts";
@@ -203,6 +204,7 @@ const CATALOG_GUIDELINES = [
203
204
  ];
204
205
 
205
206
  const SUBAGENT_ORCHESTRATION_GUIDELINES = [
207
+ "Follow the Harness execution policy for concurrency; the active delegation mode determines whether to use subagents, not whether independent background commands can overlap.",
206
208
  "When a structured plan is active, follow the current delegation mode. Track delegated and foreground deliverables only when delegation is permitted and actually underway; continue unblocked foreground work and integrate results before marking work complete.",
207
209
  "Do not treat launching a subagent as completion of the parent milestone; relevant terminal results must be inspected and integrated before verification or completion.",
208
210
  ];
@@ -2352,7 +2354,7 @@ export default function (pi: ExtensionAPI) {
2352
2354
  pi.registerTool(discoveryTool as Parameters<ExtensionAPI["registerTool"]>[0]);
2353
2355
 
2354
2356
  pi.on("before_agent_start", (event) => ({
2355
- systemPrompt: `${event.systemPrompt}\n\n${delegationPrompt(activeDelegationMode())}`,
2357
+ systemPrompt: `${appendExecutionPolicy(event.systemPrompt)}\n\n${delegationPrompt(activeDelegationMode())}`,
2356
2358
  }));
2357
2359
 
2358
2360
  // ---- live-status lifecycle -----------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-subagents",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Pi extension for detached, sandboxed subagent runs that keep the foreground session free.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,19 @@
1
+ // Generated from packages/pi-better-harness/extensions/execution-policy.ts. Do not edit directly.
2
+ /** Harness-wide scheduling guidance, vendored so standalone extensions share it. */
3
+ const EXECUTION_POLICY = [
4
+ "Harness execution policy: concurrency is separate from subagent delegation.",
5
+ "Before multi-unit work, identify ready, authorized, independent units, actual prerequisites, shared mutable resources, and capacity or availability constraints. Represent independently verifiable deliverables (such as each host migration) separately in the plan; do not hide them in one serial rollout step or create dependencies merely from list order.",
6
+ "Start all ready, authorized, non-conflicting units concurrently within known resource limits before waiting for any one to finish. Reassess ready work after launches and results; continue unblocked foreground work instead of polling running tasks. Do not equate one background launch with scheduling all ready work.",
7
+ "Serialize only for a concrete dependency, conflicting writes or ownership, resource or concurrency limit, documented rollout gate, or explicit availability requirement. Record the reason in the plan or explain it to the user. Do not invent a canary or host-by-host availability requirement.",
8
+ "If concurrency raises an unresolved material operational trade-off (for example, draining all hosts could leave no available runners), ask the user once before the affected operations. Continue independent preparation meanwhile. Existing authorization, safety checks, workflow prerequisites, and human-approved rollout constraints remain binding; urgency does not waive them.",
9
+ "Choose the execution mechanism after deciding what can run together: foreground tools for small, tightly coupled, or interactive work; subagents for bounded independent reasoning or implementation when the active delegation mode permits; background tasks for independent long-running commands or waits. Manual delegation forbids proactive subagents, not concurrent foreground tools or background commands. Use available batch or parallel tool interfaces where appropriate and inspect every launch receipt for failures or skipped work.",
10
+ "A unit waiting or failing does not block other ready independent units unless the evidence shows a shared blocker. Preserve each unit's guards and rollback boundary. Before completing verification, the plan, or the goal, inspect and integrate every relevant terminal result or failure; launch is not completion.",
11
+ ].join("\n");
12
+
13
+ export function appendExecutionPolicy(systemPrompt: string): string {
14
+ // Inspect the prompt, not module-global state: vendored copies have separate
15
+ // module identities, and every fresh turn or reload needs the policy again.
16
+ return systemPrompt.includes(EXECUTION_POLICY)
17
+ ? systemPrompt
18
+ : `${systemPrompt}\n\n${EXECUTION_POLICY}`;
19
+ }