anomalyco / anomalyco/opencode

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

Open
#45,417 6 comments 12 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 27, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.