@osolmaz/pi-workflows 0.13.3 → 0.14.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 +136 -118
- package/dist/builtins/autoimplement.workflow.d.ts +12 -12
- package/dist/builtins/autoplan.workflow.d.ts +3 -3
- package/dist/builtins/autoplan.workflow.js +44 -35
- package/dist/builtins/autoplan.workflow.js.map +1 -1
- package/dist/builtins/catalog.js +1 -1
- package/dist/builtins/plan-change.workflow.d.ts +6 -6
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/sqlite.d.ts +34 -31
- package/dist/controllers/sqlite.js +116 -77
- package/dist/controllers/sqlite.js.map +1 -1
- package/dist/extension/index.js +721 -202
- package/dist/extension/index.js.map +1 -1
- package/dist/extension/restart-policy.d.ts +38 -0
- package/dist/extension/restart-policy.js +116 -0
- package/dist/extension/restart-policy.js.map +1 -0
- package/dist/extension/terminal-decision.d.ts +51 -0
- package/dist/extension/terminal-decision.js +110 -0
- package/dist/extension/terminal-decision.js.map +1 -0
- package/dist/state/prune.js +36 -10
- package/dist/state/prune.js.map +1 -1
- package/dist/workflows/tool-input.d.ts +4 -0
- package/dist/workflows/tool-input.js +6 -1
- package/dist/workflows/tool-input.js.map +1 -1
- package/docs/2026-08-25-workflow-follow-ups.md +8 -6
- package/docs/DEFERRED_TURNS.md +39 -26
- package/docs/HUMAN_DECISIONS.md +12 -4
- package/docs/SQLITE_STATE.md +24 -0
- package/docs/WORKFLOW_COMPOSITION.md +1 -1
- package/docs/plans/2026-08-19-human-decision-gates-plan.md +34 -8
- package/docs/plans/2026-08-27-workflow-terminal-restart-plan.md +357 -0
- package/docs/workflows.md +85 -29
- package/herdr-plugin.toml +1 -1
- package/package.json +1 -1
- package/skills/autodoc/SKILL.md +1 -1
- package/skills/autoimplement/SKILL.md +1 -1
- package/skills/autoplan/SKILL.md +6 -6
- package/skills/pi-workflows/SKILL.md +2 -0
- package/src/builtins/autoplan.workflow.ts +45 -37
- package/src/builtins/catalog.ts +1 -1
- package/src/controllers/index.ts +3 -0
- package/src/controllers/sqlite.ts +226 -155
- package/src/extension/index.ts +881 -220
- package/src/extension/restart-policy.ts +163 -0
- package/src/extension/terminal-decision.ts +172 -0
- package/src/state/prune.ts +35 -9
- package/src/workflows/tool-input.ts +9 -1
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Workflow terminal decision and restart plan
|
|
3
|
+
author: Onur Solmaz <2453968+osolmaz@users.noreply.github.com>
|
|
4
|
+
date: 2026-08-27
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Full plan
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
After every top-level workflow run ends, give the model one normal successor turn.
|
|
12
|
+
|
|
13
|
+
That turn contains the workflow result and terminal reason. The model uses the conversation it already has to decide whether to:
|
|
14
|
+
|
|
15
|
+
- stop because the user’s task is complete
|
|
16
|
+
- restart the same workflow as a new run
|
|
17
|
+
- start Monitor for an authorized external wait
|
|
18
|
+
- ask the user for a required decision or authority
|
|
19
|
+
- take another safe authorized action
|
|
20
|
+
|
|
21
|
+
The system does not save or identify the original user message. It does not restart automatically. It gives the model one clear decision opportunity and makes safe retry the default for unfinished work after technical failures.
|
|
22
|
+
|
|
23
|
+
## Shared terminal behavior
|
|
24
|
+
|
|
25
|
+
The shared terminal message must include:
|
|
26
|
+
|
|
27
|
+
- workflow name and revision
|
|
28
|
+
- terminal run ID
|
|
29
|
+
- exact workflow input
|
|
30
|
+
- workflow result
|
|
31
|
+
- terminal state
|
|
32
|
+
- terminal reason
|
|
33
|
+
- restart count
|
|
34
|
+
- earlier terminal outcomes in the same restart chain
|
|
35
|
+
|
|
36
|
+
The message must tell the model:
|
|
37
|
+
|
|
38
|
+
> A workflow run ended, but that does not prove the user’s task is complete. Use the current conversation and this result to decide what to do next. If the task is unfinished because of an unexpected technical or temporary failure, prefer a safe restart. Stop if the work is complete, the user cancelled it, new authority is required, the user must make a decision, or the same failure has repeated. Use Monitor only for an authorized external wait.
|
|
39
|
+
|
|
40
|
+
Use the term **result**, not “durable result.”
|
|
41
|
+
|
|
42
|
+
## Implementation steps
|
|
43
|
+
|
|
44
|
+
### 1. Build one shared terminal-decision message
|
|
45
|
+
|
|
46
|
+
**Where**
|
|
47
|
+
|
|
48
|
+
- `src/extension/deferred-turn.ts`
|
|
49
|
+
- Add `src/extension/terminal-decision.ts` if a separate pure module keeps the code smaller.
|
|
50
|
+
|
|
51
|
+
**Change**
|
|
52
|
+
|
|
53
|
+
Add a pure builder that reads the existing run record and produces the shared terminal facts and prompt.
|
|
54
|
+
|
|
55
|
+
It must not read, copy, hash, or store an original user message.
|
|
56
|
+
|
|
57
|
+
Use the existing stored workflow input and result. Apply the existing output-size rules to large results, but always include the run ID, state, reason, and restart history.
|
|
58
|
+
|
|
59
|
+
**Verification**
|
|
60
|
+
|
|
61
|
+
Unit tests must cover completed, failed, timed-out, maxSteps, cancelled, and blocked results.
|
|
62
|
+
|
|
63
|
+
### 2. Create one terminal turn for every top-level run
|
|
64
|
+
|
|
65
|
+
**Where**
|
|
66
|
+
|
|
67
|
+
- `finishRun` in `src/extension/index.ts`
|
|
68
|
+
- `src/extension/deferred-turn-coordinator.ts`
|
|
69
|
+
- Existing turn-intent state in `src/controllers/sqlite.ts`
|
|
70
|
+
|
|
71
|
+
**Change**
|
|
72
|
+
|
|
73
|
+
Create one terminal turn intent when a top-level interactive run reaches a terminal state.
|
|
74
|
+
|
|
75
|
+
Normal presentation and fallback delivery must compete for the same intent. The first successful delivery settles it. Every later delivery attempt becomes a no-op.
|
|
76
|
+
|
|
77
|
+
Do not create this turn for:
|
|
78
|
+
|
|
79
|
+
- waiting checkpoints
|
|
80
|
+
- controller child runs
|
|
81
|
+
- internal helper runs that already report to an owner
|
|
82
|
+
|
|
83
|
+
**Verification**
|
|
84
|
+
|
|
85
|
+
Race tests must prove that presentation, fallback, reload recovery, and crash recovery produce one model turn, not two.
|
|
86
|
+
|
|
87
|
+
### 3. Replace the current terminal presentation instruction
|
|
88
|
+
|
|
89
|
+
**Where**
|
|
90
|
+
|
|
91
|
+
- `buildPresentationMessage`
|
|
92
|
+
- `buildDeferredTurnContent`
|
|
93
|
+
- Related presentation helpers in `src/extension/index.ts`
|
|
94
|
+
|
|
95
|
+
**Change**
|
|
96
|
+
|
|
97
|
+
Remove the current instruction that says the model must not call the workflow tool.
|
|
98
|
+
|
|
99
|
+
Replace it with the shared decision instructions. The terminal turn must permit one workflow launch selected by the model.
|
|
100
|
+
|
|
101
|
+
Completed runs still get a result turn. A workflow state of `completed` does not always mean the larger user task is complete. For example, the result can say that work is blocked.
|
|
102
|
+
|
|
103
|
+
Explicit human cancellation must default to stopping.
|
|
104
|
+
|
|
105
|
+
**Verification**
|
|
106
|
+
|
|
107
|
+
Tests must prove that the model can select restart or Monitor during the terminal turn and that ordinary completed work does not cause an automatic restart.
|
|
108
|
+
|
|
109
|
+
### 4. Add a generic restart action
|
|
110
|
+
|
|
111
|
+
**Where**
|
|
112
|
+
|
|
113
|
+
- `src/workflows/tool-input.ts`
|
|
114
|
+
- Workflow tool registration, schema, help text, and control switch under `src/workflows/`
|
|
115
|
+
- Restart handling in `src/extension/index.ts`
|
|
116
|
+
|
|
117
|
+
**Contract**
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"action": "restart",
|
|
122
|
+
"runId": "terminal-run-id"
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Change**
|
|
127
|
+
|
|
128
|
+
The action must:
|
|
129
|
+
|
|
130
|
+
1. Read the terminal run.
|
|
131
|
+
2. Confirm that it belongs to the current session.
|
|
132
|
+
3. Confirm that it is terminal.
|
|
133
|
+
4. Reuse the exact workflow reference, input, and safe launch settings.
|
|
134
|
+
5. Create a new immutable run.
|
|
135
|
+
6. Record the restart relationship.
|
|
136
|
+
7. Leave the old run unchanged.
|
|
137
|
+
|
|
138
|
+
Reject restart when:
|
|
139
|
+
|
|
140
|
+
- the run is active or waiting
|
|
141
|
+
- the run is unknown
|
|
142
|
+
- the run belongs to another session
|
|
143
|
+
- the run was explicitly cancelled
|
|
144
|
+
- the workflow source or revision is no longer available
|
|
145
|
+
- the restart limit was reached
|
|
146
|
+
- the same terminal failure already repeated
|
|
147
|
+
|
|
148
|
+
A later explicit user request can still use normal `start`.
|
|
149
|
+
|
|
150
|
+
**Verification**
|
|
151
|
+
|
|
152
|
+
Tool-schema and extension tests must prove exact input reuse, immutable old runs, session checks, source checks, and correct rejection behavior.
|
|
153
|
+
|
|
154
|
+
### 5. Permit one selected launch during the terminal turn
|
|
155
|
+
|
|
156
|
+
**Where**
|
|
157
|
+
|
|
158
|
+
- `queueToolLaunch`
|
|
159
|
+
- presentation tracking in `src/extension/index.ts`
|
|
160
|
+
- `agent_settled`
|
|
161
|
+
- existing queued-launch recovery
|
|
162
|
+
|
|
163
|
+
**Change**
|
|
164
|
+
|
|
165
|
+
The current presentation guard rejects workflow launches. Add one narrow exception for the active terminal-decision turn.
|
|
166
|
+
|
|
167
|
+
The model can reserve one of these:
|
|
168
|
+
|
|
169
|
+
- restart
|
|
170
|
+
- Monitor
|
|
171
|
+
- another workflow start
|
|
172
|
+
|
|
173
|
+
The reservation must not activate until the model turn settles. A second workflow launch from the same terminal turn must fail.
|
|
174
|
+
|
|
175
|
+
Other tool calls remain subject to their normal rules.
|
|
176
|
+
|
|
177
|
+
**Verification**
|
|
178
|
+
|
|
179
|
+
Tests must prove that:
|
|
180
|
+
|
|
181
|
+
- one launch can be reserved during presentation
|
|
182
|
+
- it starts only after `agent_settled`
|
|
183
|
+
- a second launch is rejected
|
|
184
|
+
- reload after reservation does not lose it
|
|
185
|
+
- crash recovery does not start it twice
|
|
186
|
+
|
|
187
|
+
### 6. Add bounded restart lineage
|
|
188
|
+
|
|
189
|
+
**Where**
|
|
190
|
+
|
|
191
|
+
- Add `src/extension/restart-policy.ts`
|
|
192
|
+
- Existing run launch-options JSON and accessors
|
|
193
|
+
- No new database table
|
|
194
|
+
|
|
195
|
+
**Change**
|
|
196
|
+
|
|
197
|
+
Store this information for restarted runs:
|
|
198
|
+
|
|
199
|
+
- root run ID
|
|
200
|
+
- parent run ID
|
|
201
|
+
- restart number
|
|
202
|
+
- parent terminal fingerprint
|
|
203
|
+
|
|
204
|
+
A terminal fingerprint is a stable hash of:
|
|
205
|
+
|
|
206
|
+
- workflow identity and revision
|
|
207
|
+
- exact input
|
|
208
|
+
- terminal state
|
|
209
|
+
- canonical result or error
|
|
210
|
+
- canonical terminal reason
|
|
211
|
+
|
|
212
|
+
Do not include timestamps or new run IDs in the fingerprint.
|
|
213
|
+
|
|
214
|
+
Allow at most three restart actions after the original run. This permits at most four runs in one chain.
|
|
215
|
+
|
|
216
|
+
If a terminal fingerprint occurs again in the same chain, reject another restart immediately. If the result changes because the workflow made progress, another restart can remain eligible until the total limit is reached.
|
|
217
|
+
|
|
218
|
+
Starting Monitor does not consume a restart.
|
|
219
|
+
|
|
220
|
+
**Verification**
|
|
221
|
+
|
|
222
|
+
Tests must cover:
|
|
223
|
+
|
|
224
|
+
- first technical retry
|
|
225
|
+
- progress followed by a different failure
|
|
226
|
+
- repeated identical maxSteps failure
|
|
227
|
+
- three-restart limit
|
|
228
|
+
- Monitor selection
|
|
229
|
+
- restart history after database reopen
|
|
230
|
+
|
|
231
|
+
### 7. Make restart reservation idempotent
|
|
232
|
+
|
|
233
|
+
**Where**
|
|
234
|
+
|
|
235
|
+
- Existing effect records
|
|
236
|
+
- Existing run queue and reservation code
|
|
237
|
+
- Terminal turn-intent settlement code
|
|
238
|
+
|
|
239
|
+
**Change**
|
|
240
|
+
|
|
241
|
+
Key the selected launch to the source terminal turn intent and tool call.
|
|
242
|
+
|
|
243
|
+
If the host repeats the same tool call after a crash or reload, return the existing reservation or new run instead of creating another one.
|
|
244
|
+
|
|
245
|
+
The terminal turn intent, launch reservation, and resulting run must have one inspectable chain.
|
|
246
|
+
|
|
247
|
+
**Verification**
|
|
248
|
+
|
|
249
|
+
Inject failures after:
|
|
250
|
+
|
|
251
|
+
- turn-intent claim
|
|
252
|
+
- launch reservation
|
|
253
|
+
- run creation
|
|
254
|
+
- terminal response settlement
|
|
255
|
+
|
|
256
|
+
After recovery, there must still be one terminal message and one successor run.
|
|
257
|
+
|
|
258
|
+
### 8. Document the contract
|
|
259
|
+
|
|
260
|
+
**Where**
|
|
261
|
+
|
|
262
|
+
- `docs/workflows.md`
|
|
263
|
+
- `docs/SQLITE_STATE.md`
|
|
264
|
+
- Workflow tool reference and examples
|
|
265
|
+
- Relevant README text
|
|
266
|
+
|
|
267
|
+
**Change**
|
|
268
|
+
|
|
269
|
+
Document:
|
|
270
|
+
|
|
271
|
+
- the shared terminal decision turn
|
|
272
|
+
- the `restart` action
|
|
273
|
+
- the difference between a workflow ending and the user’s task finishing
|
|
274
|
+
- retry defaults and limits
|
|
275
|
+
- Monitor selection
|
|
276
|
+
- explicit cancellation behavior
|
|
277
|
+
- top-level versus child-run behavior
|
|
278
|
+
- recovery and duplicate prevention
|
|
279
|
+
- that conversation context remains owned by Pi
|
|
280
|
+
- that Pi Workflows does not capture or persist an original user message
|
|
281
|
+
|
|
282
|
+
No workflow definition needs an opt-in or terminal restart step.
|
|
283
|
+
|
|
284
|
+
## Contract changes
|
|
285
|
+
|
|
286
|
+
- The workflow tool gains `restart`.
|
|
287
|
+
- Every top-level terminal run owns one terminal turn intent.
|
|
288
|
+
- Restart always creates a new run.
|
|
289
|
+
- Restart reuses the exact prior workflow input.
|
|
290
|
+
- The model makes the continuation decision from the current conversation.
|
|
291
|
+
- Restart is preferred, not forced, for unfinished work after technical or temporary failures.
|
|
292
|
+
- Explicit cancellation, missing authority, required user decisions, repeated failures, and completed work stop.
|
|
293
|
+
- Restart lineage uses existing run launch data.
|
|
294
|
+
- No new store, service, controller, or Pi API is added.
|
|
295
|
+
- No original-message provenance contract is added.
|
|
296
|
+
|
|
297
|
+
## Test plan
|
|
298
|
+
|
|
299
|
+
Add regression coverage for:
|
|
300
|
+
|
|
301
|
+
1. Successful completion produces one result turn and no automatic restart.
|
|
302
|
+
2. A blocked result from a completed workflow lets the model select restart.
|
|
303
|
+
3. Failed, timed-out, and maxSteps runs offer restart.
|
|
304
|
+
4. Explicit cancellation is not restartable through the shortcut.
|
|
305
|
+
5. Waiting checkpoints do not produce a terminal turn.
|
|
306
|
+
6. Controller child runs do not produce competing turns.
|
|
307
|
+
7. Presentation and fallback races produce one turn.
|
|
308
|
+
8. Restart uses the exact workflow reference and input.
|
|
309
|
+
9. Restart leaves the prior run unchanged.
|
|
310
|
+
10. Monitor starts through the normal start path.
|
|
311
|
+
11. A selected launch waits for `agent_settled`.
|
|
312
|
+
12. Reload and crash recovery do not duplicate turns or runs.
|
|
313
|
+
13. The same terminal failure cannot repeat indefinitely.
|
|
314
|
+
14. A chain cannot exceed three restarts.
|
|
315
|
+
15. No new code captures, hashes, or stores an original user message.
|
|
316
|
+
16. The maxSteps failure that caused this incident produces a terminal decision turn instead of silently ending the task.
|
|
317
|
+
|
|
318
|
+
Run the full repository checks:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
npm run check
|
|
322
|
+
npm run test:e2e
|
|
323
|
+
npx slophammer-ts@latest dry .
|
|
324
|
+
npx slophammer-ts@latest check . --only ts.dependency-boundaries-required
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Main risks
|
|
328
|
+
|
|
329
|
+
- **The model restarts completed work.**
|
|
330
|
+
Make stopping the default for successful results and enforce restart limits.
|
|
331
|
+
|
|
332
|
+
- **A retry repeats external effects.**
|
|
333
|
+
Include the prior result and restart history so the model can inspect the current state before it retries.
|
|
334
|
+
|
|
335
|
+
- **Presentation and fallback both fire.**
|
|
336
|
+
Make both settle the same turn intent.
|
|
337
|
+
|
|
338
|
+
- **A launch starts while the terminal response is still active.**
|
|
339
|
+
Reserve it first and activate it after `agent_settled`.
|
|
340
|
+
|
|
341
|
+
- **A temporary outage causes a loop.**
|
|
342
|
+
Use Monitor for external waits, stop repeated fingerprints, and allow only three restarts.
|
|
343
|
+
|
|
344
|
+
## Boundaries
|
|
345
|
+
|
|
346
|
+
Do not:
|
|
347
|
+
|
|
348
|
+
- modify Pi core or private APIs
|
|
349
|
+
- store or identify an original user message
|
|
350
|
+
- add restart nodes to individual workflows
|
|
351
|
+
- modify Autoimplement, Monitor, or other workflow definitions
|
|
352
|
+
- create a new controller, database, service, or daemon
|
|
353
|
+
- bypass cancellation, checkpoints, reviews, CI, authority, or safety rules
|
|
354
|
+
- add compatibility shims or parallel state contracts
|
|
355
|
+
- release or deploy anything as part of this plan
|
|
356
|
+
|
|
357
|
+
This is the selected plan.
|
package/docs/workflows.md
CHANGED
|
@@ -430,6 +430,7 @@ The model sees one `workflow` tool. Its `action` field supports:
|
|
|
430
430
|
|
|
431
431
|
- `list` for discovered workflow names and sources.
|
|
432
432
|
- `start` with a workflow name or path and structured input.
|
|
433
|
+
- `restart` with a terminal run ID. It creates a new run from the exact stored workflow reference and input.
|
|
433
434
|
- `status` for the active run or a supplied run ID.
|
|
434
435
|
- `pause`, `resume`, and `cancel` for the active run.
|
|
435
436
|
- `answer` with ordinary checkpoint input and an optional run ID. Protected `humanDecision()` gates reject this model-facing action.
|
|
@@ -439,8 +440,47 @@ The model sees one `workflow` tool. Its `action` field supports:
|
|
|
439
440
|
- `update` for a non-completing update from the current agent attempt.
|
|
440
441
|
- `submit` for the current workflow step contract.
|
|
441
442
|
|
|
442
|
-
A
|
|
443
|
-
|
|
443
|
+
A direct user request to continue or resume the active workflow maps to the
|
|
444
|
+
`resume` action immediately. The model does not call `status` instead of
|
|
445
|
+
`resume`, and it does not use `status` as a prerequisite.
|
|
446
|
+
|
|
447
|
+
`resume` is idempotent while a run is active. A held, pausing, or paused run is
|
|
448
|
+
released and reports `resumed: true`. An active run that is already executing
|
|
449
|
+
returns normal success with `resumed: false` and `alreadyRunning: true`. It does
|
|
450
|
+
not change the run state. With no active run, `resume` still returns a warning.
|
|
451
|
+
|
|
452
|
+
Model-facing `status` keeps `status` as the durable workflow lifecycle state.
|
|
453
|
+
It also reports the host action fields `paused`, `workState`, and `resumable`.
|
|
454
|
+
For the current active run, `paused` is true when the host has requested or
|
|
455
|
+
applied a hold, or when the durable run state has `paused: true`. `workState`
|
|
456
|
+
is `running`, `pausing`, or `paused` for that active host run and `inactive`
|
|
457
|
+
when no current host run can act on the durable state. `resumable` is true only
|
|
458
|
+
when `resume` can release the current active run. Queue-only status uses its
|
|
459
|
+
launch state, such as `queued` or `starting`, as `workState`; queue-only and
|
|
460
|
+
no-run results report `paused: false` and `resumable: false`. Thus, a durable
|
|
461
|
+
`status: "running"` can correctly appear with `workState: "pausing"` or
|
|
462
|
+
`workState: "paused"`, and the status message names that actionable state
|
|
463
|
+
instead of saying only that the workflow is running.
|
|
464
|
+
|
|
465
|
+
Restart uses this contract:
|
|
466
|
+
|
|
467
|
+
```json
|
|
468
|
+
{
|
|
469
|
+
"action": "restart",
|
|
470
|
+
"runId": "terminal-run-id"
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
The terminal run must belong to the current Pi session and must not be active,
|
|
475
|
+
waiting, or explicitly cancelled. Its source and revision must still resolve
|
|
476
|
+
exactly. Restart creates a new immutable run and leaves the terminal run
|
|
477
|
+
unchanged. It copies the stored input and safe launch settings; it does not
|
|
478
|
+
reconstruct input from conversation history.
|
|
479
|
+
|
|
480
|
+
A model-started run is queued until the model's current turn settles. A terminal
|
|
481
|
+
decision turn can reserve one restart, Monitor run, or other workflow start.
|
|
482
|
+
A second workflow launch from that turn fails. The first workflow prompt then
|
|
483
|
+
starts a new turn. This keeps the requesting turn outside
|
|
444
484
|
the workflow's first attempt and prevents an early missing-submission reminder.
|
|
445
485
|
The normal extension offers all actions. The headless RPC bridge offers only
|
|
446
486
|
`update` and `submit`, so a workflow child cannot recursively control other
|
|
@@ -665,19 +705,30 @@ export default defineWorkflow({
|
|
|
665
705
|
});
|
|
666
706
|
```
|
|
667
707
|
|
|
668
|
-
After
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
`
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
708
|
+
After a top-level interactive run becomes terminal, the Pi extension gives the
|
|
709
|
+
model one normal terminal decision turn. The message contains the workflow name
|
|
710
|
+
and revision, terminal run ID, exact stored input, bounded result, terminal
|
|
711
|
+
state and reason, restart count, and earlier terminal outcomes in the restart
|
|
712
|
+
chain. A completed state does not prove that the user's larger task is complete.
|
|
713
|
+
The model uses the current Pi conversation to stop, restart safely, start
|
|
714
|
+
Monitor for an authorized external wait, ask for a decision or authority, or
|
|
715
|
+
take another safe authorized action.
|
|
716
|
+
|
|
717
|
+
`presentationPrompt` adds workflow-specific presentation instructions to this
|
|
718
|
+
shared terminal decision message for completed runs. Returning `undefined`,
|
|
719
|
+
returning an empty string, omitting `presentationPrompt`, or ending in failure,
|
|
720
|
+
timeout, or cancellation uses the factual terminal fallback instead. Normal
|
|
721
|
+
presentation and fallback claim the same terminal turn intent, so races,
|
|
722
|
+
reload, crash recovery, and compaction cannot create a second decision turn.
|
|
723
|
+
Async prompt builders have 30 seconds to finish and receive an `AbortSignal`
|
|
724
|
+
that fires on timeout, session shutdown, or when a new workflow or normal user
|
|
725
|
+
turn starts; stale presentations are discarded.
|
|
726
|
+
|
|
727
|
+
Waiting checkpoints are not terminal and do not create a terminal decision
|
|
728
|
+
turn. Controller child runs and internally owned runs report to their owner and
|
|
729
|
+
do not create competing turns. Explicit cancellation produces terminal facts,
|
|
730
|
+
but its decision instruction defaults to stopping and the `restart` shortcut
|
|
731
|
+
rejects it.
|
|
681
732
|
|
|
682
733
|
An agent with `expectedOutput: assistantMessage()` is different. Its visible
|
|
683
734
|
assistant response is the node output, can appear before later nodes, and also
|
|
@@ -685,12 +736,11 @@ works inside an included workflow. A root `presentationPrompt` would add a
|
|
|
685
736
|
second response, so workflows that end with assistant-message output normally
|
|
686
737
|
omit it.
|
|
687
738
|
|
|
688
|
-
Presentation
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
internals.
|
|
739
|
+
Presentation and terminal decisions are outside the workflow graph: they cannot
|
|
740
|
+
route to another node, change the terminal run, or alter its result. A selected
|
|
741
|
+
restart always creates a new run. Workflow definitions need no opt-in,
|
|
742
|
+
continuation node, or restart prompt. Pi owns conversation history. Pi Workflows
|
|
743
|
+
does not identify, hash, copy, or store an original user message.
|
|
694
744
|
|
|
695
745
|
## Runtime behavior
|
|
696
746
|
|
|
@@ -712,20 +762,26 @@ possible. Defaults worth knowing:
|
|
|
712
762
|
held without nudges and the engine pauses at the next boundary. Node
|
|
713
763
|
timeouts keep ticking while held, so a long-abandoned step still times out.
|
|
714
764
|
`/workflow resume` re-delivers the pending step prompt.
|
|
765
|
+
- Resuming an active run that is already running succeeds without changing the
|
|
766
|
+
engine, executor, widget, or durable workflow state. This makes duplicate
|
|
767
|
+
`resume` calls safe.
|
|
715
768
|
- A model-started workflow is persisted as `queued` with its final run ID before the start tool
|
|
716
769
|
returns. Activation waits for the initiating agent turn to settle, then moves through `starting`
|
|
717
770
|
and `running`. `workflow status` and `workflow cancel` accept the run ID before a SQLite run state
|
|
718
771
|
exists.
|
|
719
772
|
- If deferred activation fails, the queue stores a bounded safe error, releases the session
|
|
720
|
-
reservation, and creates one
|
|
773
|
+
reservation, and creates one terminal turn intent for the initiating session. A workflow that
|
|
721
774
|
reports `started` and then crashes before its first prompt follows the same path. The model gets
|
|
722
|
-
one factual
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
775
|
+
one factual decision turn after settlement. Pi Workflows does not retry automatically.
|
|
776
|
+
- Agent-issued and direct `workflow cancel` actions that cancel an active or queued run create or
|
|
777
|
+
settle one terminal turn intent. The resulting decision defaults to stopping, and `restart`
|
|
778
|
+
rejects the cancelled run. When no run is live but the widget still shows a parked or finished
|
|
779
|
+
run, the command clears the widget.
|
|
780
|
+
- A restart chain allows at most three restart actions after the original run. The terminal
|
|
781
|
+
fingerprint excludes timestamps and run IDs. If the same workflow revision, exact input, state,
|
|
782
|
+
result or error, and reason occur again in that chain, another restart fails immediately. A
|
|
783
|
+
changed outcome can remain restartable until the chain limit. Starting Monitor does not consume
|
|
784
|
+
a restart.
|
|
729
785
|
- One workflow runs per session at a time.
|
|
730
786
|
- After the workflow tool accepts an agent-step submission, any assistant text that follows remains visible. The next workflow message continues the graph. A deferred intent makes a workflow prompt, presentation, and factual fallback compete to provide one successor turn, so an abort cannot produce two continuation turns.
|
|
731
787
|
- Agent nudges: if the model ends its turn without submitting the pending
|
package/herdr-plugin.toml
CHANGED
package/package.json
CHANGED
package/skills/autodoc/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: autodoc
|
|
3
|
-
description:
|
|
3
|
+
description: Records or updates an existing selected plan in canonical documentation without implementing it. Use only when the user explicitly asks to run autodoc.
|
|
4
4
|
compatibility: Requires pi-workflows and the built-in autodoc workflow.
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: autoimplement
|
|
3
|
-
description:
|
|
3
|
+
description: Implements an existing plan end to end, tests it, runs pi-reviewer until no P0/P1 issues remain, and verifies CI/CD. Use only when the user explicitly asks to run autoimplement.
|
|
4
4
|
compatibility: Requires Pi Workflows and the built-in autoimplement workflow.
|
|
5
5
|
---
|
|
6
6
|
|
package/skills/autoplan/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: autoplan
|
|
3
|
-
description:
|
|
3
|
+
description: Compares practical solutions with the ideal end state, selects the best in-scope option, and produces an implementation plan. Use only when the user explicitly asks to run autoplan.
|
|
4
4
|
compatibility: Requires pi-workflows and the built-in autoplan workflow.
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -37,12 +37,12 @@ When this skill is loaded inside an active workflow step, do not start another w
|
|
|
37
37
|
Outside Pi, or when the workflow is unavailable:
|
|
38
38
|
|
|
39
39
|
1. Frame the problem, observable success criteria, scope, constraints, and interfaces under our control.
|
|
40
|
-
2. Record two through four distinct practical candidates. Give each one a stable id, short title, plain gist, full solution, rationale, parts, and trade-offs.
|
|
41
|
-
3. Describe the
|
|
40
|
+
2. Record two through four distinct practical candidates. Ask whether each is a Long term elegant and production ready solution. Give each one a stable id, short title, plain gist, full solution, rationale, parts, and trade-offs.
|
|
41
|
+
3. Describe the Holy grail separately. Ask whether it is the Holy grail for the problem. Name every dependency outside our authority.
|
|
42
42
|
4. Choose the right option without asking the user to decide between them. Record one rejection reason for every other explicit candidate.
|
|
43
|
-
- Choose the
|
|
44
|
-
- Otherwise choose the strongest practical in-scope solution with a clear path toward the
|
|
45
|
-
- Do not block only because the
|
|
43
|
+
- Choose the Holy grail when it is proportionate, production-ready, in scope, and implementable through interfaces we control.
|
|
44
|
+
- Otherwise choose the strongest practical in-scope solution with a clear path toward the Holy grail.
|
|
45
|
+
- Do not block only because the Holy grail requires an upstream or external change.
|
|
46
46
|
5. Write a detailed implementation plan. For each step, state what changes, where it changes, and how to verify it.
|
|
47
47
|
6. Present one short plain assistant message with the chosen plan, its main steps, and a one-line gist and rejection reason for every other candidate. Call it selected for approval when a later human decision still applies.
|
|
48
48
|
7. Stop as blocked only when no truthful in-scope solution can meet the success criteria.
|
|
@@ -22,6 +22,8 @@ Use the smallest applicable action:
|
|
|
22
22
|
- `update` publishes a non-completing durable update for the active step attempt.
|
|
23
23
|
- `submit` completes an active submitted agent step with its required output. An assistant-message step completes through its normal visible reply instead.
|
|
24
24
|
|
|
25
|
+
When the user asks to continue or resume the active workflow, call `workflow` with `action: "resume"` immediately. Do not use `workflow status` as a substitute or prerequisite.
|
|
26
|
+
|
|
25
27
|
Use `start` only once for one requested run. Before starting, load the matching workflow skill when one exists and build its complete input. Include scope, authority, constraints, identifiers, and finish criteria required by that skill. Do not start with placeholders that still need user or model repair.
|
|
26
28
|
|
|
27
29
|
For a workflow without a specialized skill, inspect its input contract and make one complete call. For example:
|