Skip to content

burn summary --subagent-tree: consume SessionRelationshipRecord (replace TurnRecord-only path) #109

@willwashburn

Description

@willwashburn

Context

burn summary --subagent-tree <session> already ships (PR #64, closed #8) but reconstructs the tree solely from TurnRecord.subagent.{agentId,parentAgentId,parentToolUseId,subagentType,description} — see packages/cli/src/commands/summary.ts:30-38, 167-174 and packages/analyze/src/subagent-tree.test.ts.

PR #77 landed a normalized SessionRelationshipRecord substrate exactly so this view doesn't have to keep reconstructing relationships from per-turn fields. From the PR's deferred-work list:

Consumer CLI surfaceburn summary --subagent-tree, burn diagnose, burn waste --patterns, burn summary --by-relationship. The execution graph is now persisted, so these can be built on top.

Issue #42's acceptance also explicitly calls this out:

The graph is rich enough that #8 can consume it instead of reconstructing everything from isSidechain and parentUuid alone.

Today the ledger persists relationship rows (via appendRelationships / queryRelationships from PR #77) but the subagent-tree CLI never reads them. That keeps Codex / OpenCode subagent trees blocked on each parser duplicating the per-turn field population, and means the tree command can't show fork / continuation / subagent-of-subagent chains the new graph captures.

Proposal

Migrate burn summary --subagent-tree (and the aggregateBySubagent / subagent-tree builder in @relayburn/analyze) to build the tree from SessionRelationshipRecords (joined to TurnRecord cost data), with TurnRecord.subagent retained as a fallback for sessions ingested before the graph was populated.

  • @relayburn/analyze gains a builder that takes (turns, relationships) and produces the same tree shape consumers already render.
  • The renderer continues to roll up cost / token totals per node from the underlying TurnRecords, joining child turns via agentId.
  • When relationships is empty for a session (legacy ingest), fall back to today's TurnRecord.subagent-only path so existing data still renders.
  • Surface the four relationshipTypes (root / subagent / fork / continuation) in the rendered output, not just subagents — at minimum, an annotation when a node's relationship type is non-subagent.

Acceptance criteria

Out of scope

Refs

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