You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(pi): show subagents in Pi native chat - #42448
Pi can start helper agents ("subagents"). When Pi runs in a terminal pane, Orca already lists them. When the same Pi runs as a native chat, they were invisible. Now the chat shows them in the same subagent rows Claude and Codex chats use, and each row settles as completed, failed or stopped when the helper finishes.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$74
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$74
Prod
9
$\color{#1a7f37}{\Huge{\mathbf{+}}}$132
$\color{#cf222e}{\Huge{\mathbf{−}}}$5
$\color{#1a7f37}{\Huge{\mathbf{+}}}$127
What Changed
Before: in a Pi native chat, subagents started by an extension (pi-subagents, or anything emitting task:subagent:lifecycle) appeared only as plain tool-call rows. No subagent rows, no "N working", no settling.
After: the chat shows "Kicked off N subagents" with one row per child, each working → completed / failed / stopped, and the run summary ("Ran 2 subagents · 1 failed") once they finish.
Mechanism:
Orca's managed Pi extension (orca-agent-status.ts) already tracks the subagent roster for terminal panes and posts it to the hook endpoint. Native chat strips that endpoint on purpose, so the roster never left Pi.
In a structured session (ORCA_STRUCTURED_SESSION set), the extension now also publishes the same roster, plus each child's own outcome, as a setStatus('orca-subagents', …) line. That is the RPC-mode channel the background-work bridge already uses.
The Pi RPC adapter consumes that status line (PiRpcSubagents) before decoration is dropped and turns it into child-work evidence (live / ended / session-ended on exit). It hands the evidence to the host through onChildWorkEvidence, the same path the ACP, Codex and Claude adapters use, so the existing subagent rows render it.
Terminal panes never have the structured marker, so their behaviour is unchanged.
Why
The roster already exists in the extension every Pi user gets from Orca, so this reuses it instead of adding a second tracker. Supersedes #39564 (thanks @zzvictor). That PR read inventory through one third-party package's snapshot API (pi-subagents 0.87+), added user-visible "inventory unavailable" warnings to every Pi chat without that package, and didn't cover other producers. The root cause is that native chat never received the managed extension's roster. Fixing that covers every producer the extension already understands, with no new UI or copy.
Follow-up, not in this PR: Pi's blocking extension_ui_request dialogs (select / confirm / input / editor) are already answered by PiRpcDialogCallbacks. The issue's "untested" note about them is outdated, and nothing more is needed for subagents.
Visual Proof
Real Pi 1.5.2 in a hidden dev build of this branch, with a fake model server and the issue's demo extension (two children; scout completes after 8 s, reviewer fails after 15 s).
Running
One finished
All settled
Before: the same chat shows no subagent rows (as reported in the issue). I confirmed the cause directly: real pi --mode rpc without the structured marker emits no orca-subagents lines, so main has nothing to render.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
macOS. Ran real pi --mode rpc (1.5.2) with the generated extension: one status line per roster change, with endings completed / failed. Same run without ORCA_STRUCTURED_SESSION: no lines.
Hidden dev build, Pi native chat end to end (screenshots above).
src/main/pi/rpc/rpc-subagents.test.ts drives the real generated extension and the adapter decoder together. It checks a runner that exits before its own completion, and that a stopped child settles as cancelled. Also checked by mutation: it fails if the extension only records endings for still-active children.
pnpm test src/main/pi --maxWorkers=2 and pnpm check:changed pass.
Risk
Level: Low
Only Pi native chats change, and only when the managed status extension is installed. Orca installs it on terminal spawn, the same condition terminal rows already depend on.
The riskiest part is outcome mapping. A child whose runner exits before it reports shows as unknown briefly, until its own completion refines it. The host already accepts a definite ending after an unknown one.
Older adapters drop the new status line as decoration. Older extensions simply show no rows.
Plain revert.
AI Disclosure
Review
Two review rounds (Codex and Claude). Fixed: late completions after runner-exit pruning were lost as "unknown"; stopped and paused pi-subagents runs were shown as failed; awaited workflow children that never self-report stayed "working". Round 2 Codex was clean.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Cross-platform: no new paths or processes; the status line rides Pi's own stdio.
Remote/SSH: works wherever the native chat's Pi runs, using that host's managed extension install.
Mobile: rows are journaled like Codex/Claude subagent rows.
Folder workspaces: no git assumptions.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Native chat strips the hook endpoint, so the managed extension's subagent
roster never reached Pi chats. In structured sessions the extension now
publishes the roster as a status line, and the Pi RPC adapter turns it into
child-work evidence for the existing subagent rows.
The managed Pi extension now publishes native-chat subagent roster updates through captured UI status. The Pi RPC adapter consumes those status frames and converts roster changes and session endings into child-work evidence. The session callback forwards evidence to the current host when one is available. Tests cover overlapping child runs, their completion outcomes, and session-end evidence.
Severity of issue fixed: Medium
Merge Risk: Moderate · up to d197e
Pi subagents now appear in native chat. A late event from a replaced Pi session could be applied to the new session's subagent rows, and a malformed status frame could briefly mark running subagents as ended. Both cases are narrow, but the first should be addressed or consciously accepted before merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(pi): show subagents in Pi native chat" names the main change: Pi native chat now shows subagent rows, fed by the managed extension's roster through the RPC adapter. It is concise, uses…
Description check
The description follows the repository template. It has ELI5, What Changed (before/after plus mechanism), Why (with alternatives and the superseded PR), a linked issue (Fixes #38210), Visual Proof (th…
Linked Issues check
Issue #38210 asks that Pi subagents reported by extensions appear in Orca native chat, as they do in terminal panes. The PR meets this with a different mechanism than the issue proposes. The issue sta…
Out of Scope Changes check
All changed files map to the native-chat subagent feature: - agent-status-subagent-roster-source.ts and agent-status-handler-source.ts: publish the roster in structured sessions and capture the native…
Full details: Title check
Explanation
The title "feat(pi): show subagents in Pi native chat" names the main change: Pi native chat now shows subagent rows, fed by the managed extension's roster through the RPC adapter. It is concise, uses conventional-commit form, and matches the changeset and PR objectives.
Full details: Description check
Explanation
The description follows the repository template. It has ELI5, What Changed (before/after plus mechanism), Why (with alternatives and the superseded PR), a linked issue (Fixes #38210), Visual Proof (three images with a before note), Testing with checkboxes and platform details, Risk with level and revert path, Review, and Notes and Checklist. The AI Disclosure section is empty, but the template says to fill it in only for non-team contributors, so this is acceptable. The Linked Issue section is complete.
Full details: Linked Issues check
Explanation
Issue #38210 asks that Pi subagents reported by extensions appear in Orca native chat, as they do in terminal panes. The PR meets this with a different mechanism than the issue proposes. The issue states that either proposed approach would work. Evidence at head:
src/main/pi/managed-extensions/agent-status/agent-status-subagent-roster-source.ts publishes the visible roster and child endings through setStatus('orca-subagents', text) when ORCA_STRUCTURED_SESSION is set and the runtime is not OMP. It publishes on start, child removal, runner exit, and roster reset.
src/main/pi/rpc/rpc-subagents.ts (PiRpcSubagents.receive) consumes that status line before decoration is dropped. It emits live evidence for listed children and ended evidence for children that left the roster. It maps completed to succeeded, failed to failed, and aborted to cancelled. end() emits session-ended when children remain listed.
The PR reports that rpc-subagents.test.ts covers the generated extension and decoder together. I did not inspect that test file, so this result rests on the reported test description and the inspected implementation.
The issue's dialog observation is not an objective of this PR. The PR states that PiRpcDialogCallbacks already handles those dialogs. No coding requirement from #38210 remains unmet. Remaining uncertainty: the Pi 1.5.2 runtime behavior and the test assertions were not independently executed.
Full details: Out of Scope Changes check
Explanation
All changed files map to the native-chat subagent feature:
agent-status-subagent-roster-source.ts and agent-status-handler-source.ts: publish the roster in structured sessions and capture the native chat UI on session_start.
agent-status-session-boundary-source.ts: publishes the roster after restoring parked subagents.
agent-status-extension-test-harness.ts: adds the optional ui.setStatus type needed by the new publication path.
rpc-runtime-registration.ts, rpc-session.ts, rpc-session-contracts.ts, rpc-dialog-callbacks.ts: pass the onChildWorkEvidence path and wire PiRpcSubagents into the dialog callback chain, which is required to deliver the evidence to the host.
rpc-subagents.ts and rpc-subagents.test.ts: the decoder and its tests.
No unrelated behavior change was found. The dialog-callbacks constructor change is a required wiring change for the new onChildWork parameter, not a separate dialog feature.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Reject non-object JSON roots before changing child state.
After child A becomes live, a matching frame with statusText: "null" parses successfully. Line 30 treats it as an empty roster, so Lines 49–60 emit ended(A, unknown). Arrays and scalar roots have the same effect.
Validate the parsed root as a plain object before calculating roster differences. Reject invalid roots without changing this.live. Based on learnings, external JSON state requires plain-object validation and fail-closed rejection of invalid roots.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Pi can start helper agents ("subagents"). When Pi runs in a terminal pane, Orca already lists them. When the same Pi runs as a native chat, they were invisible. Now the chat shows them in the same subagent rows Claude and Codex chats use, and each row settles as completed, failed or stopped when the helper finishes.
What Changed
task:subagent:lifecycle) appeared only as plain tool-call rows. No subagent rows, no "N working", no settling.Mechanism:
orca-agent-status.ts) already tracks the subagent roster for terminal panes and posts it to the hook endpoint. Native chat strips that endpoint on purpose, so the roster never left Pi.ORCA_STRUCTURED_SESSIONset), the extension now also publishes the same roster, plus each child's own outcome, as asetStatus('orca-subagents', …)line. That is the RPC-mode channel the background-work bridge already uses.PiRpcSubagents) before decoration is dropped and turns it into child-work evidence (live/ended/session-endedon exit). It hands the evidence to the host throughonChildWorkEvidence, the same path the ACP, Codex and Claude adapters use, so the existing subagent rows render it.Why
The roster already exists in the extension every Pi user gets from Orca, so this reuses it instead of adding a second tracker. Supersedes #39564 (thanks @zzvictor). That PR read inventory through one third-party package's snapshot API (
pi-subagents0.87+), added user-visible "inventory unavailable" warnings to every Pi chat without that package, and didn't cover other producers. The root cause is that native chat never received the managed extension's roster. Fixing that covers every producer the extension already understands, with no new UI or copy.Linked Issue
Fixes #38210
Follow-up, not in this PR: Pi's blocking
extension_ui_requestdialogs (select/confirm/input/editor) are already answered byPiRpcDialogCallbacks. The issue's "untested" note about them is outdated, and nothing more is needed for subagents.Visual Proof
Real Pi 1.5.2 in a hidden dev build of this branch, with a fake model server and the issue's demo extension (two children; scout completes after 8 s, reviewer fails after 15 s).
Before: the same chat shows no subagent rows (as reported in the issue). I confirmed the cause directly: real
pi --mode rpcwithout the structured marker emits noorca-subagentslines, so main has nothing to render.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
macOS. Ran real
pi --mode rpc(1.5.2) with the generated extension: one status line per roster change, with endingscompleted/failed. Same run withoutORCA_STRUCTURED_SESSION: no lines.Hidden dev build, Pi native chat end to end (screenshots above).
src/main/pi/rpc/rpc-subagents.test.tsdrives the real generated extension and the adapter decoder together. It checks a runner that exits before its own completion, and that a stopped child settles as cancelled. Also checked by mutation: it fails if the extension only records endings for still-active children.pnpm test src/main/pi --maxWorkers=2andpnpm check:changedpass.Risk
Level: Low
AI Disclosure
Review
Two review rounds (Codex and Claude). Fixed: late completions after runner-exit pruning were lost as "unknown"; stopped and paused pi-subagents runs were shown as failed; awaited workflow children that never self-report stayed "working". Round 2 Codex was clean.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)