Skip to content

fix: prefer exact OpenRouter model id over the :suffix-stripped base - #5587

Open
tonycoder-hub wants to merge 1 commit into
Aider-AI:mainfrom
tonycoder-hub:cursor/fix-openrouter-free-variant-model-info-65f5
Open

fix: prefer exact OpenRouter model id over the :suffix-stripped base#5587
tonycoder-hub wants to merge 1 commit into
Aider-AI:mainfrom
tonycoder-hub:cursor/fix-openrouter-free-variant-model-info-65f5

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

OpenRouterModelManager.get_model_info treated the requested route and its :suffix-stripped base as equal candidates, so openrouter/deepseek/deepseek-r1:free could pick the paid base record (wrong context length and non-zero cost).

Try the exact id first; fall back to the base id only when the exact id is missing (needed for routing suffixes like :nitro). Distinct from #4931 and #5550/#5518/#5425.

Test plan

  • New exact-variant test fails on current main (32768 == 8192) and passes after
  • python -m pytest tests/basic/test_openrouter.py -v → 4 passed

get_model_info collected the requested route and its ":suffix"-stripped
base id into a set, so whichever id appeared first in the OpenRouter
payload won. A ":free" variant could therefore resolve to the paid base
model's context length and pricing. Try the exact id first and only fall
back to the base id, which keeps routing suffixes like ":nitro" working.

Co-authored-by: Tony Coder <407243179@qq.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants