Repository navigation
Description
Problem or use case
In a Pi native chat session, a subagent started by the default (awaited/foreground) subagent call never appears anywhere in the UI — not as a child row, and not as something you can open. The same run shows up as a plain tool row only.
Environment: Orca 1.4.261 (macOS, Apple silicon), Pi 1.5.2 (@earendil-works/pi-coding-agent), pi-subagents 0.89.0, Orca's managed ~/.pi/agent/extensions/orca-agent-status.ts present and current (it contains orca-subagents).
Why a foreground run cannot reach the roster (from reading the 1.4.261 bundle and the installed packages):
- The chat adapter consumes the roster from
setStatuswith a private key. Inout/main/chunks/structured-agent-session-host-assembly-*.js,pF.receive()returns early unlesse.method === 'setStatus' && e.statusKey === 'orca-subagents', then parsesstatusTextas{ subagents: [{ id, agentType?, description? }], ended: { [id]: 'completed' | 'failed' | 'aborted' } }. The events are published as child-work evidence throughpublishChildWorkEvidence. - The managed Pi extension
orca-agent-status.tsis the publisher. Its chat path isif (process.env.ORCA_STRUCTURED_SESSION && !isOmpRuntime()) nativeChatUi = ctx.ui→nativeChatUi.setStatus('orca-subagents', text). It feeds that roster from only fourpi.eventslisteners:task:subagent:lifecyclesubagent:async-startedsubagent:async-completesubagent:process-terminal
pi-subagentsdocuments those as async-only events (docs/observability.md→ "Events": "Async events:subagent:async-started,subagent:async-complete,subagent:jobs-changed"), andSUBAGENT_ASYNC_STARTED_EVENTis emitted only fromsrc/runs/background/async-execution.js. An awaitedsubagent({ task })call therefore publishes nothing, even though it is a real child session with a real transcript.task:subagent:lifecycle— the one listener that looks like it could cover foreground runs — is emitted by nothing in a stock install: a recursive grep for that string returns no hit in Pi 1.5.2's own package or anywhere under~/.pi/agent/npm/node_modules.- Workflow children are filtered separately:
isVisibleSubagent()requiresdetails.get(id)?.workflow !== true, so keyed children of an async workflow root are dropped even when their root publishes. That is the same filter described in [Bug]: Async workflow workers are missing from sidebar child rows #39120 for the terminal sidebar.
So today the roster only ever contains detached async runs. Foreground/awaited subagents — the default and the most common case in chat — are invisible by construction.
Second gap: even an async child row has nothing to open. Adding a pi branch to the AI Vault subagent scan is small, because Pi already records the link. The child session header carries parentSession (the parent's session file), and pi-subagents writes children to a deterministic path: <sessions root>/<cwd slug>/<parent session base name>/<agent id>/run-<n>/session.jsonl. That is documented in pi-subagents docs/observability.md → "Sessions", and I confirmed it on disk. Orca's scan currently knows only two agents:
- Count gate:
s.agent === 'claude' ? await o.g(filePath) : s.agent === 'omp' ? await t.t(filePath) : null—piyieldsnull, sosubagentTranscriptCountis 0 and the AI Vault never renders a Subagents section. - Enumeration:
wo(e){ return e.agent === 'claude' ? fo({ parentFilePath }) : So({ parentFilePath }) }— the non-Claude branch is the OMP${parentWithoutExt}/scandirectory walk.
Proposed solution
- Roster for foreground runs. Two options, both using data Orca or the extension already has:
- Derive child rows from the RPC stream the chat adapter already parses:
tool_execution_start/tool_execution_endfortoolName === 'subagent', mappingcallId→ child row and using the tool args (agent,task/description) for the label. This needs no cooperation frompi-subagents. - Or subscribe to
pi-subagents' polling-free surface instead of the async-only events:subagent:jobs-changedplus a read of thestatuscommand (ping.capabilitiesadvertises it; seepi-subagentsdocs/extension-api.md→ "Refresh a host view without polling"), andsubagent:child-statusfor keyed workflow children.
- Derive child rows from the RPC stream the chat adapter already parses:
- Let the row open the child conversation. Add a
picase to the AI Vault subagent scan: read the first JSONL header of the candidate child session, takeparentSession, and attach the child when it points at the parent transcript. Child sessions are ordinary Pi sessions, so the existing Pi parser renders them as-is. - Drop or repoint the
task:subagent:lifecyclelistener so it does not look like coverage it does not have.
Alternatives or additional context
- A
pi-subagents-independent path is preferable: an extension-owned roster depends on which subagent package the user installed, which is exactly how [Feature]: Support @tintinweb/pi-subagents events on the Pi hook route #28894 (a different@tintinweb/pi-subagentspackage) ended up needing its own hook route. - Related: [Feature]: Show Pi subagents in native chat (pi --mode rpc sessions) #38210 (closed, the original "show Pi subagents in native chat"), [Bug]: Async workflow workers are missing from sidebar child rows #39120 (workflow workers missing from sidebar child rows), [Bug]: Pi native chat never installs Orca's managed Pi extensions, so subagent rows from #42448 cannot appear #43291 (closed; managed extensions were not installed for chat launches before 1.4.262 — not the cause here, the file is present).
- Workaround today: read the child transcript from disk, e.g.
base=$(basename "$PI_SESSION_FILE" .jsonl); ls -d "$(dirname "$PI_SESSION_FILE")/$base"/*/run-*/session.jsonl, thenpi --session <path>in a terminal tab. - I have not run an async (
async: true) subagent in a chat session to confirm a row appears there; the gap above is argued from the publisher's listener set, which excludes foreground runs entirely.
Activity
qszfy666 commentedon Nov 26, 2026
A heads-up that an implementation for this is open as #45085, in case it saves someone else from starting the same work.
What it does:
subagent({ task })call now publishes a child row in native chat, exactly like the detached runs already did, and the row settles in the same snapshot it appears in (an awaited call's whole life happens between two roster posts).tool_execution_end→result.details.results[](agent,sessionName,exitCode,stopped/timedOutper child) rather than from the event bus, so it needs no cooperation frompi-subagentsand no version-dependent subscription. Thetask:subagent:lifecycleevent named earlier in this issue has no emitter in Pi 1.5.2 /pi-subagents0.89, which is why the roster never saw these runs.Current state: the branch is kept merged up to
main(mergeable, 0 behind as of today), the added tests fail without the change, andpnpm check:changedpasses locally. Two things are not in our hands: the repository's own CI needs a maintainer approval to run on a fork PR, and CodeRabbit has been skipping its re-review on the last pushes — so the head currently hascleanplus a local gate behind it rather than a fresh bot pass.Scope, to be explicit: the rows are native-chat only (the terminal hook payload is unchanged), and the scanner walks a bounded depth under the parent's stem directory. Happy to split or narrow the PR if that makes review easier.
asked by @qszfy666 via 卜卜