Skip to content

Count omp and pi profile sessions in the agent usage collectors - #9546

Open
This-Is-NPC wants to merge 1 commit into
omacom:quattrofrom
This-Is-NPC:fix/agent-usage-omp-profiles
Open

Count omp and pi profile sessions in the agent usage collectors#9546
This-Is-NPC wants to merge 1 commit into
omacom:quattrofrom
This-Is-NPC:fix/agent-usage-omp-profiles

Conversation

@This-Is-NPC

Copy link
Copy Markdown

The problem

omp --profile=<name> (and pi's equivalent) relocates the whole agent tree under <base>/profiles/<name>/. The Claude and Codex collectors only ever scanned <base>/agent/sessions:

roots = [
  Path.home() / ".pi" / "agent" / "sessions",
  Path.home() / ".omp" / "agent" / "sessions",
]

So a subscription driven entirely through a profile is invisible to the agents panel — no tokens by day, no tokens by model, no prompt or session counts. On my machine omp --profile=codex had 916 session files with 125,638 openai-codex assistant messages under ~/.omp/profiles/codex/agent/sessions, none of it counted.

What made it hard to spot is that the Codex tab was not empty: it was showing the opencode fallback numbers only, which quietly stop the day you switch away from opencode.

The fix

pi_session_roots() discovers the profile roots alongside the default one, in both collectors. Sessions are already keyed by file path, so a profile adds sessions instead of double-counting the default root, and a missing or unreadable profiles/ directory leaves today's behavior untouched.

The helper is duplicated across the two scripts, matching how cache_root() and read_fresh_json() are already duplicated there.

Verification

Real data on an Arch box running omarchy 4.0.2, omarchy-agent-usage-codex --force, before → after:

before after
totalPrompts 71,833 134,265
totalSessions 1,305 2,221
todayPrompts 0 1,505
todayTotalTokens 0 114,008,332

The last two days of recentDays went from 0 / 0 to real numbers. The Claude collector picked up the profile's Anthropic subagent traffic the same way (10 more prompts today, in my case).

Both scanner tests grow a profile session and assert it lands in todayTotalTokens and modelUsage. agent-usage-codex-scanner-test.sh, agent-usage-claude-scanner-test.sh, agent-usage-claude-limits-test.sh, agent-usage-fireworks-scanner-test.sh, agent-usage-update-test.sh and agents-rename-migration-test.sh all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_014zFbJcDEEpV5BAmsH6kAB3

`omp --profile=<name>` (and pi's equivalent) relocates the whole agent
tree under <base>/profiles/<name>/. The Claude and Codex collectors only
ever scanned <base>/agent/sessions, so a subscription driven entirely
through a profile was invisible to the agents panel: no tokens by day, no
tokens by model, no prompt or session counts.

Discover the profile roots alongside the default one. Sessions are keyed
by file path, so a profile adds sessions instead of double-counting the
default root, and a missing or unreadable profiles directory leaves the
existing behavior untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014zFbJcDEEpV5BAmsH6kAB3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant