pi-agent-flow 1.7.0 → 1.7.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/README.md +160 -25
- package/package.json +1 -1
- package/src/index.ts +12 -3
- package/src/sliding-prompt.ts +1 -0
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Then start Pi and delegate tasks using flow states.
|
|
|
31
31
|
|
|
32
32
|
```shell
|
|
33
33
|
# Install from a local clone
|
|
34
|
-
git clone https://github.com/
|
|
34
|
+
git clone https://github.com/tuanhung303/pi-agent-flow.git
|
|
35
35
|
cd pi-agent-flow
|
|
36
36
|
pi install .
|
|
37
37
|
```
|
|
@@ -45,18 +45,25 @@ pi install .
|
|
|
45
45
|
- **Flow-state delegation** — six bundled specialist flows (`scout`, `debug`, `build`, `craft`, `audit`, `ideas`) plus custom flows via Markdown front-matter
|
|
46
46
|
- **Isolated forked context** — each flow runs as an isolated `pi` child process with a session snapshot (or clean slate when configured)
|
|
47
47
|
- **Parallel execution** — batch independent flows into one call with bounded concurrency
|
|
48
|
-
- **Structured reports** — every flow returns `[Summary]`, `[Done]`, `[Not Done]`, `[Next Steps]
|
|
48
|
+
- **Structured reports** — every flow returns `[Summary]`, `[Done]`, `[Not Done]`, `[Next Steps]`; optional JSON schema with files, actions, commands, and reasoning
|
|
49
|
+
- **Mechanically enriched commands** — bash commands in structured output are replaced with exact verbatim tool-call strings and annotated with `executionTime`
|
|
49
50
|
- **Depth guards** — configurable max delegation depth (default: `3`)
|
|
50
|
-
- **Session timeout modes** — child flows use controlled budgets: `fast` (300s), `default` (600s),
|
|
51
|
+
- **Session timeout modes** — child flows use controlled budgets: `fast` (300s), `default` (600s), `long` (900s), or `extreme_long` (1200s)
|
|
52
|
+
- **Two-stage timeout awareness** — flows receive deadline hints in their prompt; the parent UI shows live countdowns and injects warning reminders before hard kill
|
|
53
|
+
- **Graceful shutdown** — parent `SIGINT`/`SIGTERM` propagates to all child process groups; orphaned sub-agents are force-killed after a grace period
|
|
51
54
|
- **Cycle prevention** — blocks re-entering flows already in the ancestor stack
|
|
52
55
|
- **Model tiering & failover** — flows map to `lite` / `flash` / `full` tiers with primary + failover model chains
|
|
56
|
+
- **Persistent flow mode** — switch global model strategies with `--flow-mode`; written to `settings.json` and remembered across sessions
|
|
57
|
+
- **Flow-mode notification** — concise (`mode: name | lite: model · flash: model · full: model`) or verbose (with per-tier flow-name labels) startup message
|
|
58
|
+
- **Auto-transition** — opt-in automatic queuing of follow-up flows based on the declarative transition matrix
|
|
53
59
|
- **Unified batch tools** — `batch` (read/write/edit/delete) and `batch_read` replace separate file tools for cross-cutting work
|
|
54
60
|
- **Web tool** — built-in `web` search (Brave + DuckDuckGo) and page fetch with HTML→Markdown conversion
|
|
55
61
|
- **Sliding system prompt** — lightweight routing reminder injected before each user message, stripped from child snapshots to avoid duplication
|
|
56
|
-
- **Session snapshot sanitization** — removes sliding prompts, reasoning/thinking artifacts, and non-inheritable content before forking
|
|
62
|
+
- **Session snapshot sanitization** — removes sliding prompts, reasoning/thinking artifacts, and non-inheritable content before forking; compresses prior flow results into compact context maps
|
|
63
|
+
- **Shared context inheritance** — child flows receive the parent's sanitized session automatically; write forward-looking intents and let the child pick up context from its inherited snapshot
|
|
57
64
|
- **Project flow confirmation** — prompts before running project-local flows from `.pi/agents/` for security
|
|
58
65
|
- **Post-flow hooks** — automatic advisory messages suggesting follow-up flows (e.g., `build → audit`)
|
|
59
|
-
- **Rich TUI rendering** — collapsed activity-panel view with per-flow stats,
|
|
66
|
+
- **Rich TUI rendering** — collapsed activity-panel view with per-flow stats, live countdowns, and expanded view with full reports and tool traces
|
|
60
67
|
- **Smooth streaming metrics** — token counters and smoothed TPS increment tick-by-tick during active streaming
|
|
61
68
|
|
|
62
69
|
---
|
|
@@ -76,15 +83,46 @@ The result is faster, cheaper, and cleaner delegation: the main agent remains un
|
|
|
76
83
|
|
|
77
84
|
---
|
|
78
85
|
|
|
86
|
+
## Shared Context
|
|
87
|
+
|
|
88
|
+
When you delegate to a flow, the child agent receives an automatic **sanitized fork** of your current session. This lets you write concise intents that focus on **what new work to do** rather than restating the full problem.
|
|
89
|
+
|
|
90
|
+
### How it works
|
|
91
|
+
|
|
92
|
+
1. **Snapshot serialized** — your conversation (files read, commands run, prior flow results) is serialized into a JSONL snapshot.
|
|
93
|
+
2. **Sanitized** — sliding prompts, reasoning/thinking artifacts, and other non-inheritable content are stripped.
|
|
94
|
+
3. **Compressed** — prior flow tool results are compacted into short summaries: files touched, commands used, outcome status.
|
|
95
|
+
4. **Forked** — the child agent loads this snapshot via `--session` at startup.
|
|
96
|
+
|
|
97
|
+
### Writing good intents
|
|
98
|
+
|
|
99
|
+
The child already sees what you've done. Write intents that say **what to do next**, not what context it needs:
|
|
100
|
+
|
|
101
|
+
| ❌ Bad intent | ✅ Good intent |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `"The auth module uses JWT tokens… inspect src/auth/ for security issues"` | `"Audit the auth module for security issues"` |
|
|
104
|
+
| `"We already found the bug… run the failing test and fix it"` | `"Fix the failing test in tests/auth.test.ts"` |
|
|
105
|
+
| `"The file structure is… implement the feature described in the PRD"` | `"Implement the feature described in the PRD"` |
|
|
106
|
+
|
|
107
|
+
### Clean slate
|
|
108
|
+
|
|
109
|
+
Set `inheritContext: false` in a custom flow's front-matter to start with a clean slate. The child receives only your `intent` — no inherited session. This is ideal for unbiased creative work in `ideas` flows.
|
|
110
|
+
|
|
111
|
+
### What the child sees
|
|
112
|
+
|
|
113
|
+
The child's `<context-seal>` prompt tells it: *"The conversation above is sealed — it is your session history for situational awareness only."* The child can reference files and findings already in context but shouldn't act as if it's still in the parent's conversation.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
79
117
|
## Bundled Flows
|
|
80
118
|
|
|
81
119
|
| Flow | Purpose | Tools | Tier |
|
|
82
120
|
|------|---------|-------|------|
|
|
83
121
|
| `[scout]` | Discover files, trace code paths, map architecture | `batch`, `bash`, `find`, `grep`, `ls` | `lite` |
|
|
84
|
-
| `[debug]` | Investigate logs, errors, stack traces, root causes
|
|
85
|
-
| `[build]` | Implement features, fix bugs, write tests, update
|
|
122
|
+
| `[debug]` | Investigate logs, errors, stack traces, root causes | `batch`, `bash`, `find`, `grep`, `ls` | `lite` |
|
|
123
|
+
| `[build]` | Implement features, fix bugs, write tests, update docs, ship | `batch`, `bash`, `find`, `grep`, `ls` | `flash` |
|
|
86
124
|
| `[craft]` | Plan structure, break down requirements, design solutions | `batch`, `bash`, `find`, `grep`, `ls` | `full` |
|
|
87
|
-
| `[audit]` | Audit security, quality, correctness; fix issues autonomously | `batch`, `bash`, `find`, `grep`, `ls` | `flash` |
|
|
125
|
+
| `[audit]` | Audit security, quality, correctness; fix safe issues autonomously | `batch`, `bash`, `find`, `grep`, `ls` | `flash` |
|
|
88
126
|
| `[ideas]` | Generate ideas and explore possibilities with inherited context | `batch`, `bash` | `full` |
|
|
89
127
|
|
|
90
128
|
> **Note:** All bundled flows have `maxDepth: 0`, meaning they do not delegate further by default. Custom flows can override this via front-matter.
|
|
@@ -102,6 +140,7 @@ Each flow call may set `sessionMode` to choose the child-agent time budget:
|
|
|
102
140
|
| `fast` | 300s | quick scouting, narrow checks, small design passes |
|
|
103
141
|
| `default` | 600s | normal flow work; this is the default |
|
|
104
142
|
| `long` | 900s | large builds, full test runs, broad refactors, complex debugging |
|
|
143
|
+
| `extreme_long` | 1200s | very large refactors, extensive audits, or multi-step debugging sessions |
|
|
105
144
|
|
|
106
145
|
Example:
|
|
107
146
|
|
|
@@ -120,6 +159,16 @@ Example:
|
|
|
120
159
|
|
|
121
160
|
The public interface is mode-based; arbitrary per-flow numeric timeouts are not exposed.
|
|
122
161
|
|
|
162
|
+
### Timeout behavior
|
|
163
|
+
|
|
164
|
+
Flows are aware of their deadline from the moment they start:
|
|
165
|
+
|
|
166
|
+
- **Prompt injection** — the activation block includes the exact time budget and warns the agent to wrap up before the deadline.
|
|
167
|
+
- **Parent UI countdown** — a live `MM:SS` countdown is shown next to the flow's aim while it runs.
|
|
168
|
+
- **Two-stage warnings** — at 2 minutes before hard timeout a warning is injected into the child's reminder stream; at 2 minutes 15 seconds a final urge demands the agent stop all tool use and output structured findings.
|
|
169
|
+
- **Grace period** — after the hard timeout fires, the agent gets a 90-second reporting grace to finish its summary before the process is force-killed.
|
|
170
|
+
- **Graceful shutdown** — when the parent receives `SIGINT` or `SIGTERM`, the signal propagates to every child process group so sub-agents terminate cleanly instead of becoming orphans.
|
|
171
|
+
|
|
123
172
|
---
|
|
124
173
|
|
|
125
174
|
## Flow Definitions
|
|
@@ -165,24 +214,72 @@ flow [myflow] accomplished
|
|
|
165
214
|
| `thinking` | `string` | Thinking budget (e.g., `"low"`, `"medium"`, `"high"`) |
|
|
166
215
|
| `maxDepth` | `number` | How many more delegation levels this flow may spawn |
|
|
167
216
|
| `inheritContext` | `boolean` | Whether to fork parent session snapshot (`true`) or start clean (`false`) |
|
|
217
|
+
| `tier` | `string` | Explicit tier override: `lite`, `flash`, or `full` |
|
|
168
218
|
|
|
169
219
|
---
|
|
170
220
|
|
|
171
|
-
##
|
|
221
|
+
## Structured Output
|
|
222
|
+
|
|
223
|
+
When `structuredOutput` is enabled (default), flows are instructed to append a JSON code block to their final response. The block is mechanically validated and enriched:
|
|
224
|
+
|
|
225
|
+
- **Bash commands** are replaced with the exact verbatim strings from the actual tool calls, fixing the common LLM behaviour of paraphrasing `curl -s -X POST …` as `"curl GAWA baseline"`.
|
|
226
|
+
- **Execution time** is captured from the timed-bash wrapper and attached to each bash command entry.
|
|
172
227
|
|
|
173
|
-
|
|
228
|
+
Schema:
|
|
174
229
|
|
|
175
|
-
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"version": "1.0",
|
|
233
|
+
"status": "complete",
|
|
234
|
+
"summary": "2-3 sentence summary",
|
|
235
|
+
"files": [
|
|
236
|
+
{ "path": "relative/path", "role": "read", "description": "why it matters", "snippet": "short excerpt", "ranges": [{ "start": 10, "end": 25, "label": "bug" }] }
|
|
237
|
+
],
|
|
238
|
+
"actions": [
|
|
239
|
+
{ "type": "read", "description": "what was done", "target": "file.ts", "result": "success", "evidence": "output or proof" }
|
|
240
|
+
],
|
|
241
|
+
"commands": [
|
|
242
|
+
{ "command": "curl -s -X POST https://api.example.com/v1/data", "tool": "bash", "executionTime": "1.2s (normal)" }
|
|
243
|
+
],
|
|
244
|
+
"notDone": [
|
|
245
|
+
{ "item": "unfinished work", "reason": "why it was not completed", "blocker": "blocking issue", "nextStep": "specific follow-up" }
|
|
246
|
+
],
|
|
247
|
+
"nextSteps": ["recommended follow-up action"],
|
|
248
|
+
"reasoning": ["key hypothesis or inference"],
|
|
249
|
+
"notes": ["observation or warning"]
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Only include fields that have data. Omit empty arrays; missing array fields are acceptable.
|
|
176
254
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Post-Flow Hooks & Auto-Transitions
|
|
258
|
+
|
|
259
|
+
When certain flows complete, the system injects advisory messages suggesting follow-up flows. This keeps the agent on the optimal path without requiring the user to manually chain flows.
|
|
260
|
+
|
|
261
|
+
### Built-in transition matrix
|
|
262
|
+
|
|
263
|
+
| Source | Target | Condition | Advice |
|
|
264
|
+
|--------|--------|-----------|--------|
|
|
265
|
+
| `scout` | `build` | success | Context mapped. Consider running a [build] flow to implement changes, or [debug] if investigating an issue. |
|
|
266
|
+
| `scout` | `debug` | success | Context mapped. Consider running a [debug] flow if investigating an issue. |
|
|
267
|
+
| `debug` | `build` | success | The root cause has been identified. Consider running a [build] flow to implement the fix. |
|
|
268
|
+
| `debug` | `audit` | success | Root cause identified. Consider running an [audit] flow to verify the fix area for related issues. |
|
|
269
|
+
| `build` | `audit` | success | Consider running an [audit] flow to audit the changes for security, correctness, and code quality. |
|
|
270
|
+
| `build` | `debug` | failure | Build failed. Consider running a [debug] flow to investigate the root cause. |
|
|
271
|
+
| `audit` | `scout` | success | Audit complete. Consider running a [scout] flow to trace the audit findings across the codebase. |
|
|
272
|
+
| `audit` | `build` | failure | Audit found issues. Consider running a [build] flow to fix them. |
|
|
273
|
+
| `craft` | `build` | success | Plan ready. Consider running a [build] flow to implement the design. |
|
|
274
|
+
| `ideas` | `craft` | success | Ideas explored. Consider running a [craft] flow to design the approach, or [build] to implement directly. |
|
|
182
275
|
|
|
183
276
|
Hooks are smart: if the agent already included the suggested flow in the same batch, the advisory is suppressed to avoid redundancy.
|
|
184
277
|
|
|
185
|
-
###
|
|
278
|
+
### Auto-transition
|
|
279
|
+
|
|
280
|
+
Enable `autoTransition: true` in `flowSettings` (or `--auto-transition`) to automatically queue follow-up flows without manual intervention. The system checks that the target flow exists, was not already requested, and would not create a cycle before queuing it.
|
|
281
|
+
|
|
282
|
+
### Extending hooks
|
|
186
283
|
|
|
187
284
|
Hooks are registered via `registerHook()` in `hooks.ts`. Each hook defines a trigger (flow type + success requirement) and an action that returns advisory text.
|
|
188
285
|
|
|
@@ -220,7 +317,7 @@ registerHook({
|
|
|
220
317
|
}
|
|
221
318
|
```
|
|
222
319
|
|
|
223
|
-
### Override working directory
|
|
320
|
+
### Override working directory or confirm project flows
|
|
224
321
|
|
|
225
322
|
```json
|
|
226
323
|
{
|
|
@@ -230,13 +327,26 @@ registerHook({
|
|
|
230
327
|
}
|
|
231
328
|
```
|
|
232
329
|
|
|
330
|
+
Suppress the confirmation prompt before running project-local flows:
|
|
331
|
+
|
|
332
|
+
```json
|
|
333
|
+
{
|
|
334
|
+
"flow": [
|
|
335
|
+
{ "type": "scout", "intent": "Map packages/ui", "aim": "Map UI package" }
|
|
336
|
+
],
|
|
337
|
+
"confirmProjectFlows": false
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
233
343
|
---
|
|
234
344
|
|
|
235
345
|
## Tools
|
|
236
346
|
|
|
237
347
|
### `flow` — delegate to flow states
|
|
238
348
|
|
|
239
|
-
The core delegation tool. Accepts an array of flow tasks and runs them in parallel.
|
|
349
|
+
The core delegation tool. Accepts an array of flow tasks and runs them in parallel with bounded concurrency (default: 4, capped to CPU count).
|
|
240
350
|
|
|
241
351
|
### `batch` / `batch_read` — unified file operations
|
|
242
352
|
|
|
@@ -289,16 +399,27 @@ Use `flowModelConfigs` in your Pi settings to define tiered model strategies. Ea
|
|
|
289
399
|
|
|
290
400
|
Settings are merged: project `.pi/settings.json` overrides global `~/.pi/agent/settings.json`.
|
|
291
401
|
|
|
402
|
+
### Persistent flow mode switch
|
|
403
|
+
|
|
292
404
|
Switch the global active strategy quickly with `--flow-mode`:
|
|
293
405
|
|
|
294
406
|
```bash
|
|
295
407
|
pi --flow-mode balance
|
|
296
408
|
pi --flow-mode quality
|
|
297
|
-
pi --flow-mode mimo
|
|
298
409
|
```
|
|
299
410
|
|
|
300
411
|
`--flow-mode` updates `flowModelConfig` in global `~/.pi/agent/settings.json` (or `$PI_CODING_AGENT_DIR/settings.json`) and applies the mode immediately for the current invocation. The mode must already exist in the merged `flowModelConfigs`; project `.pi/settings.json` can still override global settings on later no-flag runs.
|
|
301
412
|
|
|
413
|
+
On startup, the selected mode is printed in a compact notification:
|
|
414
|
+
|
|
415
|
+
```
|
|
416
|
+
mode: balance | lite: gpt-5.4-mini · flash: gpt-5.5 · full: gpt-5.5
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Failover-only tiers are shown as `failover: model-a, model-b`. Verbose mode includes the flow names associated with each tier.
|
|
420
|
+
|
|
421
|
+
### Flow settings
|
|
422
|
+
|
|
302
423
|
You can also set flow runtime defaults under `flowSettings`:
|
|
303
424
|
|
|
304
425
|
```json
|
|
@@ -313,7 +434,15 @@ You can also set flow runtime defaults under `flowSettings`:
|
|
|
313
434
|
}
|
|
314
435
|
```
|
|
315
436
|
|
|
316
|
-
|
|
437
|
+
| Setting | Default | Description |
|
|
438
|
+
|---------|---------|-------------|
|
|
439
|
+
| `sessionMode` | `default` | Default child-flow session mode: `fast`, `default`, `long`, or `extreme_long` |
|
|
440
|
+
| `maxConcurrency` | `4` | Maximum parallel flows (capped to CPU count) |
|
|
441
|
+
| `toolOptimize` | `true` | Use unified `batch`/`batch_read` instead of separate read/write/edit |
|
|
442
|
+
| `structuredOutput` | `true` | Inject JSON structured-output instructions into flow prompts |
|
|
443
|
+
| `autoTransition` | `false` | Automatically queue follow-up flows based on the transition matrix |
|
|
444
|
+
|
|
445
|
+
Session mode precedence is:
|
|
317
446
|
|
|
318
447
|
```txt
|
|
319
448
|
per-flow sessionMode > --flow-session-mode > PI_FLOW_SESSION_MODE > flowSettings.sessionMode > default
|
|
@@ -331,9 +460,13 @@ per-flow sessionMode > --flow-session-mode > PI_FLOW_SESSION_MODE > flowSettings
|
|
|
331
460
|
| `--flow-lite-model [model]` | Override the lite-tier model | — |
|
|
332
461
|
| `--flow-flash-model [model]` | Override the flash-tier model | — |
|
|
333
462
|
| `--flow-full-model [model]` | Override the full-tier model | — |
|
|
334
|
-
| `--flow-session-mode [mode]` | Default child-flow session mode
|
|
335
|
-
| `--
|
|
336
|
-
| `--
|
|
463
|
+
| `--flow-session-mode [mode]` | Default child-flow session mode | `default` |
|
|
464
|
+
| `--flow-max-concurrency [n]` | Maximum parallel flows | `4` |
|
|
465
|
+
| `--tool-optimize` | Use unified `batch`/`batch_read` | `true` |
|
|
466
|
+
| `--no-tool-optimize` | Disable tool optimization; use legacy read/write/edit | — |
|
|
467
|
+
| `--auto-transition` | Automatically queue follow-up flows | `false` |
|
|
468
|
+
| `--structured-output` | Inject structured JSON output instructions | `true` |
|
|
469
|
+
| `--no-structured-output` | Disable structured output injection | — |
|
|
337
470
|
|
|
338
471
|
### Environment variables
|
|
339
472
|
|
|
@@ -344,7 +477,9 @@ per-flow sessionMode > --flow-session-mode > PI_FLOW_SESSION_MODE > flowSettings
|
|
|
344
477
|
| `PI_FLOW_STACK` | JSON array of ancestor flow names |
|
|
345
478
|
| `PI_FLOW_PREVENT_CYCLES` | `"1"` or `"0"` |
|
|
346
479
|
| `PI_FLOW_TOOL_OPTIMIZE` | `"1"` or `"0"` (overrides default tool optimization) |
|
|
347
|
-
| `PI_FLOW_SESSION_MODE` | Default child-flow session mode: `fast`, `default`, or `
|
|
480
|
+
| `PI_FLOW_SESSION_MODE` | Default child-flow session mode: `fast`, `default`, `long`, or `extreme_long` |
|
|
481
|
+
| `PI_FLOW_MAX_CONCURRENCY` | Maximum parallel flows |
|
|
482
|
+
| `PI_FLOW_SPAWN_COMMAND` | Override the spawn command for exotic runtime environments (e.g. bundled with pkg/nexe) |
|
|
348
483
|
|
|
349
484
|
---
|
|
350
485
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -100,8 +100,9 @@ const FlowItem = Type.Object({
|
|
|
100
100
|
Type.Literal("fast"),
|
|
101
101
|
Type.Literal("default"),
|
|
102
102
|
Type.Literal("long"),
|
|
103
|
+
Type.Literal("extreme_long"),
|
|
103
104
|
], {
|
|
104
|
-
description: "Agent session budget for this flow: fast=300s, default=600s, long=900s. Use long
|
|
105
|
+
description: "Agent session budget for this flow: fast=300s, default=600s, long=900s, extreme_long=1200s. Use long or extreme_long only when the work genuinely needs the larger budget.",
|
|
105
106
|
}),
|
|
106
107
|
),
|
|
107
108
|
});
|
|
@@ -110,7 +111,7 @@ const FlowParams = Type.Object({
|
|
|
110
111
|
flow: Type.Array(FlowItem, {
|
|
111
112
|
description:
|
|
112
113
|
"Array of flow tasks to execute. Each runs in its own forked process. " +
|
|
113
|
-
"Optional sessionMode selects the child-agent budget: fast=300s, default=600s, long=900s. " +
|
|
114
|
+
"Optional sessionMode selects the child-agent budget: fast=300s, default=600s, long=900s, extreme_long=1200s. " +
|
|
114
115
|
'Example: { flow: [{ type: "scout", "intent": "Find all authentication-related code and trace JWT validation", "aim": "Find auth code and trace JWT", "sessionMode": "fast" }, { type: "build", "intent": "Fix the bug in user registration", "aim": "Fix registration bug", "sessionMode": "long" }] }',
|
|
115
116
|
minItems: 1,
|
|
116
117
|
}),
|
|
@@ -933,6 +934,14 @@ flow [type] accomplished
|
|
|
933
934
|
|
|
934
935
|
### Guards
|
|
935
936
|
- Depth: ${currentDepth}/${maxDepth} | Cycles: ${preventCycles ? "blocked" : "off"} | Stack: ${ancestorFlowStack.length > 0 ? ancestorFlowStack.join(" -> ") : "(root)"}
|
|
937
|
+
|
|
938
|
+
### Shared Context
|
|
939
|
+
Child flows fork your session automatically:
|
|
940
|
+
|
|
941
|
+
- They receive a sanitized snapshot of your conversation — files read, commands run, prior flow results.
|
|
942
|
+
- Prior flow tool results are **compressed** into compact summaries (files touched, commands used, status).
|
|
943
|
+
- Write 'intent' as a **forward-looking mission** — reference what the child already sees, don't re-describe it.
|
|
944
|
+
- Set inheritContext: false in a custom flow's front-matter to start with a **clean slate** (no inherited context).
|
|
936
945
|
`,
|
|
937
946
|
};
|
|
938
947
|
});
|
|
@@ -997,7 +1006,7 @@ flow [type] accomplished
|
|
|
997
1006
|
"",
|
|
998
1007
|
"Flow states are isolated \u03c0 processes with forked session snapshots. They run in parallel.",
|
|
999
1008
|
'Invoke: { "flow": [{ "type": "scout", "intent": "...", "aim": "...", "sessionMode": "default" }, ...] }',
|
|
1000
|
-
"Session modes: fast=300s, default=600s, long=900s. Use long only when the work genuinely needs the larger budget.",
|
|
1009
|
+
"Session modes: fast=300s, default=600s, long=900s, extreme_long=1200s. Use long or extreme_long only when the work genuinely needs the larger budget.",
|
|
1001
1010
|
"States: scout, debug, build, craft, audit, ideas.",
|
|
1002
1011
|
"Custom states configs in (create if not exists): .md files in .pi/agents/ or ~/.pi/agent/agents/.",
|
|
1003
1012
|
].join("\n"),
|
package/src/sliding-prompt.ts
CHANGED
|
@@ -22,6 +22,7 @@ export const SLIDING_PROMPT =
|
|
|
22
22
|
`You are operating with pi-agent-flow routing.\n` +
|
|
23
23
|
`If the answer is already in context, answer directly; otherwise delegate to the appropriate flow.\n` +
|
|
24
24
|
`For git, bash, CLI, or terminal tasks, delegate to [build].\n` +
|
|
25
|
+
`Child flows inherit your session context — write intents that focus on new work rather than restating what the child already sees.\n` +
|
|
25
26
|
`${SLIDING_PROMPT_CLOSE_TAG}`;
|
|
26
27
|
|
|
27
28
|
const SLIDING_PROMPT_RE = new RegExp(
|