Skip to content

[Feature] Treat subagents as first-class observable sessions: attach, monitor, manage individually #2131

Description

@kaile9

What feature would you like to see?

Make subagents first-class observable sessions: while a subagent (or swarm member) runs, the user should be able to attach to it like a session — watch its live event stream, and manage it individually (stop / steer / resume) — instead of it being an opaque one-shot call that only reports back at the end.

Today:

Related existing work: #667 (live task output), #1957 (swarm progress), PR #1139 (/agents status command), PR #1210 (session debugging timeline), PR #1645 (stop individual swarm members from web UI). None of them offers attach-to-session semantics; this request is for the missing primitive underneath all of them.

Implementation sketch (from reading the source)

The pieces mostly exist; what is missing is exposing them per-subagent:

  1. Event source — every subagent already emits AgentEvents (turn.started, thinking.delta, tool.call.started, …). In-process subscription exists (Agent.onEvent, added by the feat(agent-core): stream live subagent events into background task output buffer #667 fix); on the wire, kap-server's sessionEventBroadcaster already fans out session events, and every subagent has a stable agentId (session metadata, subagent.spawned events). Add an agent-scoped subscription (transcript subscribe_v2 recently landed for sessions — the same channel filtered by agentId gives a live subagent transcript for free).
  2. Roster — the live subagent roster is already carried in session snapshots (fix(kap-server): carry the live subagent roster in the session snapshot #1623) and the web agents dock (fix(web): dedupe background subagent rows in the agents dock #1754). Promote it to a first-class list in the TUI (the direction PR feat(tui): add agents status command #1139 takes with /agents) where each entry opens the attach view.
  3. Attach view — render the agent's AgentEvent stream with the same components the TUI already uses for the main agent (the redesigned subagent card, feat: redesign the subagent card #1345, and the vis timeline, feat(vis): full session debugging — tasks/cron, execution timeline, retries & tool progress #1210, are prior art). Attach/detach is a pure view operation; the subagent keeps running either way.
  4. Management — steer = Agent(resume=agentId, ...) (exists today); stop = the same abort path TaskStop uses for agent tasks, extended to swarm members by wiring each SubagentBatch attempt controller to a member id (PR fix: stop individual swarm members from the web UI #1645 does this for the web UI).

Suggested first increment: (1) + (2) read-only — a /agents panel where selecting a running subagent shows its live transcript. That alone closes #1957's "did it hang?" problem and needs no new control surface.

Additional information

Filed after a source read of packages/agent-core (v1) and kap-server — I'm not a regular contributor, so the sketch above may miss a simpler seam (for example, reusing the background-task output streaming from #667 instead of a new subscription channel). Very happy to adjust the proposal around whatever shape maintainers prefer.

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