Skip to content

Sidebar cost should include subagent session spend #21818

Description

@stefanmatar

Description

The sidebar Context section only sums cost from assistant messages in the current session. When subagents are spawned (via the Task tool), their cost is not included in the displayed total. This makes the reported cost misleading during subagent-heavy workflows -- the actual API spend can be significantly higher than what the sidebar shows.

The session.children() API already exists and returns child sessions. The sidebar cost calculation could aggregate costs across the parent and all child sessions.

Current behavior

Sidebar shows cost from messages.reduce((sum, x) => sum + (x.role === "assistant" ? x.cost : 0), 0) which only covers the current session.

Expected behavior

Sidebar should show total cost across the parent session and all child sessions, with an optional breakdown (e.g. $0.47 main + $0.31 subs (3)).

Related

OpenCode version

1.4.3

Operating System

macOS

Terminal

Ghostty

Activity

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions