Skip to content

[Feature]: Show the current session's subagents and background tasks, with stop and transcript view #439

Open

Description

@ayush5harma

Rescoped after review on #443: the current session's agents only, built on the Agent SDK, with no Claude Code UI and no private job files.

Problem Statement

A session's subagents and background tasks are visible only as their tool calls in the transcript, where a detached launch shows a ↗ icon and a later result. There is no single place to see which of them are still running, what each is doing, or how much it has used. A running task cannot be stopped from claude-rs, and a subagent's own transcript cannot be read.

Proposed Solution

Add a view of the active session's subagents and background tasks, built on the Agent SDK the bridge already uses:

  • Source of truth: the task lifecycle state the bridge already normalizes from task_started / task_progress / task_updated / task_notification, held in Rust as sdk_inventory.tasks and on the Detached tool calls. The view projects that state and keeps no second store.
  • Progress data: forward the token and tool-use counts, last_tool_name and the progress summary from task_progress as fields of the existing TaskMetadata.
  • Stop: a stop_task command calls Query.stopTask(). The resulting stopped notification flows through the existing task path.
  • Subagent transcript: a get_subagent_messages command calls getSubagentMessages(), and listSubagents() shows which subagents have a transcript.
  • UI: placement, command name and any footer indicator are to be agreed in feat(agents): open Claude Code's agent view with Left and show agent status in the footer #443 before implementation.

Out of scope: other sessions, Claude Code's global background-session roster, and Claude Code's own agent view.

Alternatives Considered

Checklist

  • I have searched existing issues and discussions to ensure this is not a duplicate

Activity

  1. changed the title [-][Feature]: Open Claude Code's agent view with Left on an empty prompt, and show background agent status in the footer[/-] [+][Feature]: Show the current session's subagents and background tasks, with stop and transcript view[/+] on Oct 10, 2026
  2. srothgan commented on Oct 13, 2026

    @srothgan
    Owner

    Following up on your replacement design in #443: let's use this issue for the design discussion and keep a future PR focused on reviewing the agreed implementation.

    The active-session scope and SDK-based direction make sense: include both subagents and background tasks, including background shell jobs. Use the task state we already have, with no separate CLI invocation, private job-file access, global roster, or second task store.

    On your UI questions:

    • Give the active session's subagents and background tasks a separate tab/view, grouped by task type, while reusing the existing configuration display and navigation logic.
    • Use /task to open it, and support access through Left Arrow navigation. Please describe the focus and key behavior, including what happens while editing a draft, so we can settle the interaction here.
    • A footer counter for running subagents and background tasks, including background shell jobs, is acceptable. Derive it from the existing normalized lifecycle state and count each execution once, even when it also appears as a detached tool call. A saved transcript or completed task must not count as running.

    Your proposed SDK operations are the right place to start: the task lifecycle events for live state, Query.stopTask() for requesting cancellation, and listSubagents() / getSubagentMessages() for transcript discovery and inspection. Keep cancellation acknowledgement separate from the eventual stopped state, and keep transcript reads separate from live task status.

    Before implementation, please resolve the task-to-transcript association you raised: do listSubagents() agent IDs match local_agent task IDs in the pinned runtime, and what does the view show when a task has no verified transcript association? Also check which metadata is actually missing: lifecycleMetadata() in tasks.ts already retains progress summary.

    Have your agent read AGENTS.md, docs/src/architecture.md, and the relevant declarations in agent-sdk/node_modules/@anthropic-ai/claude-agent-sdk/sdk.d.ts: SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKTaskNotificationMessage, listSubagents(), getSubagentMessages(), and Query.stopTask(). Build on tasks.ts and task_links.ts, and update the Rust and bridge contracts together where needed.

    Please continue the discussion here with the proposed navigation, counter semantics, and runtime ID findings before opening the replacement PR.

  3. ayush5harma commented on Oct 13, 2026

    @ayush5harma
    ContributorAuthor

    #456 did not follow this issue. I'll close it, and open nothing for this until the points below are agreed. @srothgan please review these

    Runtime ID findings

    Measured on SDK 0.3.288 / runtime 2.1.288 with one subagent and one run_in_background Bash command, in two runs that agreed.

    • A listSubagents() id equals the local_agent task_id from task_started, and it differs from the Agent call's tool_use_id.
    • A running subagent was listed before it completed, but not at the first poll about 2 s after task_started. So a running task can briefly have no transcript.
    • The background shell task (task_type: local_bash) never appears in listSubagents(). background_tasks_changed listed only the shell task, never the foreground subagent.
    • stopTask(task_id) on the shell task produced task_updated (killed), then task_notification (stopped) about 3.8 s later, both with the same task_id.
    • The stopTask promise itself rejected with "Query closed before response received", because the single-prompt query ended first. I'd confirm the acknowledgement on a long-lived query before relying on it.
    • Not covered: nested or backgrounded subagents, resume.

    Missing metadata

    Nothing the view needs is missing. lifecycleMetadata() keeps every field these runs sent: task_type, subagent_type, is_backgrounded, output_file, end_time, the terminal status and summary. Only task_progress's usage (tokens, tool uses, duration) and last_tool_name are dropped; last_tool_name is only logged. I'd add them only if you want them on a row.

    Navigation

    • Opening it: a Tasks tab in the existing fullscreen view, grouped by task type, reusing its tab and list navigation. /task opens it on that tab.
    • Left Arrow: opens it only when the composer is empty and no menu is open. With a draft, Left moves the cursor as today.
    • Keys in the view: Up/Down select, Enter opens a verified transcript, s stops a running task, r re-checks transcripts. Esc returns to the composer with any draft intact.

    Counter

    The footer counts running local_agent and local_bash lifecycle tasks, once per task_id, including a task that is also a detached tool call. Completed, failed and stopped tasks and saved transcripts never count. The counter is hidden at zero.

    Stop and transcripts

    Stop is offered only for a running lifecycle task_id. A row shows Stopped only when the lifecycle messages say so, never on the request. A row gets a transcript only when its local_agent task_id matches a listed id. Until then it shows "no transcript", and nothing is inferred.

    Open questions

    1. Should other task types (local_workflow, MCP tasks) appear and count?
    2. Should finished tasks stay listed for the whole session?
    3. Should the id equality get a contract test against the pinned SDK?
  4. srothgan commented on Oct 13, 2026

    @srothgan
    Owner
    1. Do we want a subagent/agent/task list?
    2. I want a new full screen view. Not part of the current config/mcp/usage view but a new dedicated full screen, just matching copying some logic. I dont want to see Agents next to MCP in the tabs list

    Maybe only subagents list? Since we already have a dedicated function we can call and use

  5. ayush5harma commented on Oct 13, 2026

    @ayush5harma
    ContributorAuthor
    1. Yes, one list for the current session, grouped by task type: subagents (local_agent) and background shells (local_bash). "Agent" and "subagent" are the same rows here, so that is two groups today, and more only if you want other task types. Selecting a subagent shows its transcript in the same screen.
    2. Agreed: a dedicated full-screen Tasks view with its own title, not a tab next to MCP. /task, or Left Arrow from an empty composer, opens it, and Esc returns to the composer with the draft intact. It would reuse the list, selection and scroll helpers the config view uses, without being part of that view.

    The rest of the proposal stays as written. Does this match what you have in mind? I'll wait for your go before opening a PR.

  6. srothgan commented on Oct 13, 2026

    @srothgan
    Owner

    Go ahead, but use /agents since we only do subagents now

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

Metadata

Metadata

Assignees

Labels

area: agent-sdkBun bridge and Agent SDK integrationstatus: discussionNeeds community input or design discussiontype: featureNew feature or capability

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions