Skip to content

fix(usage): price Magpie model ids and read Magpie limits - #141

Merged
nullStack65 merged 1 commit into
release/native-0.1.10from
fix/clo-951-magpie-usage-reporting
Nov 20, 2026
Merged

nullStack65 merged 1 commit into
release/native-0.1.10from
fix/clo-951-magpie-usage-reporting

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

Deploy: fleet

Problem and change

Kameron's usage panel (2026-11-20) showed three Magpie reporting bugs, tracked on the usage panel issue (CLO-951, https://linear.app/closura/issue/CLO-951/usage-panel-remove-stale-opencode-instances-explain-agy).

  1. codex/gpt-6.1-sol (and claude/..., grok/...) reported "no known rates" while the bare id was priced. Magpie prefixes the model id with the harness, which is not a rate-table provider. Rate lookup now prices a codex/, claude/ or grok/ prefix at the bare model's rate when that rate is unambiguous, and leaves a genuinely ambiguous name unpriced.
  2. Magpie-routed OpenCode instances probed OpenCode Go and surfaced "OpenCode Go could not read usage". An instance whose OPENCODE_FLAGS routes to another provider now reports that it routes through a custom model provider instead of probing. Codex already skips its JSON-RPC usage read on a confirmed custom route.
  3. Magpie's grok accounts never joined Limits → Grok. They now map onto the Grok driver with the subscription window id the native Grok probe uses, so both shared accounts show beside direct Grok accounts.

Also, model_substituted no longer fires when Magpie selects grok/grok-4.7 and xAI runs grok-4.7-build. A rate-table provider prefix such as openai/ is still a substitution.

The open usage-panel PR (#124) only drops dead OpenCode Go keys and names the Antigravity window, so this is separate.

Evidence

  • pnpm --filter t3 exec vp test run src/usage/usagePricing.test.ts src/usage/magpieQuotas.test.ts src/orchestration-v2/SubagentProjection.test.ts: 56 passed, then 27 passed after the prefix narrowing.
  • pnpm --filter @t3tools/provider-opencode exec vp test run src/server/status.test.ts: 41 passed.
  • pnpm --filter t3 typecheck, @t3tools/provider-opencode and @t3tools/provider-core typecheck: exit 0.

Human review: not requested

🤖 Generated with Claude Code

Magpie prefixes model ids with the harness (`codex/gpt-6.1-sol`,
`claude/...`, `grok/...`), so rate lookup missed the table and reported
them unpriced. A harness prefix now prices at the bare model's rate when
that rate is unambiguous.

OpenCode instances Magpie routes to another provider no longer probe
OpenCode Go, which answered with a read error. Magpie's grok accounts map
onto the Grok limits pool, and `grok/grok-4.7` running as `grok-4.7-build`
is no longer flagged as a model substitution.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nullStack65

Copy link
Copy Markdown
Owner Author
{"reviewed_head": "306ddbe89f378ac90647dae115ec9e158c262212", "reviewer": "grok-4.7, Claude Code review lane", "findings": []}

Review: CLEAN

Independent review of the Magpie usage reporting fix (CLO-951) at 306ddbe89f378ac90647dae115ec9e158c262212. No Critical, Important or Medium defects. Re-ran the affected tests on this head: 56 passed in the server package (usagePricing, magpieQuotas, SubagentProjection) and 41 passed in @t3tools/provider-opencode status.test.ts.

Checked against the four reported bugs:

  1. Harness-prefix pricing. resolveRate only falls through to the bare alias for a claude/, codex/ or grok/ prefix, and only when no exact entry exists. Against the current LiteLLM table (7,075 entries) none of those prefixes exist as providers, so there is no false match, and codex/gpt-6.1-sol, claude/claude-fable-5 and grok/grok-4.7 resolve to the same rate as the bare id. An ambiguous bare name stays unpriced, and a real provider prefix such as openai/ is untouched. The By model grouping keeps the raw id, so rows are not merged.

  2. The Codex JSON-RPC errors are not a gap in this PR. account/rateLimits/read, the call behind Codex could not read usage (JSON-RPC -32600/-32603), only runs when codexRoutesSpendNativeQuota confirms a native OpenAI route, and that logic is unchanged by this PR because it already exists on release/native-0.1.10. The host this lane runs on has model_provider = "magpie" in ~/.codex/config.toml, and its live probe cache (magpie-primary-codex.json, checked 2026-11-20 18:21 UTC) reports unsupported with "routes through a custom model provider", not a JSON-RPC error. The screenshot was taken against the fleet build 3ad1bfdd (this PR's base) before that detection landed. The one case that still probes is a failed config/read, where the route cannot be confirmed, and that correctly stays a probe failure.

  3. Grok accounts. Magpie grok entries map to the grok driver with the subscription window id the native Grok probe publishes, so both shared accounts join Limits → Grok and line up with a direct Grok account.

  4. Model alert equivalence. baseModel strips only a claude|codex|grok prefix and one trailing -build. grok/grok-4.7 against grok-4.7-build is silent, while grok-4.7-fast, grok-4.5-build and a double -build-build still raise model_substituted. A rate-table prefix such as openai/ still alerts.

Not verified: the ARC CI check was still running, and nothing was exercised against a live Magpie gateway.

@nullStack65
nullStack65 merged commit d536de1 into release/native-0.1.10 Nov 20, 2026
3 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