Add Google and xAI models.dev pricing lookup - #2377
Conversation
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 5:14 AM ET / 09:14 UTC. ClawSweeper reviewWhat this changesAdds models.dev pricing lookup and local Pi-session cost reporting for Gemini, Vertex AI, and Grok, including support through the Merge readinessKeep open: current main and v0.49.2 still limit Pi-session cost reports to Codex and Claude, so this remains a distinct feature. The implementation and isolated CLI proof are credible, but the head is merge-dirty and needs an owner-selected landing order and a fresh rebase. Priority: P2 Review scores
Verification
How this fits togetherCodexBar parses local Pi/OMP JSONL sessions into daily token-cost reports, using the cached models.dev catalog for provider/model rates. Those reports feed provider cost snapshots in the app and the flowchart LR
A[Pi and OMP session logs] --> B[Session cost scanner]
B --> C[Provider and model mapping]
C --> D[models.dev pricing cache]
D --> E[Daily cost report]
E --> F[App and CLI cost output]
Decision needed
Why: The three open PRs modify the same cost-scanner, pricing, and capability-gate surfaces; the owner explicitly requested a chosen sequence, and the correct sequence cannot be inferred safely from source alone. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Choose one provider-pricing PR as the first landing, rebase this mapping onto current main while retaining the recent cost-pricing behavior, then refresh focused tests, repository checks, and the isolated CLI transcript. Do we have a high-confidence way to reproduce the issue? Not applicable: this is an additive feature rather than a report of broken behavior; the PR instead provides an isolated built-CLI after-fix transcript with synthetic Pi sessions. Is this the best way to solve the issue? Yes, conditionally: provider-scoped catalog lookup is a narrow fit for the existing cost pipeline and its fixture tests cover the new routing, but it must be rebased and revalidated against current main. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a90dfed5c264. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (31 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
2d19620 to
b99340f
Compare
73dfd89 to
3b034fa
Compare
|
@steipete Rebased onto latest main and added a regression test confirming that a scoped Codex home still suppresses Pi-session merging. Ready for review. |
87ad75c to
1eac100
Compare
…DevCostUSD out of enum to satisfy lint limits
The hash commit was dropped during the rebase because the generated file conflicted with main. Regenerate it now that all pricing changes are applied.
ClawSweeper flagged that a custom codexHomePath should continue to suppress merging default Pi-session spend. Add a test verifying ambient scans merge Pi while scoped scans do not.
1eac100 to
46c997f
Compare
|
@steipete — this PR has been rebased onto latest main and is ready for review. Thanks! |
After rebasing the Google/xAI models.dev pricing work, ProviderArchitectureGatekeeperTests failed because new provider-specific branches (Gemini, Grok, VertexAI) appeared in shared cost code and existing allowlist anchors shifted. Add '// Provider-specific by design:' markers at each provider-owned dispatch point, update the gatekeeper's hardcoded supportsTokenSnapshot set and shifted suppressed references, and remove obsolete CostUsageFetcher/PiSessionCostScanner allowlist entries whose anchors no longer match. Closes provider-architecture gatekeeper failures on the Google/xAI rebase.
Summary
models.devlookup seam for Google/Gemini, Vertex AI, and xAI/Grok providers.google, Vertex AI togoogle-vertexwithgooglefallback, and Grok toxai.codexbar cost.Proof
models.dev.git grep -n -E "gemini-3\.5-flash|gemini-3\.1-pro-preview|gemini-3\.1-flash-lite|grok-4\.5|grok-4\.3|grok-4\.20" origin/main -- Sources Tests docshttps://models.dev/api.jsonshowed:google:gemini-3.5-flash/ Gemini 3.5 Flash / input 1.5 / output 9 / cache_read 0.15 / context 1048576google:gemini-3.1-pro-preview/ Gemini 3.1 Pro Preview / input 2 / output 12 / cache_read 0.2 / context 1048576google:gemini-3.1-flash-lite/ Gemini 3.1 Flash Lite / input 0.25 / output 1.5 / cache_read 0.025 / context 1048576xai:grok-4.5/ Grok 4.5 / input 2 / output 6 / cache_read 0.3 / context 500000xai:grok-4.3/ Grok 4.3 / input 1.25 / output 2.5 / cache_read 0.2 / context 1000000xai:grok-4.20-0309-reasoning/ Grok 4.20 (Reasoning) / input 1.25 / output 2.5 / cache_read 0.2 / context 1000000models.devfixture data with separategoogle,google-vertex, andxairates, then verifiesPiSessionCostScanner.loadDailyReportcomputes provider-scoped costs for Pi JSONL rows:google/gemini-3.5-flash: 160 tokens, cost0.0006015google-vertex/gemini-3.1-pro-preview: 160 tokens, cost0.0008171, proving Vertex uses the Vertex catalog before Google fallbackxai/grok-4.5: 160 tokens, cost0.000503.pi/agent/sessions/2026-07-28T10-00-00-000Z_google-xai-proof.jsonlcontaining only assistant rows. No real account files, Keychain, or browser cookies were read. Command shape:HOME=[temp] CFFIXED_USER_HOME=[temp] XDG_CONFIG_HOME=[temp]/.config XDG_CACHE_HOME=[temp]/.cache .build/debug/CodexBarCLI cost --provider <provider> --format json --pretty --refresh{ "provider" : "gemini", "source" : "local", "sessionTokens" : 160000, "sessionCostUSD" : 0.6015, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "gemini-3.5-flash", "totalTokens" : 160000, "cost" : 0.6015 }] }] } { "provider" : "vertexai", "source" : "local", "sessionTokens" : 160000, "sessionCostUSD" : 0.802, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "gemini-3.1-pro-preview", "totalTokens" : 160000, "cost" : 0.802 }] }] } { "provider" : "grok", "source" : "local", "sessionTokens" : 160000, "sessionCostUSD" : 0.503, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "grok-4.5", "totalTokens" : 160000, "cost" : 0.503 }] }] }Verification
CLANG_MODULE_CACHE_PATH=/private/tmp/codexbar-clang-cache swift test --disable-sandbox --scratch-path /Users/mosaab/Documents/Projects/CodexBar/.build --filter PiSessionCostScannerTests: 19 tests passed.CLANG_MODULE_CACHE_PATH=/private/tmp/codexbar-clang-cache swift test --disable-sandbox --scratch-path /Users/mosaab/Documents/Projects/CodexBar/.build --filter 'provider lookup resolves current Google and xAI models': 1 test passed.git diff --check: clean.make checkcompleted generated parser hash, package/docs/locales checks, SwiftFormat lint mode, and SwiftLint strict with 0 violations, then exited on the sandbox-only macOS plist cache write permission error after lint shutdown.No live provider probes, browser-cookie imports, or Keychain reads were run.