MoonshotAI / MoonshotAI/kimi-code
[Feature] Treat subagents as first-class observable sessions: attach, monitor, manage individually
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
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:
- A background
Agenttask exposes only its output buffer. (#667 and PR #2130 add a live text transcript to that buffer — but it is still a log you poll, not a session you can attach to.) - Foreground subagents render progress only as a transient grouped card; once it scrolls away there is no way back to the subagent's own timeline.
- Swarm members (
AgentSwarm) are worse: they never register background tasks at all, so there is no per-member output, no per-member status, and no per-member stop — see #1957 ("Swarm无法查看进度"). - Management is all-or-nothing: interrupting cancels every sibling; you cannot stop or steer one subagent.
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:
- Event source — every subagent already emits
AgentEvents (turn.started,thinking.delta,tool.call.started, …). In-process subscription exists (Agent.onEvent, added by the #667 fix); on the wire, kap-server'ssessionEventBroadcasteralready fans out session events, and every subagent has a stableagentId(session metadata,subagent.spawnedevents). Add an agent-scoped subscription (transcript subscribe_v2recently landed for sessions — the same channel filtered byagentIdgives a live subagent transcript for free). - Roster — the live subagent roster is already carried in session snapshots (#1623) and the web agents dock (#1754). Promote it to a first-class list in the TUI (the direction PR #1139 takes with
/agents) where each entry opens the attach view. - Attach view — render the agent's
AgentEventstream with the same components the TUI already uses for the main agent (the redesigned subagent card, #1345, and the vis timeline, #1210, are prior art). Attach/detach is a pure view operation; the subagent keeps running either way. - Management — steer =
Agent(resume=agentId, ...)(exists today); stop = the same abort pathTaskStopuses for agent tasks, extended to swarm members by wiring eachSubagentBatchattempt controller to a member id (PR #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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading packages/agent-core and kap-server, especially Agent.onEvent, sessionEventBroadcaster, transcript subscribe_v2, and the session snapshots used by /agents. Trace how agentId and SubagentBatch attempts are represented; the first increment is done when selecting a running subagent in /agents opens a live, read-only transcript without affecting its execution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100