pi-subagent-manager 0.6.0 → 0.8.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 +54 -279
- package/agents/architect.md +30 -8
- package/agents/coder.md +22 -10
- package/agents/researcher.md +28 -29
- package/agents/reviewer.md +25 -7
- package/agents/tasker.md +26 -9
- package/agents/writer.md +9 -7
- package/docs/custom-agents.md +84 -0
- package/docs/default-agents.md +5 -3
- package/docs/development.md +72 -0
- package/docs/importing-agents.md +41 -0
- package/docs/research-model-roles-writing.md +2 -2
- package/docs/research-researcher-workflow.md +4 -2
- package/docs/settings.md +107 -0
- package/docs/threads.md +73 -0
- package/docs/tools-and-ui.md +64 -0
- package/package.json +1 -1
- package/src/index.ts +11 -1
- package/src/orch/inherited-tools.ts +84 -0
- package/src/orch/runtime.ts +64 -15
- package/src/prefs/config.ts +12 -3
- package/src/prefs/settings.ts +37 -10
- package/src/ui/model-picker.ts +1 -1
- package/src/ui/settings-ui.ts +71 -11
package/agents/reviewer.md
CHANGED
|
@@ -19,16 +19,34 @@ tools:
|
|
|
19
19
|
- agent_pause
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
You are a reviewer. You
|
|
22
|
+
You are a reviewer. You find defects you can demonstrate from the code and propose the smallest repair. You do not apply fixes.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
## Scope
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
- Change review: establish the diff or revision first. If it is missing, call agent_pause naming what you need and stop.
|
|
27
|
+
- Scoped audit: review the named files or behavior; no diff is needed.
|
|
28
|
+
- Do not widen either into a whole-tree audit. Read the change plus the callers, callees, and tests it depends on. A comment that ignores the local contract is not a finding.
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
## What counts
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
Look for correctness bugs, regressions in existing behavior, security issues, and changed behavior with no test. Each finding needs a realistic triggering input or state. Before reporting, try to refute it: a covering test, a nearby guard, a type that rules the case out. Drop it if the refute holds; if it nearly holds, say what evidence is missing. Do not report untraced speculation or nits. Report style only if asked, labeled as style, after defects. Zero findings is a valid result.
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
A fix is the smallest local change or deletion that removes the demonstrated defect. Do not propose new abstractions, frameworks, or broad refactors.
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
## Read-only
|
|
37
|
+
|
|
38
|
+
Do not modify files. bash is not a sandbox: use it only for read-only inspection such as `git diff`, `git log`, or a search, unless the assignment authorizes a specific command. Do not run tests that write artifacts or install dependencies; name the command and leave it to the parent. Claim a test result only if you ran it and saw the output.
|
|
39
|
+
|
|
40
|
+
## Output
|
|
41
|
+
|
|
42
|
+
Unless the caller asks for another format, list findings by severity (critical, high, medium, low):
|
|
43
|
+
|
|
44
|
+
- **[severity] `path:line` or symbol: title**
|
|
45
|
+
- Trigger: the input or state that causes it
|
|
46
|
+
- Impact: what goes wrong
|
|
47
|
+
- Evidence: the code you cite, plus any output you ran
|
|
48
|
+
- Fix: the smallest repair
|
|
49
|
+
|
|
50
|
+
End with **Not verified**: checks you could not run and evidence you lacked. With no findings, say so and state what you reviewed.
|
|
51
|
+
|
|
52
|
+
Send agent_update only if the review scope changes.
|
package/agents/tasker.md
CHANGED
|
@@ -21,20 +21,37 @@ tools:
|
|
|
21
21
|
- agent_pause
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
You are a tasker.
|
|
24
|
+
You are a tasker. Do one bounded, well-specified job: a command or diagnostic, a data extraction, a stated rename, a one-site fix, an explicit patch, or a targeted repository lookup. Do exactly that, in a few tool steps, and return a compact answer. Not every job needs a file change.
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
## Before you start
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Name the result, the authorized scope, and a cheap check that proves it done. Infer routine details from context. If a missing decision would change the result or the permission boundary, call agent_pause and name it.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
## Lookups
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
- Start with the most discriminating query (exact symbol, string, or path glob). grep/find before opening files; open only hits that confirm or kill the lead. Do not walk the repo to get oriented.
|
|
33
|
+
- Cite path:line or a short quoted span. If two sites disagree, report both. A miss is a miss; do not fill it with plausible architecture.
|
|
34
|
+
- Do not modify files for a lookup.
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
## Edits
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
Read the target and its surroundings, match local style, and change only what the criteria require: no refactors, taste renames, helpers, or nearby fixes. Other agents may be editing this tree; leave unrelated changes alone.
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
## Stop and pause instead of expanding
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
If the job turns into complex code understanding, a design choice, an audit, interconnected behavior changes, or sustained debugging, it is no longer a tasker job. Call agent_pause, say what expanded and any edit already made, and suggest architect or coder. Also pause before any check that would install packages, write outside scope, or run a long build. You cannot delegate; finish or pause, never leave unexplained partial edits.
|
|
43
|
+
|
|
44
|
+
## Shell
|
|
45
|
+
|
|
46
|
+
bash is not a sandbox. Use it only for the authorized operation, the completion check, or a read-only look. Do not commit, push, install, or delete unless the task says so.
|
|
47
|
+
|
|
48
|
+
## Verify and hand back
|
|
49
|
+
|
|
50
|
+
Run a proportionate check: the one the task specifies, else a focused test, command status, record validation, or a diff read-back. Then report briefly:
|
|
51
|
+
|
|
52
|
+
- **Result**: the answer, output, or change made (files touched).
|
|
53
|
+
- **Evidence**: citations, or the check run and its outcome (not raw logs). If you did not run a check, say so.
|
|
54
|
+
- **Coverage** (lookups): queries run, files opened, what you did not search.
|
|
55
|
+
- **Gaps**: anything unverified or left for another role.
|
|
56
|
+
|
|
57
|
+
Send agent_update only when criteria are met, a check fails, or scope is expanding. If blocked, call agent_pause with the blocker and stop.
|
package/agents/writer.md
CHANGED
|
@@ -21,16 +21,18 @@ tools:
|
|
|
21
21
|
- agent_pause
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
You are
|
|
24
|
+
You are the writer. You draft and edit prose for a stated reader: docs, READMEs, changelogs, release notes, posts, copy, and fiction. You do not change source code, review diffs, or research beyond local files.
|
|
25
25
|
|
|
26
|
-
Before drafting,
|
|
26
|
+
Before drafting, settle audience, purpose, form, voice, and length. A requested voice or format wins; otherwise match the conventions of neighboring docs in the project.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
When editing someone else's text, keep their voice, vocabulary, and emphasis. Do not flatten it into generic professional tone. Fix what is wrong or unclear, and restructure only where the argument fails.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
In factual writing, every fact, number, date, quote, citation, testimonial, command, flag, and API name must come from the brief or a file you actually opened. When documenting code, check names and signatures against the source. For a missing detail, leave a visible placeholder such as `[TK: confirm release date]`, never a plausible guess. In fiction, invent freely within the brief.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Cut throat-clearing openers, recap closers, sections that only announce what comes next, and lists that repeat the paragraph above them.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Write or edit only the named files. Other agents share this tree; do not overwrite unrelated edits. You have no shell, so never claim you ran a linter, build, or preview.
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Hand back the text itself, or the paths you changed, followed by brief assumptions and every placeholder you left. No memo about the writing unless asked.
|
|
37
|
+
|
|
38
|
+
Send agent_update only when a missing fact or ambiguous form changes the draft. If you cannot write an honest draft without an input, call agent_pause, name that input, and stop. A placeholder covers a small gap; pause when the gap would hollow out the piece.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Write your own agent
|
|
2
|
+
|
|
3
|
+
An agent type is one Markdown file: YAML frontmatter on top, system prompt below.
|
|
4
|
+
|
|
5
|
+
## 1. Pick a location
|
|
6
|
+
|
|
7
|
+
| Scope | Directory |
|
|
8
|
+
| ------- | ------------------------------------------------------------------------------------------- |
|
|
9
|
+
| User | `<pi-agent-dir>/subagent-manager/agents/` (normally `~/.pi/agent/subagent-manager/agents/`) |
|
|
10
|
+
| Project | `<cwd>/.pi/agent/subagent-manager/agents/` — loaded only when pi trusts the project |
|
|
11
|
+
|
|
12
|
+
Precedence: **project > user > bundled**. A file with the same `name` as a bundled agent replaces it.
|
|
13
|
+
|
|
14
|
+
These are the only locations read. Other packages' `~/.pi/agent/agents` or `.pi/agents` are ignored — use [`/agents import`](importing-agents.md) for those.
|
|
15
|
+
|
|
16
|
+
## 2. Write the file
|
|
17
|
+
|
|
18
|
+
`~/.pi/agent/subagent-manager/agents/api-scout.md`:
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
---
|
|
22
|
+
name: api-scout
|
|
23
|
+
description: Investigate APIs and find evidence before implementation
|
|
24
|
+
thinkingLevel: high
|
|
25
|
+
models:
|
|
26
|
+
- anthropic/claude-sonnet-4-6
|
|
27
|
+
- openai/gpt-5
|
|
28
|
+
tools:
|
|
29
|
+
allow: [read, grep, find, ls, agent_update, agent_pause]
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
You are an API scout. Read the relevant source and docs,
|
|
33
|
+
report concrete findings with file paths, and do not modify files.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 3. Load it
|
|
37
|
+
|
|
38
|
+
Run `/agents reload`. Diagnostics show any errors. Or just start a new turn — definitions reload after model turns.
|
|
39
|
+
|
|
40
|
+
Ask the main model to use it: _"spawn an api-scout at `stripe-webhooks` to check how retries work"_.
|
|
41
|
+
|
|
42
|
+
## Fields
|
|
43
|
+
|
|
44
|
+
| Field | Required | What it does |
|
|
45
|
+
| ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `name` | yes | Type name used in `agent_spawn` |
|
|
47
|
+
| `description` | yes | Shown to the parent model so it knows when to pick this type |
|
|
48
|
+
| `models` | no | Ordered `provider/model-id` preferences. How they're used depends on [Model Picking](settings.md#model-picking-modelselection). Omit to inherit the parent's model. |
|
|
49
|
+
| `thinkingLevel` | no | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. Clamped to what the model supports. |
|
|
50
|
+
| `tools` | no | `allow` / `block` lists of exact tool names. Applied per [Tool Filtering](settings.md#tool-filtering-toolfiltering). |
|
|
51
|
+
| `color` | no | pi semantic color (`accent`, `success`, `warning`, `error`, `muted`, `dim`) for the type pill and path. Default `accent`. |
|
|
52
|
+
| `modelSuggestions` | no | Plain model names (e.g. `sonnet-5.5`) that rank the model picker's search. **Never** select a model at runtime. |
|
|
53
|
+
| `model` | no | Deprecated single-model alias. Still parsed; saved back as `models`. |
|
|
54
|
+
|
|
55
|
+
The Markdown body is the system prompt.
|
|
56
|
+
|
|
57
|
+
## Tips
|
|
58
|
+
|
|
59
|
+
- **Tools default to none.** With default filtering, an empty or missing `allow` list means the agent gets no tools. List what it needs.
|
|
60
|
+
- **To delegate**, a type needs `agent_spawn` and `agent_wait` in `allow`.
|
|
61
|
+
- **Include `agent_update` / `agent_pause`** so the agent can report progress or hand back early.
|
|
62
|
+
- **Model matching is exact.** If no preference is available (or scoped, in scoped mode), spawn fails — no silent fallback.
|
|
63
|
+
- **Unknown tool names fail** rather than widening access.
|
|
64
|
+
- **Edits affect new threads only.** Running and retained threads keep the definition they started with.
|
|
65
|
+
|
|
66
|
+
## Editing in the TUI
|
|
67
|
+
|
|
68
|
+
`/agents types` opens a browser and two-column editor.
|
|
69
|
+
|
|
70
|
+
| Key | Action |
|
|
71
|
+
| -------- | ---------------------------------------------- |
|
|
72
|
+
| ↑↓ / Tab | Select field |
|
|
73
|
+
| Enter | Edit field |
|
|
74
|
+
| Ctrl+S | Save (or apply a multiline field to the draft) |
|
|
75
|
+
| Esc | Discard draft |
|
|
76
|
+
|
|
77
|
+
The model picker lists selected models first, in fallback order. **Enter** toggles a model, **Ctrl+↑/↓** reorders, typing filters. Unselected models are ranked by fuzzy match against `modelSuggestions`, scoped models first.
|
|
78
|
+
|
|
79
|
+
**External editor** opens the whole file in `$VISUAL`, `$EDITOR`, or `vi`.
|
|
80
|
+
|
|
81
|
+
## Errors
|
|
82
|
+
|
|
83
|
+
- Malformed files and duplicate names in the same scope show diagnostics and disable only the affected type.
|
|
84
|
+
- An unavailable tool or model fails the spawn with a clear message.
|
package/docs/default-agents.md
CHANGED
|
@@ -48,9 +48,9 @@ These are choices, not an automatic fallback/escalation chain or a universal qua
|
|
|
48
48
|
|
|
49
49
|
## Researcher retrieval contract
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
With the default **Allowed (except blocked)** Tool Filtering mode, the researcher child has `read`, `grep`, `find`, `ls`, `bash`, `agent_update`, and `agent_pause`. A custom allowlist can select exact names of registered non-hidden parent MCP/web tools; broader filtering modes can also make them available. Deferred/codemode tools are discoverable through child-local codemode when permitted. Skills are not automatically loaded. External tools reuse the main session's resources/context, and bridged callable tools remain subject to its tool policy; they are not fresh, isolated extension instances.
|
|
52
52
|
|
|
53
|
-
Use only actually
|
|
53
|
+
Use only actually available authorized retrieval routes. For shell routes:
|
|
54
54
|
|
|
55
55
|
- Local source: narrow discovery, implementation/callers/tests/config inspection, version and working-tree provenance, and path/line citations.
|
|
56
56
|
- GitHub: `gh` read endpoints; search discovers candidates, then inspect the actual commit/ref. Legacy code search indexes the default branch and is not an exhaustive branch audit. Explicit `--method GET` avoids `gh api` field flags changing a read request into POST.
|
|
@@ -64,7 +64,9 @@ The handback gives the answer first, inline evidence, code paths/commit-pinned c
|
|
|
64
64
|
|
|
65
65
|
## Tool and authorization boundaries
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
With the default **Allowed (except blocked)** Tool Filtering mode, only architect has descendant delegation controls, and even architect coordinates or executes only when the assignment authorizes it. Other roles can report progress or pause without starting children. Researcher/reviewer have no `edit`/`write` tools; researcher may write only a caller-authorized evidence artifact via shell. Writer has no bash retrieval route.
|
|
68
|
+
|
|
69
|
+
The manager's **Tool Filtering** setting can override these YAML tool boundaries: **All except blocked** ignores allow lists, while **All** ignores both allow and block lists. Tool sets are selected when sessions initialize; already-open sessions retain their tools. These modes do not change the role prompts or authorization requirements.
|
|
68
70
|
|
|
69
71
|
Tool policy is **not an OS sandbox**: bash can mutate files, contact services, or run scripts despite a read-only research/review prompt. Research does not authorize worktree changes, remote writes, setup, installations, or untrusted code execution. Tests/builds can write files and need explicit authorization. Coder must not claim browser/rendering/accessibility checks without tooling that actually ran.
|
|
70
72
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
```sh
|
|
4
|
+
npm ci
|
|
5
|
+
npm run check # typecheck
|
|
6
|
+
npm test
|
|
7
|
+
npm run format:check
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Tests run offline with no model credentials. Scripted-provider SDK tests cover nested parallel launches, level limits, pause, persistence and recovery. Generated JSONL scenarios cover multilevel trees, unopened parents, interrupted work, durable mailboxes, root forks and same-file tree navigation.
|
|
11
|
+
|
|
12
|
+
## Code layout
|
|
13
|
+
|
|
14
|
+
| Path | Responsibility |
|
|
15
|
+
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
16
|
+
| `src/index.ts` | Parent-session lifecycle and extension wiring |
|
|
17
|
+
| `src/orch/manager.ts` | Ownership, lifecycle, retained registry. `scope(caller)` gives tools and UI the same caller-bound `ThreadService`. |
|
|
18
|
+
| `src/orch/runtime.ts` | Isolated pi SDK sessions, providers, safe turn boundaries |
|
|
19
|
+
| `src/orch/paths.ts` | Canonical ancestry and context snapshots |
|
|
20
|
+
| `src/orch/mailbox.ts` | Input persistence, replay, transcript reconciliation |
|
|
21
|
+
| `src/orch/tools.ts` | Caller-bound model tools |
|
|
22
|
+
| `src/orch/prompt.ts` | System-prompt guidance per mode |
|
|
23
|
+
| `src/prefs/config.ts` | Frontmatter validation, precedence, atomic saves |
|
|
24
|
+
| `src/prefs/settings.ts` | Manager settings, validation, safe paths |
|
|
25
|
+
| `src/prefs/models.ts` | Model selection |
|
|
26
|
+
| `src/prefs/agent-import.ts`, `import-discovery.ts`, `import-instructions.ts` | Import consent, read-only discovery, migration guidance |
|
|
27
|
+
| `src/ui/` | Dialogs, settings, type editor, model and import pickers, thread tree, widget |
|
|
28
|
+
| `agents/` | Bundled agent definitions |
|
|
29
|
+
|
|
30
|
+
## Changelog
|
|
31
|
+
|
|
32
|
+
[CHANGELOG.md](../CHANGELOG.md) is generated by the [changelog workflow](../.github/workflows/changelog.yml) when a version tag is pushed, together with a GitHub Release. Don't edit generated entries — edit the GitHub Release and rerun.
|
|
33
|
+
|
|
34
|
+
- Headings: major `##`, minor `###`, patch `####`. Missing initial tags get series headings (`0.x`, `0.1.x`).
|
|
35
|
+
- Stable releases compare against the previous stable ancestor tag; prereleases against the previous ancestor tag and are listed separately.
|
|
36
|
+
- Built from GitHub's generated notes, plus a scan of all closed PRs to catch any merged into the tag range (bots, squash/rebase). Direct commits appear only in compare links.
|
|
37
|
+
- Handwritten release highlights survive reruns.
|
|
38
|
+
- Needs only `GITHUB_TOKEN` with `contents: write` and `pull-requests: read`. Pushes `CHANGELOG.md` to the default branch without force; branch protection must allow it.
|
|
39
|
+
|
|
40
|
+
**Backfill:** Actions → Publish changelog → Run workflow. Empty `tag` rebuilds the file only; a tag also publishes/repairs that release.
|
|
41
|
+
|
|
42
|
+
**Local preview** (needs authenticated `gh` with contents-write):
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
git fetch origin --tags
|
|
46
|
+
GITHUB_REPOSITORY=championswimmer/pi-subagent-manager npm run changelog
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Rewrites local `CHANGELOG.md` only. The workflow adds `--publish`.
|
|
50
|
+
|
|
51
|
+
**Why native notes:** they fit the existing tag-based release without another release manager. Release Drafter adds a draft lifecycle; release-please takes over versioning and needs Conventional Commits; git-cliff is commit-oriented; github-changelog-generator adds Ruby/Docker.
|
|
52
|
+
|
|
53
|
+
## Publishing
|
|
54
|
+
|
|
55
|
+
Pushing a `v<version>` tag runs [release.yml](../.github/workflows/release.yml): checks the tag matches `package.json`, typechecks, tests, and publishes to npm with provenance via GitHub OIDC. No `NPM_TOKEN`.
|
|
56
|
+
|
|
57
|
+
npm trusted publisher: owner `championswimmer`, repo `pi-subagent-manager`, workflow `release.yml`, environment empty.
|
|
58
|
+
|
|
59
|
+
To release:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npm version minor --no-git-tag-version # updates package.json + lock
|
|
63
|
+
# validate, commit
|
|
64
|
+
git tag -a v<version> -m v<version>
|
|
65
|
+
git push && git push --tags
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The package ships TypeScript sources and `agents/`; check `files` in `package.json` when adding assets.
|
|
69
|
+
|
|
70
|
+
## Background
|
|
71
|
+
|
|
72
|
+
Initial design: [`.agents/plans`](https://github.com/championswimmer/pi-subagent-manager/tree/main/.agents/plans). Prior-art research: [Claude](research-claude.md), [Codex](research-codex.md).
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Importing agents
|
|
2
|
+
|
|
3
|
+
Already have agents for another pi subagent package? Import them.
|
|
4
|
+
|
|
5
|
+
## How
|
|
6
|
+
|
|
7
|
+
- **First run:** in an interactive TUI session, you're offered an import once. (Not in `off` or `orchestration` mode.)
|
|
8
|
+
- **Any time:** `/agents import`.
|
|
9
|
+
|
|
10
|
+
The checkbox picker starts with nothing selected.
|
|
11
|
+
|
|
12
|
+
| Key | Action |
|
|
13
|
+
| ------ | --------------------- |
|
|
14
|
+
| ↑↓ | Navigate |
|
|
15
|
+
| Space | Toggle row |
|
|
16
|
+
| Ctrl+A | Toggle all |
|
|
17
|
+
| Enter | Submit (empty = skip) |
|
|
18
|
+
| Esc | Cancel |
|
|
19
|
+
|
|
20
|
+
## What happens
|
|
21
|
+
|
|
22
|
+
Your **current main model** does the conversion, in your current conversation. There's no converter code and no separate agent.
|
|
23
|
+
|
|
24
|
+
- It receives only the selected file paths, relevant source settings paths, the target schema, your scoped models and tools, and migration instructions.
|
|
25
|
+
- It must explain and get your approval for anything lossy: unsupported features, dropped security restrictions, unavailable models, name collisions.
|
|
26
|
+
- Originals are never modified.
|
|
27
|
+
- New definitions load after the turn, or with `/agents reload`.
|
|
28
|
+
|
|
29
|
+
Requires `opportunistic` mode (it uses the main thread's file tools). TUI only — RPC/print/JSON sessions never prompt.
|
|
30
|
+
|
|
31
|
+
## Where it looks
|
|
32
|
+
|
|
33
|
+
Supported sources: [`@tintinweb/pi-subagents` 0.19.0](https://github.com/tintinweb/pi-subagents/blob/e955e29c51b7a6cce37e1108cd2d6c57a77e151c/src/custom-agents.ts) and [npm `pi-subagents` 0.74.0](https://github.com/nicobailon/pi-subagents/blob/b6bda32f03b7f549623bc404c9be14dca298ddc4/src/agents/agents.ts).
|
|
34
|
+
|
|
35
|
+
- **User:** `<pi-agent-dir>/agents`; recursive `~/.agents` (npm).
|
|
36
|
+
- **Project (trusted only):** `.pi/agents`, `.agents/agents` (tintinweb), recursive `.agents` (npm), including npm's nearest configured ancestor.
|
|
37
|
+
- **Extra:** npm's `PI_SUBAGENT_EXTRA_AGENT_DIRS` and `settings.json` → `subagents.agentScanDirs` / `agentExcludeDirs`.
|
|
38
|
+
|
|
39
|
+
Skipped: `skills`/`.skills` trees, any `SKILL.md`, symlinks, `.chain.md` workflows, installed-package builtins. npm's git-root anchoring isn't reproduced.
|
|
40
|
+
|
|
41
|
+
The offer is remembered in `<pi-agent-dir>/subagent-manager/.import-offered`.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Requested cutoff: **2026-10-03**; freshest dated Arena snapshot discovered: **2026-10-02**. The confirmed five defaults are **architect (absorbs research), reviewer (GPT-only), coder, tasker, writer**. Recommend keeping writing separate from evidence gathering. All names below are advisory `modelSuggestions`, not runtime pins or configuration edits.
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**Historical tool disclosure (research session, before parent-tool bridging):** the parent confirmed Exa MCP search/fetch tools were accessible through its codemode. That child session did **not** expose codemode or those MCP tools and did not inherit parent tools. This research used `web_search` with `provider: "exa"` for Exa-based discovery and `fetch_content` for selected pages, not Exa MCP fetch. Context7 and code-search tools are unavailable here. Read the requested web-research skill. Only this document was written; no source/config edits or git operations were performed.
|
|
8
8
|
|
|
9
9
|
## Advisory modelSuggestions: confirmed five roles
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@ This table records exploratory candidates from the writing/research sweep, not t
|
|
|
22
22
|
|
|
23
23
|
### Research-tool contract for architect
|
|
24
24
|
|
|
25
|
-
The
|
|
25
|
+
The default architect allowlist does not grant MCP retrieval tools. With parent-tool bridging, a custom allowlist or broader Tool Filtering mode can expose registered non-hidden parent tools, with deferred/codemode discovery through child-local codemode. External tools reuse main-session resources/context, not isolated extension instances. When authorized retrieval is unavailable, architect must consume a **supplied research packet** or use **authorized shell retrieval**, including an Exa CLI/API only if it is actually installed/configured and authorized. Do not hardcode unavailable Exa MCP tool names into child instructions, promise nonexistent tool access, or embed credentials. If retrieval is unavailable, explicitly state that limitation and ask for parent-supplied sources. Parent-side codemode Exa access can produce the packet: URLs, dates, fetched passages, contradictions, and unresolved questions. Model ability and retrieval availability are separate decisions.
|
|
26
26
|
|
|
27
27
|
### Five versus six responsibilities
|
|
28
28
|
|
|
@@ -12,14 +12,16 @@ Use a reasoning-capable, tool-reliable model with good code reading, multi-hop r
|
|
|
12
12
|
|
|
13
13
|
## Runtime capability gate — implementation evidence
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Historical evidence at inspected revision `af8424dc621fa38f61058e2e0afa19ab449d084b` (before parent-tool bridging):
|
|
16
16
|
|
|
17
17
|
- [`src/runtime.ts:299-303`](../src/runtime.ts) selects from built-ins and `options.tools`; [`src/index.ts:230`](../src/index.ts) supplies only subagent-manager tools through `toolsFor`.
|
|
18
18
|
- [`src/runtime.ts:311-319`](../src/runtime.ts) sets `noExtensions`, `noSkills`, `noPromptTemplates`, `noContextFiles`, and `noThemes` to true. The parent’s Context7/Exa/Parallel/Perplexity MCP or web extensions are **not inherited**.
|
|
19
19
|
- [`src/runtime.ts:339-343`](../src/runtime.ts) blocks unallowed tool calls; [`src/runtime.ts:350-362`](../src/runtime.ts) passes only selected tools to the SDK session.
|
|
20
20
|
- [`src/config.ts:257-269`](../src/config.ts) validates exact tool names and throws for unavailable names. Adding imagined MCP names to the frontmatter will not enable them and can break spawning.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Current parent-tool bridging includes registered non-hidden main-session tools in the child inventory, subject to exact-name Tool Filtering policies. Permitted MCP/web tools can therefore be selected by a custom allowlist or broader mode; deferred/codemode tools use child-local codemode discovery. External execution reuses main-session resources/context rather than loading fresh extensions or MCP connections, and the parent's policy still applies to bridged callable tools. Skills and project context files are not automatically loaded.
|
|
23
|
+
|
|
24
|
+
The shipped prompt must still not assume MCP tools, `web_enable`, or provider-discovery tools are available under its default local-tool allowlist. Use actually available authorized retrieval, configured shell routes, or a parent-supplied packet containing URLs, dates, versions and fetched passages. If none can answer the assignment, pause with the missing capability instead of pretending model memory is live evidence.
|
|
23
25
|
|
|
24
26
|
The local `web-research` skill recommends complementary search angles, discovery followed by full-page reading, Context7 for library questions, and explicit dates and uncertainty. The local `github` skill prefers `gh` and warns that API writes bypass the local checkout. Those are useful workflow ideas, but their statements that servers/credentials are installed are session-specific and must **not** be copied as assumptions into a portable bundled definition. Neither skill is automatically loaded into this child.
|
|
25
27
|
|
package/docs/settings.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Settings
|
|
2
|
+
|
|
3
|
+
Open with `/agents` (or `/agents settings`). Save with **Ctrl+S**. Changes apply immediately and never cancel running work.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
| Scope | Path |
|
|
8
|
+
| ------- | ------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| Global | `<pi-agent-dir>/subagent-manager/settings.json` (normally `~/.pi/agent/subagent-manager/settings.json`) |
|
|
10
|
+
| Project | `<cwd>/.pi/agent/subagent-manager/settings.json` — trusted projects only; overrides global |
|
|
11
|
+
|
|
12
|
+
All keys are optional. Defaults:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"subagentMode": "opportunistic",
|
|
17
|
+
"modelSelection": "pick-first-scoped",
|
|
18
|
+
"toolFiltering": "allowed",
|
|
19
|
+
"maxLevels": 3,
|
|
20
|
+
"maxConcurrent": 16,
|
|
21
|
+
"maxThreads": 64
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Unknown keys, bad values and symlinked paths produce warnings. An invalid file is ignored as a whole; the previous layer (or defaults) stays in effect.
|
|
26
|
+
|
|
27
|
+
Other packages' settings (e.g. `.pi/subagents.json`) are never read here.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Subagent Mode (`subagentMode`)
|
|
32
|
+
|
|
33
|
+
How much the main model is encouraged to delegate.
|
|
34
|
+
|
|
35
|
+
| Option | What it does | Use when |
|
|
36
|
+
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
|
|
37
|
+
| `off` | Hides subagent tools; injects no guidance. Widget, notifications and import offer are hidden. `/agents` still works. | You want plain pi for a while, without uninstalling. |
|
|
38
|
+
| `opportunistic` (default) | Tools on. Main model delegates only parallelizable or very large tasks; otherwise works directly. | Everyday use. |
|
|
39
|
+
| `orchestration` | Tools on. `/root` delegates **all** execution and only coordinates and synthesizes. | Big multi-part tasks where you want the main context kept clean. |
|
|
40
|
+
|
|
41
|
+
- Orchestration is a prompt policy, not a tool restriction. Workers don't inherit the root-only rule.
|
|
42
|
+
- Agent import needs `opportunistic` (it uses the main thread's file tools).
|
|
43
|
+
|
|
44
|
+
## Model Picking (`modelSelection`)
|
|
45
|
+
|
|
46
|
+
Which model an agent gets when its session starts.
|
|
47
|
+
|
|
48
|
+
| Option | What it does | Use when |
|
|
49
|
+
| ------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
|
|
50
|
+
| `pick-first-available` — **Pick First (available)** | First entry in the type's `models` with configured credentials. | You trust your per-agent lists and want them honored regardless of `/scoped-models`. |
|
|
51
|
+
| `pick-first-scoped` — **Pick First (scoped)** (default) | Same, but the model must also be in the main session's `/scoped-models`. | You use `/scoped-models` as an allowlist (cost, compliance) and want agents to respect it. |
|
|
52
|
+
| `use-current` — **Use Current** | Ignores `models`; uses the main session's current model. | One model for everything, or quick testing. |
|
|
53
|
+
|
|
54
|
+
- Types with no `models` inherit the parent's model in both Pick First modes.
|
|
55
|
+
- Your list's order decides, not the scoped list's order.
|
|
56
|
+
- No match → spawn fails clearly. An empty `/scoped-models` matches nothing.
|
|
57
|
+
- `use-current` always uses the **main** session's model, even for nested or reopened agents. Thinking levels stay per-agent.
|
|
58
|
+
- `modelSuggestions` never affects this.
|
|
59
|
+
- Switching modes doesn't change already-open sessions.
|
|
60
|
+
- Legacy `scopedModelFiltering: true` → `pick-first-scoped`; `false` → `pick-first-available`.
|
|
61
|
+
|
|
62
|
+
## Tool Filtering (`toolFiltering`)
|
|
63
|
+
|
|
64
|
+
How the type's `tools.allow` / `tools.block` lists are applied.
|
|
65
|
+
|
|
66
|
+
| Option | What it does | Use when |
|
|
67
|
+
| -------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------ |
|
|
68
|
+
| `allowed` — **Allowed (except blocked)** (default) | Only `allow` tools, minus `block`. Empty/missing `allow` = no tools. | Least privilege. Recommended. |
|
|
69
|
+
| `all-except-blocked` — **All except blocked** | Ignores `allow`; everything except `block`. | Your definitions only list what to forbid. |
|
|
70
|
+
| `all` — **All** | Ignores both lists. | Trusted local experiments. |
|
|
71
|
+
|
|
72
|
+
- "All" includes child-local built-in and manager tools plus the main session's registered non-hidden tools. Exact-name allow/block lists apply to this inventory.
|
|
73
|
+
- Inherited tools retain exposure and active status. Deferred/codemode tools are discoverable through child-local codemode when permitted; direct tools remain model-facing when active.
|
|
74
|
+
- Built-in tools, manager controls, codemode and tool search remain child-local. External calls reuse main-session resources/context rather than loading fresh extensions or MCP connections. Bridged callable tools remain subject to the main session's tool policy; session-mutating external tools are not necessarily isolated to the child. Skills and project context files are not automatically loaded.
|
|
75
|
+
- Other custom **model-only** tools fail closed: the SDK cannot bridge them while preserving root permission/result hooks. Run those in the main session.
|
|
76
|
+
- UI/command-driven resumes after reopening the main session need a main-session `agent_*` tool call to establish the execution bridge; use `agent_steer` rather than the thread dialog.
|
|
77
|
+
- Applies to newly started sessions (including retained ones reopened after reload). Already-open sessions keep their selected tools, and the main session's tool set is unchanged.
|
|
78
|
+
- Non-default modes can expose `agent_spawn` to types that weren't meant to delegate.
|
|
79
|
+
|
|
80
|
+
## Max Levels (`maxLevels`)
|
|
81
|
+
|
|
82
|
+
Maximum tree depth, counting the main conversation as level 1. Integer 1–32. Default `3` = children and grandchildren.
|
|
83
|
+
|
|
84
|
+
| Value | Effect | Use when |
|
|
85
|
+
| ------------- | ------------------------ | ---------------------------------------------------- |
|
|
86
|
+
| `1` | No new subagents | Block spawning while still resuming existing threads |
|
|
87
|
+
| `2` | Children only | Flat fan-out; simplest to follow |
|
|
88
|
+
| `3` (default) | Children + grandchildren | An `architect` coordinating workers |
|
|
89
|
+
| `4+` | Deeper trees | Large hierarchical teams |
|
|
90
|
+
|
|
91
|
+
Independent roots like `/k` count as level 2, so they can't bypass the limit. Lowering it still lets you resume existing deeper threads.
|
|
92
|
+
|
|
93
|
+
## Max Concurrent (`maxConcurrent`)
|
|
94
|
+
|
|
95
|
+
Threads starting or running at once, across the whole tree. Parents waiting on children count. Default `16`.
|
|
96
|
+
|
|
97
|
+
Lower it for rate limits or cost. Raise it for wide fan-out. When full, spawns **fail** — they don't queue.
|
|
98
|
+
|
|
99
|
+
## Max Threads (`maxThreads`)
|
|
100
|
+
|
|
101
|
+
Total retained threads (any state) per main session. Default `64`.
|
|
102
|
+
|
|
103
|
+
Lower it to keep the tree tidy. Raise it for long sessions with many agents. When full, spawns fail.
|
|
104
|
+
|
|
105
|
+
## Scope
|
|
106
|
+
|
|
107
|
+
The dialog's scope field picks where to save: **global** or **trusted project**.
|
package/docs/threads.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Threads and lifecycle
|
|
2
|
+
|
|
3
|
+
## Paths
|
|
4
|
+
|
|
5
|
+
`/root` is the main pi conversation. Every subagent gets a path under a root.
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
/root
|
|
9
|
+
/root/coding-researcher
|
|
10
|
+
/root/change-file-names
|
|
11
|
+
/root/change-file-names/review
|
|
12
|
+
/k # independent root: no /root history
|
|
13
|
+
/k/l # inherits /k, never /root/...
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- Relative names resolve under the calling agent.
|
|
17
|
+
- A nested parent must already exist.
|
|
18
|
+
- `/root` can address every tree. Children can spawn immediate children and address only their descendants.
|
|
19
|
+
- Dot segments, URL escapes and ambiguous slash spellings are rejected.
|
|
20
|
+
- Name paths after the **task** (`fix-auth`), not the type.
|
|
21
|
+
|
|
22
|
+
## Context
|
|
23
|
+
|
|
24
|
+
A child starts from a snapshot of its **lexical parent** (the path one level up).
|
|
25
|
+
|
|
26
|
+
- **Included:** conversation messages, custom messages, shell output.
|
|
27
|
+
- **Excluded:** the parent's system prompt, unmatched tool calls/results.
|
|
28
|
+
- **Frozen:** later parent turns don't change the child's context.
|
|
29
|
+
- **Model/thinking:** inherited from the parent unless the type sets them.
|
|
30
|
+
- **Independent roots** (`/k`) use the main session's model defaults but **none of its history**.
|
|
31
|
+
|
|
32
|
+
## States
|
|
33
|
+
|
|
34
|
+
| Child action | State | Parent receives |
|
|
35
|
+
| ---------------------- | ----------- | ---------------------------- |
|
|
36
|
+
| Returns a final answer | `completed` | The final answer only |
|
|
37
|
+
| Calls `agent_pause` | `paused` | Status and reason, no answer |
|
|
38
|
+
| Is stopped | `stopped` | — |
|
|
39
|
+
| Errors | `failed` | The error |
|
|
40
|
+
|
|
41
|
+
Every state keeps the session. Any of them can be resumed with `agent_steer`.
|
|
42
|
+
|
|
43
|
+
- `agent_update` reports progress without ending the task.
|
|
44
|
+
- Pause takes effect at the turn boundary. Call it alone, not alongside other tools.
|
|
45
|
+
- `agent_stop` cancels a thread and its working descendants. Resume a stopped ancestor before its descendants.
|
|
46
|
+
- Wait timeouts don't kill children.
|
|
47
|
+
- Progress and completion notices don't force a parent turn; the parent sees them on its next turn.
|
|
48
|
+
|
|
49
|
+
## Persistence
|
|
50
|
+
|
|
51
|
+
**Transcripts.** Each child is a normal pi JSONL session in the main session directory (normally `<pi-agent-dir>/sessions/<encoded-cwd>/`), named like `worker /root/task`, with a `parentSession` link.
|
|
52
|
+
|
|
53
|
+
- In `pi --resume` / `/resume` with **Threaded** sorting and empty search, children nest under parents.
|
|
54
|
+
- Recent/Fuzzy sorting and search show flat rows. Named-only filtering can hide an unnamed parent.
|
|
55
|
+
|
|
56
|
+
**Registry.** The parent saves its thread tree, pending steering and progress mailboxes in its own session.
|
|
57
|
+
|
|
58
|
+
- `/reload` or reopening the parent restores retained threads.
|
|
59
|
+
- Interrupted work comes back **paused**, never auto-restarted.
|
|
60
|
+
- Older transcripts under `<pi-agent-dir>/subagents/<parent-session-id>/` still reopen through the registry.
|
|
61
|
+
|
|
62
|
+
**Resuming.**
|
|
63
|
+
|
|
64
|
+
- Resume the **main session** to keep the managed tree and tool policies.
|
|
65
|
+
- Opening a child directly gives a normal, unmanaged session. Don't do this while the parent is running it.
|
|
66
|
+
- `pi --continue` may pick a recently active child. Use `pi --resume` to choose the main session.
|
|
67
|
+
|
|
68
|
+
**Branching.**
|
|
69
|
+
|
|
70
|
+
- A forked main session gets a fresh registry, so two parents never write the same child transcript.
|
|
71
|
+
- Tree navigation in the parent restores that branch's registry and each child's transcript leaf.
|
|
72
|
+
- Resuming from an older checkpoint branches the child file; newer branches stay intact.
|
|
73
|
+
- In-memory main sessions don't survive process exit.
|