galaxyproject / galaxyproject/loom

Support pi subagents in Loom + Orbit

Open
#115 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14
Forks
12
Avg merge
6d 5h
Merged PRs (30d)
17

Description

## Background

pi 0.75 ships a subagent example extension (`packages/coding-agent/examples/extensions/subagent/`) that registers a `subagent` tool. Each invocation spawns a separate `pi` subprocess with its own context window, model, and tool allowlist. Agents are declared as markdown + YAML frontmatter under `~/.pi/agent/agents/*.md` (user) or `.pi/agents/*.md` (project, gated by confirm). Three modes: `single`, `parallel` (max 8, concurrency 4), `chain` (with `{previous}` substitution between steps).

PR earendil-works/pi#4710 (landed in 0.75.4) returns real per-task output to the parent (was truncated to 100-char previews).

## What Loom needs

1. **Vendor or load the tool.** Either include pi's example extension or copy it into `extensions/loom/` so we control discovery paths — e.g. `~/.loom/agents/*.md` and project-local `.loom/agents/*.md`. Lets us ship Galaxy-flavored agents (scout, planner, QC reviewer, …) with sensible tool allowlists.

2. **Orbit rendering.** Pi's `renderCall`/`renderResult` are TUI-only (return `@earendil-works/pi-tui` components). In Orbit, a subagent run arrives on the existing event stream as `tool_call` with `toolName === \"subagent\"` and `details: SubagentDetails` carrying per-child `{agent, task, exitCode, messages, usage}`. No dedicated `subagent_start`/`subagent_end` events — `tool_execution_update` streams in as each child finishes. The renderer switch in `app/src/renderer/app.ts` needs a new case that renders one card per child, probably as an artifact tab so long scout runs don't bury chat.

3. **Galaxy agent presets.** Candidate first-cut agents:
- **scout** — wide search across IWC + Toolshed, locked to `galaxy_search_*`/`galaxy_search_iwc`/`Read`
- **planner** — chains scout results into a draft plan section
- **reviewer** — audits a completed invocation against the plan

## Sharp edges

- **50 KB cap per task return** and subagent stdout doesn't stream tokens to the parent LLM — one shot at end. Long Galaxy exploration will hit the cap. UX needs an escape hatch: have the subagent write a longer report to a file in the analysis dir, return a pointer.
- **Cost / load.** Each subagent is a fresh `pi` subprocess with the configured model. Parallel mode = N× tokens and meaningful local CPU/RAM. Orbit's usage badge should reflect aggregated subagent usage.
- **Tool allowlist per agent** — good fit for Galaxy; lock scouts to discovery tools only.
- **Discovery paths.** Decide: support pi's `~/.pi/agent/agents/` directly, or fork to `~/.loom/agents/` to avoid stepping on other pi installs the user may run.

## Scope suggestion

Two PRs:
1. Loom (brain): vendor the subagent tool with Loom-flavored discovery paths + one or two example Galaxy agents under `extensions/loom/agents/`.
2. Orbit (shell): add the `toolName === \"subagent\"` renderer case + artifact-tab affordance + usage aggregation.

## References

- pi-mono: `packages/coding-agent/examples/extensions/subagent/` (index.ts, agents.ts, README.md)
- earendil-works/pi#4710 (parallel output fix, in 0.75.4)
- pi extension lifecycle: `packages/coding-agent/docs/extensions.md`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with packages/coding-agent/examples/extensions/subagent/ (index.ts, agents.ts, README.md) and the pi extension lifecycle docs, then inspect app/src/renderer/app.ts. Define the Loom tool and agent discovery paths, Galaxy presets, and Orbit rendering and usage behavior; done means the proposed Loom and Orbit changes are covered by two reviewable PRs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.