Skip to content

feat(fork): show Oh My Pi spend on the usage page - #10

Merged
Coriou merged 2 commits into
mainfrom
feat/omp-cost-tracking
Oct 27, 2026
Merged

Coriou merged 2 commits into
mainfrom
feat/omp-cost-tracking

Conversation

@Coriou

@Coriou Coriou commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Problem

Usage had no Oh My Pi source. OMP spend never appeared in the daily/hourly history, the model
breakdown, cache savings, or the provider split, even though the composer already shows the live
session cost OMP reports over ACP.

Fix

  • Fork-local transcript reader (apps/server/src/provider/Drivers/ompUsage.ts) over OMP's native
    session JSONL: per-message usage.cost.total, the file's session header for resume state, and a
    dedupeKey that collapses the verbatim entries a fork copies.
  • Subagent transcripts are separate sessions beside the session file, so they are counted from their
    own files; the parent's task aggregate is ignored to avoid counting that spend twice. This is the
    same rule OMP's own omp-stats uses.
  • rateModel carries the bare model id OMP stores (the rate table keys on it) while the
    provider-prefixed id stays the display model. Zero-cost records fall back to T3's model pricing.
  • Store resolution mirrors OMP: --session-dir, PI_CODING_AGENT_SESSION_DIR, profile
    (--profile / OMP_PROFILE / PI_PROFILE), PI_CODING_AGENT_DIR, an existing XDG root, then
    PI_CONFIG_DIR and the default root.
  • Registered on the OMP driver, "omp" added to UsageProviderKind, web/mobile label and colour,
    and a docs/user/usage.md line.
  • The OMP adapter gains a regression test that its end-of-turn usage_update cost reaches the
    provider thread (no production change for that part).

Evidence

Usage page in a dev server reading this machine's real OMP history:

  • before: 8 providers, $6,097.84, 2,344 sessions
  • after: Oh My Pi — 17 sessions, $45.84 (0.7% of cost), $6,143.68, 2,361 sessions

Captures: t3code-docs/media/omp-usage-before.webp and omp-usage-after.webp (kept outside this
repo, as PR assets are not committed).

Reader against real data, in review:

  • matches an independent ungated parse on 967 of 969 settled files (the two differ because they were
    still growing)
  • one real parent session sums to $4.912741, identical to the cumulative cost T3 already stored for
    that provider thread
  • streaming and linewise records are identical across all 2,303 chunk-straddling lines, including one
    14.6 MB line
  • a cold parse of 969 files takes 4.8 s

vp run check:changed: format, lint, knip ×2, graphql, typecheck (30 packages) and the affected
tests are green.

Notes

  • Older clients silently drop unknown omp buckets and sources while still decoding the summary, so
    USAGE_CONTRACT_VERSION does not need a bump (upstream added "muse" the same way).
  • Pointing Pi and Oh My Pi at one store with PI_CODING_AGENT_DIR counts those sessions under both
    providers; documented in the user guide.

Model: openrouter/deepseek/deepseek-v4.1-flash-1017 · Harness: Oh My Pi (Tx Code)
Review: Opus 5.5 via Claude Code, effort medium — mergeable.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Oct 27, 2026
Usage had no Oh My Pi source, so OMP spend never reached the daily/hourly history, model breakdown, or cache savings.

Read OMP's native session JSONL: per-message usage carries the same cost OMP reports over ACP, and each file's session header supplies the session identity that resume needs. Subagent transcripts are separate sessions beside the session file, so they are counted from their own files; the parent's task aggregate is ignored to avoid counting that spend twice.

Records keep the bare model id as rateModel, because the rate table keys on it, while the provider-prefixed id stays the display model. Zero-cost records fall back to T3's model pricing like the other providers.

Store resolution follows OMP's own precedence: --session-dir, PI_CODING_AGENT_SESSION_DIR, profile (--profile / OMP_PROFILE / PI_PROFILE), PI_CODING_AGENT_DIR, an XDG root, then PI_CONFIG_DIR and the default root.

The OMP adapter also gains a regression test that its end-of-turn usage_update cost reaches the provider thread.
@Coriou
Coriou force-pushed the feat/omp-cost-tracking branch from b08522a to 1c3fcc4 Compare October 27, 2026 20:27
@Coriou
Coriou merged commit d1e3d5f into main Oct 27, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant