refactor(pricing): align parenthesized reasoning tiers with CLIProxyAPI#480
Open
makoMakoGo wants to merge 3 commits intojunhoyeo:mainfrom
Open
refactor(pricing): align parenthesized reasoning tiers with CLIProxyAPI#480makoMakoGo wants to merge 3 commits intojunhoyeo:mainfrom
makoMakoGo wants to merge 3 commits intojunhoyeo:mainfrom
Conversation
Generalize the parenthesized `(level)` suffix handling to match the upstream CLIProxyAPI contract (https://help.router-for.me/configuration/thinking) so pricing resolution stays consistent with how the proxy itself routes models: - Drop the GPT-only restriction; Claude, Gemini, and any other family routed through CLIProxyAPI now resolve `(level)` suffixes the same way. - Expand the accepted level set from {low, medium, high, xhigh} to the full CLIProxyAPI level vocabulary: {minimal, low, medium, high, xhigh, auto, none}. Numeric thinking budgets remain out of scope. - Fold the lookup pipeline: the entry point strips a recognized parenthesized tier once and falls through the existing dash-suffix / prefix-strip paths, so prefixed routes (e.g. `myproxy-gpt-5.2(xhigh)`, `antigravity-claude-sonnet-4-5(high)`) resolve via the same mechanism that already handles dash forms. - Remove the dedicated `try_strip_prefixed_parenthesized_reasoning_tier` helper and the unreachable parenthesis branches inside `try_strip_unknown_prefix` that the previous structure left behind.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/tokscale-core/src/pricing/lookup.rs">
<violation number="1" location="crates/tokscale-core/src/pricing/lookup.rs:253">
P2: Unknown parenthesized tiers now fall through into generic `-suffix` stripping, allowing silent misresolution to shorter model ids (e.g., `...-0125(invalid)` → `...-turbo`) instead of returning `None`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
Author
|
This is a large-scope change — if you think it has issues, just close it. The GPT-related changes in #478 are already sufficient to cover most of the scenarios that weren’t considered before. |
Cubic flagged that the simplified `lookup_with_source_and_provider` path would fall through to `try_strip_unknown_suffix` for inputs like `gpt-5.2-codex(invalid)`, which then split on `-` and silently matched a shorter, unrelated model id (`gpt-5.2`). Restore the short-circuit semantics from the original PR: when the input ends with `(...)` but the contents are not a recognized CLIProxyAPI level, return `None` instead of peeling the parenthesized fragment off as if it were a generic suffix. The fall-through still applies for recognized levels, so prefix routing (`myproxy-gpt-5.2(xhigh)` → `gpt-5.2`) keeps working.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #478. Generalize the
model(level)parenthesized reasoning-tier handling so it matches the upstream contract documented at CLIProxyAPI · Thinking Budgets via Model Name Parentheses. #478 landed a narrow GPT-only / four-level subset; in practice CLIProxyAPI strips the parentheses before routing for any model family (Gemini / Claude / OpenAI / Codex / OpenRouter) and accepts a wider level vocabulary, so pricing resolution should mirror that.Behavior
minimal,low,medium,high,xhigh,auto,none. Numeric thinking budgets remain out of scope.(level)suffixes the same way (e.g.claude-sonnet-4-5(none)→claude-sonnet-4-5,gemini-3-pro(auto)→openrouter/google/gemini-3-pro-preview).myproxy-gpt-5.2(xhigh)→gpt-5.2,antigravity-claude-sonnet-4-5(high)→claude-sonnet-4-5.gpt-5.2(weirdgarbage),gpt-5.2(1024), andgpt-5.2()all returnNoneinstead of silently misresolving.try_strip_prefixed_parenthesized_reasoning_tierhelper and the unreachable parenthesis branches insidetry_strip_unknown_prefixthat the previous structure left behind. Net-92 +80.Caveat / Future Work
normalize_model_for_groupingis now asymmetric between the two equivalent CLIProxyAPI suffix forms:gpt-5.2(xhigh)gpt-5.2gpt-5.2-xhighgpt-5.2-xhighclaude-opus-4-5-highclaude-opus-4-5-highPricing lookup folds both forms to the same base (and same cost), so reports built on
normalize_model_for_groupingwill fragment cost-equivalent rows when the dash form appears. Aligning the dash path requires introducing a CLIProxyAPI-level whitelist intonormalize_model_for_grouping(so-codex/-codex-max/-nano— real model variants — are not folded). That is a larger behavior change touching existing grouping assertions and is intentionally out of scope for this PR; flagging it here as a follow-up refactor target.Test plan
cargo test -p tokscale-core— 599 pass (one pre-existing flaky parallel-test interaction intest_parse_all_messages_fireworks_provider_kept_under_synthetic_only_filter; passes single-threaded, unrelated to this change)cargo test --workspace— 1127 passtokscale pricing 'gpt-5.2(xhigh)' --json→ matchesgpt-5.2tokscale pricing 'claude-sonnet-4-5(none)' --json→ matchesclaude-sonnet-4-5tokscale pricing 'myproxy-gpt-5.2(auto)' --json→ matchesgpt-5.2Summary by cubic
Align pricing lookup with CLIProxyAPI by stripping
(level)reasoning suffixes across all model families and rejecting unrecognized(...)to avoid misrouting. Prefixed routes and dash variants now resolve cleanly to the base model.New Features
minimal,low,medium,high,xhigh,auto,none(case-insensitive); numeric budgets remain out of scope.(level)for all families and prefixed IDs (e.g.,myproxy-gpt-5.2(xhigh)→gpt-5.2,antigravity-claude-sonnet-4-5(high)→claude-sonnet-4-5).gpt-5.2(weirdgarbage),gpt-5.2(),gpt-5.2-codex(invalid)).Refactors
(level)once at entry, then reuse existing suffix/prefix logic.try_strip_prefixed_parenthesized_reasoning_tier,has_parenthesized_suffix, and dead parenthesis branches in prefix stripping.strip_gpt_parenthesized_reasoning_tiertostrip_parenthesized_reasoning_tierand use it innormalize_model_for_grouping.Written for commit afbf220. Summary will update on new commits. Review in cubic