@wichayutdew/pi-workflows 0.2.2 → 0.3.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 CHANGED
@@ -13,8 +13,9 @@ extensions, skills, dependency checks, and optional human-review gate.
13
13
 
14
14
  The harness owns state transitions. A step runs in the main Pi agent by default,
15
15
  or in a separate [pi-subagents](https://github.com/nicobailon/pi-subagents)
16
- child when it declares `subagent`. Either execution mode can advance only by
17
- calling `workflow_complete_step` with an outcome declared by that step.
16
+ child when it declares `subagent`. Main-agent steps advance through
17
+ `workflow_complete_step`; delegated steps return the same validated contract
18
+ through pi-subagents' correlated `structured_output`.
18
19
 
19
20
  ## Install
20
21
 
@@ -40,8 +41,8 @@ pi install npm:@plannotator/pi-extension
40
41
  ```
41
42
 
42
43
  Neither integration is required, but both are highly recommended together for
43
- the best isolation and review experience. Pi Workflows targets
44
- pi-subagents `0.35.1` or newer. Run `/subagents-doctor` if an explicitly
44
+ the best isolation and review experience. Delegated steps require
45
+ pi-subagents `0.36.0` or newer. Run `/subagents-doctor` if an explicitly
45
46
  delegated step cannot start.
46
47
 
47
48
  Pi loads `src/index.ts` through the package manifest. Restart Pi or run `/reload` after changing extension source.
@@ -142,15 +143,15 @@ Top-level fields:
142
143
 
143
144
  Each step supports:
144
145
 
145
- | Field | Required | Description |
146
- | ------------- | -------- | ----------------------------------------------------------------------- |
147
- | `title` | No | Human-readable name. Defaults to the step identifier. |
148
- | `prompt` | Yes | Inline text or `{ "file": "relative/path.md" }`. |
149
- | `subagent` | No | Opt into pi-subagents delegation and configure its profile and budgets. |
150
- | `permissions` | No | Resources callable during this step. Everything defaults to denied. |
151
- | `requires` | No | Dependencies that must be detectable before the step starts. |
152
- | `transitions` | Yes | Exact outcome to next step, `$pause`, or `$done`. |
153
- | `gate` | No | Built-in prompt or Plannotator human-review gate. |
146
+ | Field | Required | Description |
147
+ | ------------- | -------- | --------------------------------------------------------------------------------------- |
148
+ | `title` | No | Human-readable name. Defaults to the step identifier. |
149
+ | `prompt` | Yes | Inline text or `{ "file": "relative/path.md" }`. |
150
+ | `subagent` | No | Opt into isolated delegation and select the Pi Subagents profile and execution budgets. |
151
+ | `permissions` | No | Resources callable during this step. Everything defaults to denied. |
152
+ | `requires` | No | Dependencies that must be detectable before the step starts. |
153
+ | `transitions` | Yes | Exact outcome to next step, `$pause`, or `$done`. |
154
+ | `gate` | No | Built-in prompt or Plannotator human-review gate. |
154
155
 
155
156
  Supported prompt variables:
156
157
 
@@ -198,9 +199,13 @@ steps:
198
199
  ```
199
200
 
200
201
  The expanded defaults are `agent: pi-workflows.step`, `context: fresh`,
201
- `timeoutMs: 900000`, and `artifacts: false`.
202
+ `timeoutMs: 900000`, `artifacts: false`, and `retryToolFailures: false`. The
203
+ `agent` value is the actual Pi Subagents profile launched for that step.
204
+ `fresh` is the only supported workflow-step context: each child receives the
205
+ original workflow input and the previous step's compact handoff, never the
206
+ parent or a sibling transcript.
202
207
 
203
- Use a Pi Subagents runtime name directly when only the agent changes:
208
+ Use a profile name directly when only the child profile changes:
204
209
 
205
210
  ```yaml
206
211
  steps:
@@ -211,8 +216,11 @@ steps:
211
216
  done: $done
212
217
  ```
213
218
 
214
- This name-only form inherits the same defaults. Use the object form when the
215
- step also needs a context, model, timeout, budget, or artifact override:
219
+ This name-only form inherits the same execution defaults and launches the
220
+ configured Pi Subagents `scout` profile. Its system prompt and profile defaults
221
+ provide the specialty, while the workflow prompt supplies the exact step
222
+ contract. Use the object form when the step also needs a model, timeout, budget,
223
+ or artifact override:
216
224
 
217
225
  ```yaml
218
226
  subagent:
@@ -221,65 +229,62 @@ subagent:
221
229
  timeoutMs: 600000
222
230
  ```
223
231
 
224
- `agent` is the same runtime name Pi Subagents uses. For example,
225
- `subagent: worker` selects its builtin `worker`, then Pi Subagents applies the
226
- matching `subagents.agentOverrides.worker` entry from
227
- `~/.pi/agent/settings.json` and any higher-precedence project settings. Pi
228
- Workflows does not parse that file or reimplement agent discovery. An
229
- `agentOverrides` entry modifies a discovered builtin, package, user, or project
230
- agent; the entry alone does not create a new agent.
231
-
232
- This is separate from `~/.pi/agent/workflows/settings.yaml`, which configures
233
- Pi Workflows project trust and permission ceilings. Use
234
- `/subagents-models worker` to inspect Pi Subagents' live resolved profile and
235
- `/subagents-doctor` to diagnose discovery or loading problems.
236
-
237
- The bundled `pi-workflows.step` remains the default for `subagent: {}`. It
238
- inherits project instructions but not the parent transcript or its skill
239
- catalog. A named agent contributes its Pi Subagents system prompt, thinking,
240
- model unless the step overrides it, extension loading, and initial tool
241
- visibility. The workflow sends its configured step prompt and explicit skill
242
- selection.
232
+ Pi Workflows passes `subagent.agent` directly to Pi Subagents. Built-in profiles
233
+ such as `scout`, `planner`, `worker`, and `reviewer` therefore retain their own
234
+ system prompts, models, and specialty defaults. The bundled
235
+ `pi-workflows.step` profile remains the default general-purpose profile when
236
+ `agent` is omitted.
237
+
238
+ Every delegated request sets `context: fresh`, `output: false`, an
239
+ `outputSchema` for the workflow result, and `agentContract: { version: 1 }`.
240
+ Pi Subagents supplies `structured_output`, validates the schema, and emits the
241
+ single correlated terminal response. Pi Workflows' child policy independently
242
+ validates the declared outcome and compact handoff before the parent advances.
243
+ Request-level model, timeout, turn-budget, tool-budget, skills, and artifact
244
+ options are still forwarded. Use `/subagents-models <agent>` to inspect the
245
+ selected profile and `/subagents-doctor` to diagnose discovery or loading
246
+ problems. Workflow project trust and permission ceilings remain separately
247
+ configured in `~/.pi/agent/workflows/settings.yaml`.
243
248
 
244
249
  Supported fields:
245
250
 
246
- | Field | Default | Description |
247
- | ------------ | -------------------- | ----------------------------------------------------------------------------------- |
248
- | `agent` | `pi-workflows.step` | Any discovered Pi Subagents runtime name, such as `scout`, `worker`, or `reviewer`. |
249
- | `context` | `fresh` | `fresh` isolates the step; `fork` deliberately includes filtered parent context. |
250
- | `model` | Agent/default model | Optional pi-subagents model override. |
251
- | `timeoutMs` | `900000` | Child deadline, from 1 second through 24 hours. |
252
- | `turnBudget` | pi-subagents default | `{ "maxTurns": n, "graceTurns": n }`. |
253
- | `toolBudget` | pi-subagents default | `{ "soft": n, "hard": n, "block": "*" }`; `block` may instead be a tool-name array. |
254
- | `artifacts` | `false` | Ask pi-subagents to retain its normal run artifacts. |
255
-
256
- Builtin names are unqualified (`worker`); packaged names may be qualified, such
257
- as `pi-workflows.step`. Pi Workflows installs an inert listener in every
258
- Pi Subagents child. It registers `workflow_complete_step` and activates policy
259
- only after a valid, single-use workflow capability arrives, so ordinary
260
- subagent runs remain unchanged.
261
-
262
- A selected profile's active tools and loaded extensions remain an outer
263
- boundary. Effective step tools are the intersection of that profile and
264
- `permissions`, plus the workflow completion tool. Pi Workflows can remove
265
- access but cannot grant a normal tool or load an extension excluded by the
266
- profile. If a custom profile declares `extensions`, it must keep the installed
267
- Pi Workflows extension available; otherwise the child never receives the
268
- policy runtime and the step fails closed.
251
+ | Field | Default | Description |
252
+ | ------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
253
+ | `agent` | `pi-workflows.step` | Actual Pi Subagents profile, such as `scout`, `planner`, `worker`, or `reviewer`. |
254
+ | `context` | `fresh` | Always isolated; parent and sibling transcripts are never inherited. |
255
+ | `model` | Profile/default model | Optional pi-subagents model override for the selected profile. |
256
+ | `timeoutMs` | `900000` | Child deadline, from 1 second through 24 hours. |
257
+ | `turnBudget` | pi-subagents default | `{ "maxTurns": n, "graceTurns": n }`. |
258
+ | `toolBudget` | pi-subagents default | `{ "soft": n, "hard": n, "block": "*" }`; `block` may instead be a tool-name array. |
259
+ | `artifacts` | `false` | Ask pi-subagents to retain its normal run artifacts. |
260
+ | `retryToolFailures` | `false` | Authorize one fresh reinforcement retry in allow-list or unrestricted Bash mode; runtime still requires a wholly replay-safe attempt without `edit` or `write`. |
261
+
262
+ Pi Workflows installs an inert listener in every Pi Subagents child and
263
+ activates policy only after a valid, single-use workflow capability arrives, so
264
+ ordinary subagent runs remain unchanged. Delegated completion uses the
265
+ `structured_output` tool provided by Pi Subagents; `workflow_complete_step`
266
+ remains the completion tool only for main-agent steps.
267
+
268
+ After capability verification, Pi Workflows resolves the step permissions
269
+ against every tool registered in the child and activates only that exact set,
270
+ plus the upstream structured completion tool. The selected profile's ordinary
271
+ active-tool allow-list is not a second workflow policy. Profile extension
272
+ loading still controls which extension providers exist in the child; a workflow
273
+ cannot activate a tool whose provider was not loaded.
269
274
 
270
275
  Workflow `permissions.skills` is sent as Pi Subagents' request-level skill
271
276
  selection, so it replaces the selected profile's normal skill list for that
272
- step; an empty list disables injected skills. Pi Workflows also disables Pi
273
- Subagents' separate acceptance report for these requests because the harness
274
- already owns correlated completion, declared outcomes, and optional human
275
- review gates.
277
+ step; an empty list disables injected skills. `output: false` prevents a
278
+ profile-default output file, while omitting acceptance under agent contract v1
279
+ avoids a second acceptance gate. The schema, harness, declared outcomes, and
280
+ optional human review gate own correlated completion.
276
281
 
277
282
  At runtime:
278
283
 
279
284
  1. The harness creates a correlated child policy and result channel.
280
- 2. pi-subagents starts one foreground child for the current step.
281
- 3. The child runtime enforces permissions and writes the validated result.
282
- 4. The parent harness applies the configured transition, then launches the next step.
285
+ 2. pi-subagents starts one foreground child using the step's configured agent profile.
286
+ 3. The child runtime activates the workflow-permitted registered tools and validates `structured_output`.
287
+ 4. The parent waits for the correlated terminal response, applies the transition, and launches the next fresh-context step.
283
288
 
284
289
  Main-agent mode uses the same per-step tool, MCP, Bash, extension-tool, and
285
290
  completion enforcement, but it cannot unload globally visible skills or
@@ -301,9 +306,9 @@ mcp:
301
306
 
302
307
  The harness requires an explicit `server` and `tool` on every proxy call. Proxy search, discovery, connection, and authentication modes are blocked while a workflow step is running.
303
308
 
304
- The generic `mcp` proxy is the portable choice for workflow steps. A custom
305
- subagent profile may expose direct MCP tools through its own `mcp:` frontmatter;
306
- Pi Workflows still requires each direct runtime name in `tools`.
309
+ The generic `mcp` proxy is the portable choice for workflow steps. The bundled
310
+ runtime may also expose direct MCP tools through Pi Subagents settings; Pi
311
+ Workflows still requires each direct runtime name in `tools`.
307
312
 
308
313
  `extensions` contains case-insensitive fragments matched against tool source metadata. Tools registered by matching extensions become visible and callable:
309
314
 
@@ -424,17 +429,33 @@ For example, suppose the approved artifact contains:
424
429
  {
425
430
  "repositories": [
426
431
  {
427
- "worker": [{ "command": "bun test" }]
432
+ "cwd": "/absolute/path/to/repository",
433
+ "sourceCwd": "/absolute/path/to/source",
434
+ "worker": [
435
+ {
436
+ "command": "bun --cwd /absolute/path/to/repository test"
437
+ }
438
+ ]
428
439
  }
429
440
  ]
430
441
  }
431
442
  ```
432
443
 
433
- A later step with `approvedSources: [verification-worker]` may run exactly
434
- `bun test`. It may not run `bun test --watch`, because that is a different
435
- string. `verification-reviewer` reads the sibling `reviewer` list instead.
436
- `remote-actions` reads only Bash actions from `actions[]` and additionally
437
- filters them to supported hosted-API mutations or non-force pushes.
444
+ A later step with `approvedSources: [verification-worker]` may run only the
445
+ exact reviewed command. Cwd-dependent commands must encode that entry's
446
+ absolute `repositories[].cwd`, such as `bun --cwd /reviewed/root test`; they
447
+ may not substitute another directory or add `--watch`.
448
+ `verification-reviewer` reads the sibling `reviewer` list with the same rule.
449
+ `remote-actions` reads only Bash actions from
450
+ `actions[]` and additionally filters them to supported hosted-API mutations or
451
+ non-force pushes.
452
+
453
+ A delegated step accepts one distinct reviewed repository directory; repeated
454
+ entries may name that same absolute `cwd`. Missing, relative, or ambiguous
455
+ multiple directories fail closed before the child starts. A not-yet-created
456
+ worktree may bootstrap only from the same contract's one existing absolute
457
+ `sourceCwd`; file mutations remain confined to the reviewed target `cwd`, and
458
+ all setup and later Bash commands must still match the approved strings.
438
459
 
439
460
  The complete path is:
440
461
 
@@ -516,14 +537,33 @@ transitions:
516
537
  ```
517
538
 
518
539
  Setting `provider: plannotator` is the entire opt-in; the harness preflights the
519
- installed extension automatically. The active step calls
520
- `workflow_complete_step` with outcome `submit` and the full content in
521
- `artifact`. The harness correlates the Plannotator review identifier and
522
- accepts only the matching decision. On approval, that reviewed artifact—not
540
+ installed extension automatically. A main-agent planning step calls
541
+ `workflow_complete_step`; a delegated planning child calls
542
+ `structured_output`. In either case it uses outcome `submit` and places the full
543
+ content in `artifact`. The harness correlates the Plannotator review identifier
544
+ and accepts only the matching decision. On approval, that reviewed artifact—not
523
545
  the step's separate summary—becomes the authoritative handoff to the next step.
524
546
 
525
547
  If review finishes while the workflow is paused, the result is checkpointed and applied only after `/workflow-resume`. Resume also queries Plannotator’s durable review status, so a decision made while Pi was closed is not lost.
526
548
 
549
+ ### Planning is the decision boundary
550
+
551
+ For a delegated plan workflow, put every unresolved choice in the plan artifact
552
+ with evidence, options, a recommendation, and an adopted default. The built-in
553
+ review panel or Plannotator is where the user resolves those choices. Approval
554
+ makes that reviewed artifact the final implementation contract and compact
555
+ handoff.
556
+
557
+ Post-approval implementation and verification children are non-interactive:
558
+ they do not ask questions in the terminal or detach for supervisor input. If an
559
+ approved contract is missing, stale, or contradictory, the child pauses with a
560
+ declarative evidence summary instead of starting a replacement or opening a
561
+ side channel.
562
+
563
+ In print or JSON mode, a pending built-in plan review remains safely paused.
564
+ Reopen the same session in TUI or RPC mode and run `/workflow-resume` to show
565
+ the preserved review instead of restarting the planning child.
566
+
527
567
  ## Pause, repair, resume
528
568
 
529
569
  Use:
@@ -550,6 +590,43 @@ blocked. Wait for the terminal event; if the delegation channel has already
550
590
  failed, restart Pi before resuming. This prevents an old writer and a resumed
551
591
  writer from overlapping.
552
592
 
593
+ When a delegated child returns `failed` or `structured_output_failed` with a
594
+ terminal error or nonzero exit code, the harness audits the retained Pi child
595
+ session before deciding whether to launch one fresh reinforcement retry. The
596
+ audit accepts only regular, non-symlink session files contained by the current
597
+ parent session's child-run root, requires the persisted policy-stripped task and
598
+ its per-request binding to match the active delegation, reads a bounded complete
599
+ tail, and proves that every recorded call was read-only or rejected by that
600
+ step's actual Bash policy before execution. Approved exact Bash commands are
601
+ evaluated with the same authorization inputs used by the child. A zero-tool
602
+ attempt is also replay-safe when the complete bound transcript proves it.
603
+
604
+ When the terminal error identifies a failed tool, the harness also records the
605
+ exact correlated call, tool error, subagent exit code, terminal error, and
606
+ validated diagnostic session path. If exact correlation is unavailable, the
607
+ generic terminal evidence is retained without claiming an unrelated command.
608
+ A failed process status is treated as resolved when the transcript proves a
609
+ successful `structured_output` occurred after every failed tool result and the
610
+ correlated result validates. This accepts the same finalized child result; it
611
+ never replays mutation-capable work.
612
+
613
+ Without a valid finalized result, the next fresh child receives the bounded
614
+ terminal evidence in an escaped JSON data boundary and is told to inspect
615
+ current state, change its approach, resolve the cause, and finish the original
616
+ step. A second failure pauses. Mutation-capable or unknown-effect calls, a
617
+ truncated or malformed transcript, a missing active-request binding,
618
+ cancellation, interruption, timeout, and budget exhaustion do not trigger an
619
+ automatic retry. Local channel failures also wait for confirmed child
620
+ termination instead of risking two live children.
621
+
622
+ Inside a live child, recovery is not tied to a list of known error strings. The
623
+ completion contract requires the agent to inspect the exact error and current
624
+ state, try a permitted semantically equivalent alternative, and continue the
625
+ original step. It may pause only after safe alternatives are exhausted, with
626
+ the failed call, error, attempted alternatives, and remaining blocker in its
627
+ handoff. A fresh retry is explicitly a continuation: it inspects state first
628
+ and must not repeat a side effect that is already present.
629
+
553
630
  While paused, fix repository code, workflow YAML, prompts, MCP configuration,
554
631
  an extension, or any other environmental problem. Then run:
555
632
 
@@ -561,7 +638,8 @@ Resume reloads configuration before continuing:
561
638
 
562
639
  - The paused step restarts in its configured main-agent or delegated mode.
563
640
  - A changed current step restarts that step.
564
- - A changed completed step restarts the earliest changed completed step.
641
+ - A changed ordinary completed step restarts the earliest changed completed step.
642
+ - A completed human-approved gate keeps its persisted reviewed artifact authoritative; later prompt or configuration digest changes do not reopen that plan while the gate and approved outcome still match.
565
643
  - Future-only changes preserve the current checkpoint.
566
644
  - Removing the current or a completed step fails closed and requires restoring configuration or aborting.
567
645
  - Restoring a Pi session automatically pauses an in-progress workflow for inspection.
@@ -570,22 +648,40 @@ Resume reloads configuration before continuing:
570
648
 
571
649
  ## Commands
572
650
 
573
- In TUI mode, `/workflow-status` opens a read-only board for the current
574
- checkpoint. It refreshes once per second and shows run timing, the current
575
- execution or review, pause reasons, configuration drift, and the completed
576
- attempt path. Press `q`, `Esc`, `Ctrl-C`, or `Ctrl-D` to close it. Non-TUI modes
577
- receive the same checkpoint as text.
578
-
579
- | Command | Purpose |
580
- | ------------------------------- | ----------------------------------------------------- |
581
- | `/workflow-list` | List loaded workflows and their configured commands. |
582
- | `/workflow-start <id> [input]` | Start by workflow identifier. |
583
- | `/<configured-command> [input]` | Start through a workflow alias. |
584
- | `/workflow-status` | Open a live run-status board (text outside TUI mode). |
585
- | `/workflow-pause [reason]` | Halt without losing the checkpoint. |
586
- | `/workflow-resume` | Reload, reconcile, and continue. |
587
- | `/workflow-abort [reason]` | End the active run and restore baseline tools. |
588
- | `/workflow-reload` | Reload definitions while no workflow is running. |
651
+ The full status overlay opens when a workflow starts and is toggled with
652
+ `Ctrl+Alt+W` by default (`q` or `Esc` also hides it). Set `statusShortcut` in
653
+ `settings.yaml` to another Pi key identifier, then run Pi's `/reload` to
654
+ re-register it; `/workflow-reload` cannot change extension shortcuts. The
655
+ overlay shows run timing, execution or review, pause reasons, configuration
656
+ drift, and the completed attempt path without a task-viewer pane below the
657
+ editor. The main surface shows only one small animated `◐`/`◓`/`◑`/`◒` working
658
+ indicator while a workflow runs, then clears it when execution stops. All step,
659
+ progress, history, failure, and review detail stays in the overlay. There, `✓`
660
+ marks a completed step, `✕` a failed or aborted run, and `◆` a paused step or
661
+ pending review. Long reasons are clamped to the available display width; the
662
+ durable checkpoint retains the full text. On short terminals, use `↑`/`↓`,
663
+ PgUp/PgDn, or Home/End to scroll the overlay.
664
+
665
+ | Command | Purpose |
666
+ | ------------------------------- | ---------------------------------------------------- |
667
+ | `/workflow-list` | List loaded workflows and their configured commands. |
668
+ | `/workflow-start <id> [input]` | Start by workflow identifier. |
669
+ | `/<configured-command> [input]` | Start through a workflow alias. |
670
+ | `/workflow-pause [reason]` | Halt without losing the checkpoint. |
671
+ | `/workflow-resume` | Reload, reconcile, and continue. |
672
+ | `/workflow-abort [reason]` | End the active run and restore baseline tools. |
673
+ | `/workflow-reload` | Reload definitions while no workflow is running. |
674
+
675
+ Configured aliases also accept multiline input. For example, if `work` is a
676
+ loaded workflow command, Pi Workflows normalizes:
677
+
678
+ ```text
679
+ /work
680
+ """inspect and update this repository"""
681
+ ```
682
+
683
+ to the same command with an argument instead of letting the raw multiline text
684
+ start an unrelated parent-agent turn.
589
685
 
590
686
  ## User and project configuration
591
687
 
@@ -603,6 +699,7 @@ Project workflows are disabled by default. Enable them in the user-owned
603
699
  # yaml-language-server: $schema=/absolute/path/to/pi-workflows/schemas/settings.schema.json
604
700
  version: 1
605
701
  allowProjectWorkflows: true
702
+ statusShortcut: ctrl+alt+w
606
703
  permissionCeiling:
607
704
  tools: [read, grep, bash]
608
705
  mcp: []
@@ -610,7 +707,7 @@ permissionCeiling:
610
707
  skills: []
611
708
  bash: { mode: read-only }
612
709
  subagent:
613
- agents: [pi-workflows.step, scout, worker, reviewer]
710
+ agents: [scout, planner, worker, reviewer]
614
711
  contexts: [fresh]
615
712
  models: []
616
713
  maxTimeoutMs: 900000
@@ -618,6 +715,7 @@ permissionCeiling:
618
715
  maxGraceTurns: 3
619
716
  maxToolCalls: 100
620
717
  artifacts: false
718
+ retryToolFailures: false
621
719
  ```
622
720
 
623
721
  Settings use the same strict YAML 1.2 parser as workflow definitions. The
@@ -630,8 +728,8 @@ within this ceiling. The `subagent` ceiling is optional for main-only project
630
728
  workflows; if omitted, any project step that declares `subagent` is rejected.
631
729
  Each delegated project step must declare `turnBudget` and `toolBudget` with
632
730
  `"block": "*"`, so it cannot silently inherit unbounded child defaults or keep
633
- mutation tools after reaching the hard limit. The ceiling also controls child
634
- agent names, context inheritance, model overrides, timeouts, artifact
731
+ mutation tools after reaching the hard limit. The ceiling also controls
732
+ agent profile names, fresh-context use, model overrides, timeouts, artifact
635
733
  retention, and the Bash rules and approved sources that a project workflow may
636
734
  request. Project workflows cannot override user workflow identifiers or
637
735
  commands.
@@ -655,7 +753,7 @@ The package keeps the Pi entry point intentionally small:
655
753
  | `src/runtime/` | Shared completion parsing and main-agent step runtime. |
656
754
  | `src/preflight.ts` | Required tool, extension, and skill checks. |
657
755
  | `src/prompt.ts` | Template rendering and step contract. |
658
- | `agents/step.md` | Bundled dynamic-policy pi-subagents profile. |
756
+ | `agents/step.md` | Default general-purpose profile plus workflow child guidance. |
659
757
 
660
758
  The engine and policy modules do not depend on Pi runtime types, so they are fast to test.
661
759
 
@@ -671,7 +769,7 @@ process separation when a step opts into pi-subagents:
671
769
  - completion as the sole call in its tool batch;
672
770
  - optional separate pi-subagents child process per delegated step;
673
771
  - an idle, tool-isolated main agent while a delegated step runs;
674
- - a single-use, parent-created child capability tied to the selected workflow agent;
772
+ - a single-use, parent-created child capability tied to the delegated step;
675
773
  - explicit MCP server and tool checks;
676
774
  - restricted Bash parsing;
677
775
  - exact Bash capabilities derived from a correlated human-reviewed artifact;
@@ -708,8 +806,11 @@ ceilings, deterministic transitions, configuration reconciliation, pause/resume
708
806
  state, gate handling, MCP isolation, Bash policy, extension tool selection,
709
807
  main-agent completion, built-in feedback/approval, subagent request correlation
710
808
  and cancellation, child policy enforcement, and dependency preflight,
711
- including reviewed exact-command propagation and fail-closed legacy
712
- checkpoints.
809
+ including reinforcement retry after replay-safe terminal errors and nonzero
810
+ exits, reviewed exact-command propagation, and fail-closed legacy checkpoints.
811
+ `bun run check` also launches real Pi RPC subprocesses, invokes
812
+ `/work`, and verifies fresh `scout`, `worker`, and `reviewer` children receive
813
+ only the explicit compact handoff from the immediately preceding step.
713
814
 
714
815
  ## Publishing checklist
715
816
 
@@ -728,7 +829,7 @@ extensions, without hard-coding them into the orchestrator, are:
728
829
 
729
830
  | Parameter | Why it belongs in configuration |
730
831
  | --------------------------------- | ------------------------------------------------------------------------------------------- |
731
- | Retry and backoff | Let a step distinguish a transient child failure from a workflow-level pause. |
832
+ | Configurable retry and backoff | Extend the single safe reinforcement retry with per-step transient-failure policy. |
732
833
  | Acceptance criteria | Give each step machine-checkable completion evidence and verification commands. |
733
834
  | Working directory or worktree | Isolate mutating steps, monorepo packages, and concurrent branches. |
734
835
  | Parallel groups and join policy | Run independent steps together and declare fail-fast, quorum, or all-success behavior. |
@@ -742,11 +843,11 @@ extensions, without hard-coding them into the orchestrator, are:
742
843
 
743
844
  - A delegated workflow step uses one foreground subagent. Parallel or chained children inside one step are not yet a workflow-level primitive.
744
845
  - Gate providers are built-in prompt and Plannotator; custom providers are not yet configurable.
745
- - A custom subagent profile can be narrower than a step, but Pi Workflows cannot widen that profile.
846
+ - Delegated steps require pi-subagents 0.36.0 or newer and launch the actual profile selected by `subagent.agent`.
746
847
  - Extension tools are enforced; autonomous extension event-handler side effects cannot be disabled per step.
747
848
  - Completion evidence is model-reported; use reviewed executable checks and a fresh verification step when correctness matters.
748
849
  - Workflow configuration uses YAML. Prompt bodies may live in separate Markdown files.
749
850
 
750
851
  ## License
751
852
 
752
- Licensed under the [Apache License 2.0](./LICENSE).
853
+ Licensed under the [MIT License](./LICENSE).
package/agents/step.md CHANGED
@@ -14,4 +14,18 @@ Execute the supplied workflow step exactly as instructed.
14
14
  The Pi Workflows child runtime selects and enforces the step's tools, MCP
15
15
  selectors, Bash policy, extension tools, skills, outcomes, and completion
16
16
  contract. Do not broaden those permissions. If the step or environment is
17
- invalid, return an outcome that pauses the workflow.
17
+ invalid, use a configured pause outcome when one exists. Otherwise, end with a
18
+ concise declarative error without calling the completion tool so the parent
19
+ harness pauses the step.
20
+
21
+ Each step is an isolated, non-interactive child using its configured Pi
22
+ Subagents profile and workflow prompt. Complete delegated work through
23
+ pi-subagents' `structured_output`; `workflow_complete_step` belongs to
24
+ main-agent workflow steps. Never call `contact_supervisor`,
25
+ `subagent_supervisor`, or `intercom`. Gated planning puts unresolved decisions
26
+ in its review artifact with evidence, options, and an adopted default. Other
27
+ steps treat their instructions and incoming handoff as final; if that contract
28
+ is missing, stale, or contradictory, use a configured pause outcome and
29
+ describe the problem declaratively in the compact summary. When no pause
30
+ outcome exists, end with the declarative error instead. Never ask a terminal
31
+ question.