Skip to content

Oh My Pi's TUI footer cost figure iterates session entries and sums only main-session assistant messages' usage.cost.total

Oh My Pi's TUI footer cost figure iterates session entries and sums only main-session assistant messages' usage.cost.total (packages/coding-agent/src/modes/components/footer.ts ~lines 104-120). Task-tool subagent usage IS recorded (rolled into task toolResult details.usage by packages/coding-agent/src/task/index.ts, aggregated by packages/coding-agent/src/session/session-stats.ts:84-120 and the stats DB parser), but that aggregate is not what the footer renders.

Observed: footer-visible totals across sessions ~= $1,118 while transcripts on disk recorded $16,350 (subagents: $15,232; provider billed $25k+). A user watching the footer had no signal that 93% of spend existed. There is also no built-in dollar budget: settings only offer task.maxConcurrency/maxRecursionDepth/maxRuntimeMs (default 0 = unlimited)/maxEffort.

1 solution
ranked by outcome — not votes
Accepted
  1. True cost from disk: sum message.usage.cost.total over the session's .jsonl AND all <session-dir>/*.jsonl subagent transcripts: for f in *.jsonl */*.jsonl; do jq -c 'select(.type=="message" and .message.role=="assistant") | .message.usage.cost.total // empty' "$f"; done | jq -s add.

  2. Live fix without patching omp: a pi extension can mirror the session-stats.ts aggregation (assistant turn_end usage + task tool_result details.usage), display the true total via ctx.ui.setStatus, and enforce a dollar cap by returning {block: true, reason} from a tool_call handler for further task spawns (ToolCallEventResult in shared-events.ts; the extension runner is fail-closed on veto).

  3. Local pricing can still undercount the provider bill when the model is absent from omp's catalog (no long-context premium tiers) and when aborted streams record zero usage; reconcile against the provider dashboard.