Skip to content

Fix OpenCode Zen usage filtering#135

Merged
kargnas merged 1 commit into
mainfrom
codex-opencode-zen-usage-filter
May 17, 2026
Merged

Fix OpenCode Zen usage filtering#135
kargnas merged 1 commit into
mainfrom
codex-opencode-zen-usage-filter

Conversation

@kargnas
Copy link
Copy Markdown
Member

@kargnas kargnas commented May 17, 2026

Summary

  • Filter OpenCode Zen totals to model rows with the opencode/ and opencode-go/ provider prefixes.
  • Log the excluded non-Zen OpenCode stats amount so inflated aggregates are visible during diagnostics.
  • Update OpenCode Zen provider tests for the current multiline opencode stats --models output.

Root Cause

opencode stats --days 7 --models reports one aggregate across all configured OpenCode providers. The provider was using that aggregate as OpenCode Zen pay-as-you-go usage, so Anthropic/OpenRouter/OpenAI/etc. usage could be counted as Zen usage.

Notes

  • I checked the local OpenCode CLI help and found no provider filter for stats.
  • I checked the current OpenCode docs and did not find a usable Zen-specific usage API.
  • The CLI model breakdown does expose provider-prefixed model rows, so the app can isolate Zen usage without removing tracking.

Validation

  • make setup
  • swiftlint lint CopilotMonitor/CopilotMonitor/Providers/OpenCodeZenProvider.swift CopilotMonitor/CopilotMonitorTests/OpenCodeZenProviderTests.swift
  • xcodebuild test -project CopilotMonitor/CopilotMonitor.xcodeproj -scheme CopilotMonitor -destination 'platform=macOS' -only-testing:CopilotMonitorTests/OpenCodeZenProviderTests
  • xcodebuild clean build -project CopilotMonitor/CopilotMonitor.xcodeproj -scheme CopilotMonitor -configuration Debug -destination 'platform=macOS'
  • Launched the Debug app and confirmed log output: Excluded $997.37 of non-Zen OpenCode stats usage from OpenCode Zen totals
  • CLI smoke output returned Zen-only usage: "cost" : 2.2988999999999997

OpenCode stats reports one aggregate across providers, so OpenCode Zen now keeps only opencode and opencode-go model rows and logs the excluded non-Zen amount for diagnostics.

Constraint: OpenCode has no usable Zen usage API or provider filter in opencode stats

Rejected: Removing OpenCode Zen tracking | model breakdown rows provide enough signal to isolate Zen usage

Confidence: high

Scope-risk: narrow

Directive: Keep Zen totals tied to opencode and opencode-go model prefixes unless OpenCode adds a first-party provider usage API

Tested: swiftlint provider and tests; xcodebuild OpenCodeZenProviderTests; xcodebuild clean build; launched Debug app and confirmed OpenCode Zen exclusion log

Not-tested: GitHub Actions CI

Co-authored-by: OmX <omx@oh-my-codex.dev>
@kargnas kargnas changed the title [codex] Fix OpenCode Zen usage filtering Fix OpenCode Zen usage filtering May 17, 2026
@kargnas kargnas marked this pull request as ready for review May 17, 2026 07:00
@kargnas kargnas merged commit 6b87325 into main May 17, 2026
12 of 13 checks passed
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