Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

fix(provider): normalize additional provider aliases - #126

Merged
makoMakoGo merged 1 commit into
personal/local-clientsfrom
codex-provider-normalization
Jul 6, 2026
Merged

fix(provider): normalize additional provider aliases#126
makoMakoGo merged 1 commit into
personal/local-clientsfrom
codex-provider-normalization

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jul 5, 2026

Copy link
Copy Markdown
Owner

What Changed

Normalize more provider aliases through the shared provider identity layer:

  • xai-oauth, grok, grok-oauth, grok-cli, and supergrok canonicalize/group as xai.
  • moonshotai, moonshot-ai, kimi, kimi-code, and kimi-for-coding canonicalize/group as kimi.
  • z.ai, z-ai, zhipu, zhipuai, bigmodel.cn, and open.bigmodel.cn canonicalize/group as zai.
  • vertex, vertex-ai, google-gemini-cli, and google-antigravity canonicalize/group as google.
  • github-copilot, copilot-chat, azure, and azure_ai canonicalize/group as microsoft.
  • mistralai, meta_llama, fireworks_ai, and together_ai canonicalize/group as mistral, meta, fireworks, and together.

Provider display now renders microsoft as Microsoft, and the stale github-copilot display arm was removed because Copilot is now represented by the unified Microsoft provider identity.

Aggregation now trusts finalized UnifiedMessage.provider_id values instead of re-running provider normalization inside each accumulator. finalize_token_priced_messages remains the canonicalization boundary for both model and provider ids.

finalize_token_priced_messages now resolves provider ids through the full ingress order: owl shims, canonical providers, custom literal provider tags, model inference, then unknown.

Why

Local OMP data and built-in provider aliases were leaking raw provider names such as xai-oauth, which made provider grouping and display inconsistent. Kimi was also using moonshotai as the canonical provider even though the displayed/provider grouping identity should be kimi.

The aggregation engine already consumes finalized messages and did not re-canonicalize model ids; provider ids now follow the same boundary.

Custom provider ids such as venice must survive finalize so provider-aware pricing can match provider-scoped catalog keys. owl provider shims must also survive finalize as the grouping/provider identity while still pricing through the inferred model provider.

Pricing Impact

Kimi is now treated as the original provider tag for provider-aware pricing so existing moonshotai/kimi-* pricing keys still match when the provider hint is kimi.

Azure and Copilot catalog/provider hints now use the same microsoft canonical provider identity; there is no separate display-vs-pricing provider split.

Custom provider names still participate in provider-aware pricing as literal provider tags without being promoted to canonical provider identities.

Validation

  • cargo test -p tokscale-core provider_identity --quiet
  • cargo test -p tokscale-core aggregate:: --quiet
  • cargo test -p tokscale-core test_provider_hint_prefers_matching_pricing_source --quiet
  • cargo test -p tokscale-core test_finalize_token_priced_messages_preserves --quiet
  • cargo test -p tokscale-core test_finalize_token_priced_messages_canonicalizes_provider --quiet
  • cargo test -p tokscale-core test_apply_token_pricing_prices_owl --quiet
  • cargo test -p tokscale-core --quiet
  • cargo test -p tokscale-cli --quiet
  • cargo bench -p tokscale-core --bench normalization normalize_provider_for_grouping -- --sample-size 10
    • local Criterion baseline showed provider normalization improved for all benchmarked provider cases, including mixed batch and GitHub Copilot.
  • cargo bench -p tokscale-core --bench aggregation all_views -- --sample-size 10
    • local Criterion baseline showed aggregation_engine_push_finish/all_views time improved by about 23%.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@makoMakoGo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39c263bd-ab44-4906-b661-f62015a007b6

📥 Commits

Reviewing files that changed from the base of the PR and between dbfa7f0 and f139df8.

📒 Files selected for processing (10)
  • crates/tokscale-cli/src/tui/ui/widgets.rs
  • crates/tokscale-core/src/aggregate/accumulators.rs
  • crates/tokscale-core/src/aggregate/engine.rs
  • crates/tokscale-core/src/aggregate/tui.rs
  • crates/tokscale-core/src/lib.rs
  • crates/tokscale-core/src/lib_tests.rs
  • crates/tokscale-core/src/pricing/lookup.rs
  • crates/tokscale-core/src/pricing/lookup_tests.rs
  • crates/tokscale-core/src/provider_identity.rs
  • crates/tokscale-core/src/sessions/claudecode.rs

