No description
  • TypeScript 100%
Find a file
DenisSud fa16f05b94 minimal subprocess-based delegation — drop SDK in-process sessions
Rewrite the extension to spawn a fresh pi subprocess per delegation
instead of using in-process AgentSession with inherited chat history.

- Spawn pi --mode json -p --no-session --no-skills --no-extensions
- No inherited context, no agent configs, no frills
- Core logic adapted from amosblomqvist/pi-subagents
- Old approach archived in task-compaction/

Changes:
  README.md                        — document new approach
  extensions/subagent/index.ts     — rewrite to ~70 lines
  package.json                     — update description
2026-06-07 20:45:01 +03:00
extensions/subagent minimal subprocess-based delegation — drop SDK in-process sessions 2026-06-07 20:45:01 +03:00
.gitignore V1: one-shot subagent tool 2026-06-02 12:18:27 +03:00
LICENSE updating some stuff 2026-06-02 12:45:09 +03:00
package.json minimal subprocess-based delegation — drop SDK in-process sessions 2026-06-07 20:45:01 +03:00
README.md minimal subprocess-based delegation — drop SDK in-process sessions 2026-06-07 20:45:01 +03:00

su-subagent — Minimal Delegation Extension for Pi

A minimal delegation extension for the pi coding agent. Adds a single delegate(taskPrompt) tool that spawns a fresh, isolated pi subprocess to complete a sub-task.

Installation

pi install /path/to/su-subagent

Usage

The parent agent gets a single capability:

delegate(taskPrompt: string) -> string

The sub-agent is a plain, non-configured pi agent with no inherited context. It runs autonomously with standard built-in tools (read, bash, write, edit, etc.). Its output is returned as text — no file handoff.

Example delegation:

delegate(taskPrompt="Find all TODO comments in the repository and categorize them")
delegate(taskPrompt="Investigate why tests in src/auth.test.ts are failing")
delegate(taskPrompt="Refactor utils.js: extract the CSV parser into its own module")

How It Works

Parent Agent
    │
    ├─ tool call: delegate(taskPrompt)
    ▼
Spawn `pi --mode json -p --no-session --no-skills --no-extensions "Task: ..."`
    │
    ▼
Parse JSON events from stdout, extract final assistant message
    │
    ▼
Return output text as tool result

Each sub-agent runs as an isolated OS process — a completely fresh pi instance. No context leakage. No session files. No in-process state sharing.

When to Delegate

Use delegate for Don't use delegate for
Multi-step file exploration Simple lookups (use grep/read directly)
Code refactoring in a single file Design or architectural decisions
Running tests and diagnosing failures Anything needing user interaction
Research across many files Work dependent on conversation state
Parallel independent investigations Planning or decision-making

Core Logic

Adapted from amosblomqvist/pi-subagents but simplified to its essence:

  • One default sub-agent — no agent profiles, no frontmatter, no config
  • Subprocess isolation — each delegation spawns a pi process
  • JSON mode--mode json -p for machine-readable output
  • No frills — no skills, no extensions, no session persistence, no custom rendering

License

MIT