Skip to content

Session cost excludes subagent cost (TUI sidebar, opencode stats, /export) #45417

Description

@stephenmathieson

Summary: The reported session cost does not include the cost of subagents the session spawned. For any workflow that fans out subagents (e.g. a multi-subagent review command), the displayed cost is far below what was actually billed.

Repro:

  1. Run a session that dispatches several subagents (Task/subagent calls).
  2. Note the cost shown in the TUI sidebar/footer (also opencode stats and /export).
  3. Sum the per-message cost of the root session and every subagent (walk parent_id in the SQLite history via opencode db).
  4. The true total is much higher than the reported figure.

Actual: Only the root session cost is reported; subagent cost is excluded.
Expected: Session cost aggregates the root session plus all subagents, recursively.
Impact: Cost attribution/comparison is wrong for any subagent-heavy workflow.

Context: Appears to be the same limitation as #11027 (auto-closed for inactivity, not fixed) and RFC #12377 (closed); related to #31032. Opening a fresh issue per the stale-bot suggestion on #11027.

Workaround: Sum per-message cost from the SQLite history with a recursive walk over parent_id.

Environment: opencode 1.18.x, macOS.

Activity

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

Metadata

Metadata

Assignees

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