Skip to content

[Feature]: Show awaited (foreground) Pi subagents in native chat, and let the row open the child transcript #43861

Open

Description

@qszfy666

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):

  1. The chat adapter consumes the roster from setStatus with a private key. In out/main/chunks/structured-agent-session-host-assembly-*.js, pF.receive() returns early unless e.method === 'setStatus' && e.statusKey === 'orca-subagents', then parses statusText as { subagents: [{ id, agentType?, description? }], ended: { [id]: 'completed' | 'failed' | 'aborted' } }. The events are published as child-work evidence through publishChildWorkEvidence.
  2. The managed Pi extension orca-agent-status.ts is the publisher. Its chat path is if (process.env.ORCA_STRUCTURED_SESSION && !isOmpRuntime()) nativeChatUi = ctx.ui → nativeChatUi.setStatus('orca-subagents', text). It feeds that roster from only four pi.events listeners:
    • task:subagent:lifecycle
    • subagent:async-started
    • subagent:async-complete
    • subagent:process-terminal
  3. pi-subagents documents those as async-only events (docs/observability.md → "Events": "Async events: subagent:async-started, subagent:async-complete, subagent:jobs-changed"), and SUBAGENT_ASYNC_STARTED_EVENT is emitted only from src/runs/background/async-execution.js. An awaited subagent({ task }) call therefore publishes nothing, even though it is a real child session with a real transcript.
  4. 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.
  5. Workflow children are filtered separately: isVisibleSubagent() requires details.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 — pi yields null, so subagentTranscriptCount is 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}/scan directory walk.

Proposed solution

  1. 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_end for toolName === 'subagent', mapping callId → child row and using the tool args (agent, task/description) for the label. This needs no cooperation from pi-subagents.
    • Or subscribe to pi-subagents' polling-free surface instead of the async-only events: subagent:jobs-changed plus a read of the status command (ping.capabilities advertises it; see pi-subagents docs/extension-api.md → "Refresh a host view without polling"), and subagent:child-status for keyed workflow children.
  2. Let the row open the child conversation. Add a pi case to the AI Vault subagent scan: read the first JSONL header of the candidate child session, take parentSession, 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.
  3. Drop or repoint the task:subagent:lifecycle listener so it does not look like coverage it does not have.

Alternatives or additional context

Activity

  1. qszfy666 commented on Nov 26, 2026

    @qszfy666
    Author

    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:

    • An awaited 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).
    • Agent Session History lists that child's transcript for a Pi parent, and the existing row actions open it.
    • The data comes from tool_execution_end → result.details.results[] (agent, sessionName, exitCode, stopped/timedOut per child) rather than from the event bus, so it needs no cooperation from pi-subagents and no version-dependent subscription. The task:subagent:lifecycle event named earlier in this issue has no emitter in Pi 1.5.2 / pi-subagents 0.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, and pnpm check:changed passes 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 has clean plus 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 卜卜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions