Skip to content

Nest subagent sessions inside parent session tile #19

@amahpour

Description

@amahpour

Problem

Subagent sessions currently appear as separate tiles in the dashboard (or are filtered out entirely via id NOT LIKE 'agent-%' in db.py). This makes it hard to see the relationship between a parent session and its subagents. Other tools like Agentsview don't show subagents at all — we have the data, but we're not presenting it effectively.

Proposed Change

Nest subagent sessions within their parent session's tile instead of treating them as independent entries.

Investigation Findings

Hook event payloads (confirmed)

SubagentStart provides:

Field Description
session_id Parent session's ID
agent_id Subagent's unique ID (e.g., agent-abc123)
agent_type Agent type (e.g., "Explore", "Plan", "Bash")
cwd Current working directory
transcript_path Path to parent session's transcript

SubagentStop additionally provides:

Field Description
agent_transcript_path Path to subagent's own transcript file
last_assistant_message Subagent's final response text

Key finding: The parent-child relationship is explicit — session_id is the parent, agent_id is the child. No inference needed.

Current behavior

  • SubagentStart/SubagentStop events are received but agent_id and agent_type are ignored
  • Subagent sessions get their own row in sessions with id prefixed agent-
  • get_all_active_sessions() filters them out: AND id NOT LIKE 'agent-%'
  • No parent_session_id column exists in the schema

Implementation Plan

Backend

  1. DB migration: Add parent_session_id TEXT and agent_type TEXT columns to sessions table
  2. Hook processing (server/hooks.py): On SubagentStart, create/update the subagent session using agent_id as the session ID, storing session_id as parent_session_id and extracting agent_type
  3. On SubagentStop: Update the subagent session with status, store last_assistant_message as task description or activity preview
  4. API (server/routes/api.py): Nest subagent sessions under their parent in /api/sessions response (add subagents: [...] array to each parent session)
  5. Remove filter: Stop filtering out agent-* sessions from the main query (they'll be nested instead)
  6. Watcher (server/watcher.py): Optionally parse agent_transcript_path for subagent transcripts

Frontend

  1. Session tile: Add a collapsible "Subagents" section inside the parent session card
  2. Compact subagent rows: Show status dot, agent_type, description/display_name, duration, and cost
  3. Real-time updates: Ensure WebSocket session_update messages correctly update nested subagent state within the parent tile

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions