MoonshotAI / MoonshotAI/kimi-code

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

Open
#2,131 1 comment 3 reactions 0 assignees View on GitHub

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 Agent task 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:

  1. 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'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 (#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.
  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, #1345, and the vis timeline, #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 #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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.