Walkthrough

本次变更重构了 provider 归一化与分组核心逻辑(canonicalize_provider_segment、normalize_provider_for_grouping、provider_tags),将 azure/github-copilot 系归一到 microsoft,moonshotai 归一到 kimi,mistralai 归一到 mistral,并更新了 ORIGINAL_PROVIDER_TAGS 常量。相应地同步了定价查找、聚合统计、CLI 显示格式化与会话解析各处的测试断言。

Changes

Provider 归一化重构与下游同步

Layer / File(s) Summary
核心归一化逻辑重构
crates/tokscale-core/src/provider_identity.rs
重写 canonicalize_provider_segment、normalize_provider_for_grouping、provider_tags 与 inferred_provider_from_model,将 azure*/github-copilot* 归一为 microsoft,moonshot* 归一为 kimi,mistral* 归一为 mistral,并更新相关测试用例。
定价查找行为更新
crates/tokscale-core/src/pricing/lookup.rs, crates/tokscale-core/src/pricing/lookup_tests.rs
更新 ORIGINAL_PROVIDER_TAGS 常量(meta/mistral/kimi 替换旧值),并将多处 lookup_with_provider 测试的 provider 提示从 azure 调整为 microsoft。
聚合与会话解析同步
crates/tokscale-core/src/aggregate/tui.rs, crates/tokscale-core/src/lib_tests.rs, crates/tokscale-core/src/sessions/claudecode.rs
同步更新 daily/source breakdown key 与 provider_id 断言,将 github-copilot 改为 microsoft、moonshotai 改为 kimi、fireworks_ai 改为 fireworks。
CLI 显示层别名映射
crates/tokscale-cli/src/tui/ui/widgets.rs
新增 microsoft 到 MicroSoft 的显示映射,并扩展测试覆盖 Z.AI、Qwen、xAI、Google、MicroSoft 各类别名及去重合并场景。

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Poem

小兔蹦跳理供应商,
azure 归入 microsoft 郎,
moonshot 化身叫做 kimi,
测试断言一并跟上,
🐰 归一化后世界更清爽!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题简洁且准确概括了本次对 provider 别名归一化的主要改动。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex-provider-normalization

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

Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Jul 5, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 62.5%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 13 improved benchmarks
✅ 14 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
normalize_provider_for_grouping[openai_codex_provider] 9.1 µs 3.6 µs ×2.5
normalize_provider_for_grouping[opencode_openrouter_path] 9.2 µs 3.8 µs ×2.4
normalize_provider_for_grouping[anthropic_provider_path] 8.6 µs 3.7 µs ×2.3
mixed_batch 18.8 µs 8.4 µs ×2.2
normalize_provider_for_grouping[zai_provider_alias] 8.7 µs 4.1 µs ×2.1
aggregation_engine_push_finish[model_only] 266 ms 158.9 ms +67.45%
aggregation_engine_push_finish[workspace_model] 320 ms 222.7 ms +43.65%
normalize_provider_for_grouping[github_copilot_provider] 5.3 µs 3.8 µs +39.71%
aggregation_engine_push_finish[graph_sessions_time] 1,081.7 ms 868.3 ms +24.58%
normalize_provider_for_grouping[kimi_provider_path] 4.5 µs 3.6 µs +23.45%
aggregation_engine_push_finish[all_views] 2.8 s 2.3 s +20.17%
aggregation_engine_push_finish[tui_client_model] 760 ms 645.2 ms +17.79%
aggregation_engine_push_finish[tui_workspace_model] 896.7 ms 785.9 ms +14.09%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex-provider-normalization (f139df8) with personal/local-clients (ede53ee)1

Open in CodSpeed

Footnotes

  1. No successful run was found on personal/local-clients (53468ca) during the generation of this report, so ede53ee was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@makoMakoGo
makoMakoGo force-pushed the codex-provider-normalization branch 2 times, most recently from 2f3a5cc to dbfa7f0 Compare July 6, 2026 00:16
@makoMakoGo
makoMakoGo marked this pull request as ready for review July 6, 2026 01:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
crates/tokscale-cli/src/tui/ui/widgets.rs (1)

182-218: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

清理不可达的 "github-copilot" 匹配分支。

normalize_provider_for_grouping 现在会将 github-copilot/copilot-chat 规范化为 "microsoft"(参见 provider_identity.rs"github_copilot" | "copilot_chat" => "microsoft"),因此本文件213行 "github-copilot" => "GitHub Copilot".to_string() 分支永远不会被匹配到,属于死代码,容易造成误导(读者可能误以为该 provider 仍显示为 "GitHub Copilot")。测试用例(第362行 ("github-copilot", "MicroSoft"))也印证了实际生效的是210行的 "microsoft" 分支。

建议直接删除该死分支。

🧹 建议删除死代码
         "cohere" => "Cohere".to_string(),
         "microsoft" => "MicroSoft".to_string(),
         "opencode" => "OpenCode".to_string(),
         "owl" => "Owl".to_string(),
-        "github-copilot" => "GitHub Copilot".to_string(),
         "commandcode" => "Command".to_string(),
         "unisound" => "UniSound".to_string(),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tokscale-cli/src/tui/ui/widgets.rs` around lines 182 - 218, Remove the
unreachable github-copilot branch from get_single_provider_display_name in
widgets.rs, since normalize_provider_for_grouping already maps
github-copilot/copilot-chat to microsoft and the microsoft arm is the one that
actually applies. Keep the existing provider display-name fallback logic intact,
but delete the dead "GitHub Copilot" match arm to avoid misleading future
readers and align the function with provider_identity normalization.
crates/tokscale-core/src/provider_identity.rs (1)

100-110: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

移除 widgets.rs 中失效的 github-copilot 分支normalize_provider_for_grouping 已把 github-copilot / copilot-chat 归到 microsoft,因此这里不会再命中 "github-copilot=>GitHub Copilot"。保留这条分支只会误导后续维护。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tokscale-core/src/provider_identity.rs` around lines 100 - 110, The
provider normalization logic still has a stale GitHub Copilot-specific branch
that can no longer be reached because normalize_provider_for_grouping already
maps github-copilot and copilot-chat to microsoft. Remove the obsolete
github-copilot handling from the provider grouping/mapping logic in
provider_identity.rs, keeping the remaining microsoft, google, and opencode
cases intact so the symbols normalize_provider_for_grouping and the related
match arms stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/tokscale-cli/src/tui/ui/widgets.rs`:
- Around line 182-218: Remove the unreachable github-copilot branch from
get_single_provider_display_name in widgets.rs, since
normalize_provider_for_grouping already maps github-copilot/copilot-chat to
microsoft and the microsoft arm is the one that actually applies. Keep the
existing provider display-name fallback logic intact, but delete the dead
"GitHub Copilot" match arm to avoid misleading future readers and align the
function with provider_identity normalization.

In `@crates/tokscale-core/src/provider_identity.rs`:
- Around line 100-110: The provider normalization logic still has a stale GitHub
Copilot-specific branch that can no longer be reached because
normalize_provider_for_grouping already maps github-copilot and copilot-chat to
microsoft. Remove the obsolete github-copilot handling from the provider
grouping/mapping logic in provider_identity.rs, keeping the remaining microsoft,
google, and opencode cases intact so the symbols normalize_provider_for_grouping
and the related match arms stay consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 97284704-5668-40e6-8e9e-c11066f73df5

📥 Commits

Reviewing files that changed from the base of the PR and between 53468ca and dbfa7f0.

📒 Files selected for processing (7)
  • crates/tokscale-cli/src/tui/ui/widgets.rs
  • crates/tokscale-core/src/aggregate/tui.rs
  • crates/tokscale-core/src/lib_tests.rs
  • crates/tokscale-core/src/pricing/lookup.rs
  • crates/tokscale-core/src/pricing/lookup_tests.rs
  • crates/tokscale-core/src/provider_identity.rs
  • crates/tokscale-core/src/sessions/claudecode.rs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Re-trigger cubic

@makoMakoGo
makoMakoGo force-pushed the codex-provider-normalization branch from dbfa7f0 to 8297ab8 Compare July 6, 2026 01:51
@makoMakoGo
makoMakoGo force-pushed the codex-provider-normalization branch from 8297ab8 to f139df8 Compare July 6, 2026 02:27
@makoMakoGo
makoMakoGo merged commit 5abcc8f into personal/local-clients Jul 6, 2026
9 checks passed
@makoMakoGo
makoMakoGo deleted the codex-provider-normalization branch July 6, 2026 02:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant