Skip to content

FE-899: Subagent integration#239

Merged
lunelson merged 1 commit into
nextfrom
ln/fe-899-subagent-integration
Jun 22, 2026
Merged

FE-899: Subagent integration#239
lunelson merged 1 commit into
nextfrom
ln/fe-899-subagent-integration

Conversation

@lunelson

@lunelson lunelson commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Brunch-owned subagent registration backed by sealed in-process SDK child sessions.
  • Define bundled proposer/scout/researcher agents with explicit tool allowlists and no ambient discovery.
  • Harden parser, caller-shape, concurrency, abort, and docs contracts.

Verification

  • npm run verify

@lunelson lunelson marked this pull request as ready for review June 19, 2026 15:26
Copilot AI review requested due to automatic review settings June 19, 2026 15:26
@cursor

cursor Bot commented Jun 19, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Child sessions can use cwd-scoped read tools and web fetch/search when enabled via opt-in deps; isolation is sealed and write/bash are excluded, but mis-gating at startup could expose delegation in production sessions.

Overview
Adds a default-off, opt-in subagent Pi tool (D44-L) that runs isolated work in in-process sealed SDK child sessions—not subprocesses— and returns each child’s last assistant message to the parent.

The new subagents extension loads TypeBox-validated markdown agents (scout, researcher, proposer) with explicit tool allowlists (read-only FS / web / none), runs them via runSubagent with bounded concurrency, abort propagation, and fail-soft error results. createBrunchPiExtensions accepts optional subagents deps to register the tool and add it to the opt-in active-tool channel (with dev introspection tools); loadBrunchSubagents in the app layer assembles sealed deps from pi-settings. Startup wiring (e.g. BRUNCH_DEVcreateBrunchPiExtensions) is documented but not included in this diff. Build copies bundled agents/*.md and config.json into dist.

Reviewed by Cursor Bugbot for commit 7655623. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 03f3ee9. Configure here.

Comment thread src/.pi/extensions/subagents/index.ts
Comment thread src/.pi/extensions/subagents/session.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces the first Brunch “subagents” implementation as a default-off Pi extension: bundled markdown agent definitions + config, a sealed in-process SDK child-session runner, and an opt-in subagent tool wired through createBrunchPiExtensions when runtime deps are provided.

Changes:

  • Adds .pi/extensions/subagents with agent/config loaders, sealed child-session execution (runSubagent), registrar (registerBrunchSubagents), and a comprehensive test suite.
  • Adds an app-layer composition root (loadBrunchSubagents) to assemble sealed deps without src/app imports from .pi/.
  • Extends createBrunchPiExtensions to optionally register/advertise the subagent tool via the existing opt-in tool channel; updates build assets copying.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/app/pi-subagents.ts App composition root that loads bundled subagent definitions/config and returns sealed deps.
src/app/pi-extensions.ts Adds optional subagent opt-in wiring: allowed-tool opt-in union + conditional registrar registration/export.
src/.pi/extensions/subagents/subagents.test.ts Tests for parsing/loading/config, model resolution, tool planning, semaphore, registrar behavior, and sealed child-session E2E via faux provider.
src/.pi/extensions/subagents/session.ts Implements sealed SDK child-session runner (resolveSubagentModel, planSubagentTools, runSubagent).
src/.pi/extensions/subagents/README.md Topology/hand-off documentation for the subagents extension and wiring guidance.
src/.pi/extensions/subagents/index.ts Registers the subagent tool, fan-out execution with bounded concurrency, and formats results.
src/.pi/extensions/subagents/config.ts TypeBox-validated loader/parser for bundled subagent config.json.
src/.pi/extensions/subagents/agents/scout.md Bundled read-only “scout” agent definition.
src/.pi/extensions/subagents/agents/researcher.md Bundled “researcher” agent definition (web tools).
src/.pi/extensions/subagents/agents/proposer.md Bundled tool-less “proposer” agent definition.
src/.pi/extensions/subagents/agents.ts Markdown frontmatter + body parser and directory loader for bundled agent definitions.
src/.pi/extensions/README.md Updates extensions index to reflect the now-real subagents extension.
package.json Extends build:pi-assets to ship subagent markdown agents + config into dist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +60 to +66
const separator = line.indexOf(':');
if (separator === -1) {
throw new Error(`malformed frontmatter line (expected "key: value"): ${rawLine}`);
}
const key = line.slice(0, separator).trim();
fields[key] = line.slice(separator + 1).trim();
}
Comment on lines +3 to +6
> **Status (handoff doc):** mechanism **built + verified**, but **not yet wired
> into startup** — the `subagent` tool is present-but-dead in every build until a
> launch path passes `subagents` to `createBrunchPiExtensions(...)`. This README
> is intentionally fatter than the sibling topology READMEs because the feature
Comment on lines +130 to +143
async execute(_toolCallId, params: Params, signal, _onUpdate, ctx) {
const requested =
params.tasks ?? (params.agent && params.task ? [{ agent: params.agent, task: params.task }] : []);
if (requested.length === 0) {
return {
content: [
{
type: 'text' as const,
text: 'subagent requires either { agent, task } or { tasks: [{ agent, task }, ...] }.',
},
],
details: { results: [] },
};
}
@lunelson lunelson changed the title bung in first version of brunch subagents FE-899: Subagent integration Jun 22, 2026
@graphite-app graphite-app Bot changed the base branch from ln/fe-861-generalized-capture-2 to graphite-base/239 June 22, 2026 11:40
@lunelson lunelson force-pushed the ln/fe-899-subagent-integration branch from 03f3ee9 to 7655623 Compare June 22, 2026 12:27
@lunelson lunelson force-pushed the graphite-base/239 branch from 30ccdf9 to 1f0392b Compare June 22, 2026 12:27
@graphite-app graphite-app Bot changed the base branch from graphite-base/239 to next June 22, 2026 12:28
@graphite-app

graphite-app Bot commented Jun 22, 2026

Copy link
Copy Markdown

Merge activity

  • Jun 22, 12:28 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

@lunelson lunelson merged commit cf0e513 into next Jun 22, 2026
12 checks passed
@lunelson lunelson deleted the ln/fe-899-subagent-integration branch June 22, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants