anomalyco / anomalyco/opencode
Session cost excludes subagent cost (TUI sidebar, opencode stats, /export)
@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:
- Run a session that dispatches several subagents (Task/subagent calls).
- Note the cost shown in the TUI sidebar/footer (also
opencode statsand/export). - Sum the per-message cost of the root session and every subagent (walk
parent_idin the SQLite history viaopencode db). - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.