Repository navigation
Accept OpenRouter variant suffixes such as :nitro in the widget's model check - #554
Merged
neuromechanist merged 7 commits intoSep 29, 2026
Merged
Conversation
The Settings dialog refused openai/gpt-oss-120b:nitro: isValidModelId had no :variant, while the server's _MODEL_ID_PATTERN has one. The widget now uses the server's pattern and 100-character limit, and one shared list of valid and invalid ids (tests/fixtures/model_ids.json) is read by the widget's Settings test and by a backend test, with a source-level check that the two patterns are the same text. Tested: Settings suite 89 checks (each corpus id saved or refused through the real dialog), 22 Bun suites, parity and corpus tests; 8 mutations killed.
:nitro, :floor and :exacto only change which providers serve a request, so openai/gpt-oss-120b:nitro is gpt-oss-120b and runs at the plain slug's reasoning level instead of OpenRouter's own default. :free, :batch, :thinking and :extended are catalog entries of their own and are left alone. Tested: variant mapping and request-body tests; 3 mutations killed.
Tested: not applicable (docs).
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
OpenRouter lets suffixes be stacked (openai/gpt-5.2:nitro:exacto), so the server pattern and the widget's both take any number of them; the test that pinned one suffix now pins an empty variant instead. The shared corpus gains stacked ids and an upper-case and underscore id, the parity test checks that the widget's check uses the pattern and limit it declares, and the corpus test documents trimming. Tested: Settings suite 95 checks, corpus and parity tests; 5 mutations killed.
…ug's provider alone :online is a documented routing variant, and routing variants stack in any order with at most one catalog variant, so all of them are stripped before the lookup and a leftover catalog variant (:free) still means a different entry. An anthropic/ slug that carries a variant is no longer pinned to the Anthropic provider: the caller chose how it is routed. Tested: stacked, order, alias-variant and provider tests; 4 mutations killed.
…eadlock httpcore's pool lock is not reentrant, and LiteLLM can leave a streaming response unclosed. When the collector then finalizes it inside a later request, while the pool lock is held, it takes the same lock on the same thread and never returns: the intermittent hang seen in local runs and in CI, always in a test using FakeOpenRouter. Automatic collection is now held off while the fake server is up and run when it closes. Tested: 12 consecutive runs of the OpenRouter test files with no hang (a smaller set stalled about 1 run in 3 before); mechanism tests for the collector state.
…s verified Tested: not applicable (docs).
neuromechanist
deleted the
feature/issue-552-openrouter-variant-slugs
branch
September 29, 2026 23:45
8 tasks
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.
Closes #552.
What was wrong
The widget's Settings dialog refused an OpenRouter slug with a variant suffix (
openai/gpt-oss-120b:nitro): "Invalid model format. Expected a Claude model id or provider/model-name". A saved one was dropped on load.isValidModelIdinfrontend/osa-chat-widget.jshad no room for:variant, while the server's own check for a community's ids (_MODEL_ID_PATTERN) has, and the request'smodelfield has no pattern at all: the server accepted what the widget refused.I reproduced the server side in-process against a local fake of OpenRouter: the slug reaches OpenRouter intact (
model: openai/gpt-oss-120b:nitro) and noproviderorder is sent for a caller's custom slug.Changes
isValidModelIduses the server's pattern and its 100-character limit; the refusal message names a variant such as:nitro.openai/gpt-5.2:nitro:exacto: any number of routing variants, at most one catalog variant), so both the server pattern and the widget's take any number; the server test that pinned a single suffix now pins an empty variant instead.tests/fixtures/model_ids.jsonholds valid and invalid ids. The widget's Settings suite saves or refuses each one through the real dialog,tests/test_core/test_model_id_corpus.pyholds the server's validator to the same list, andtests/test_frontend/test_widget_model_id_parity.pychecks the two patterns are the same text (apart from the escaped slash) and that the widget's check uses the pattern and limit it declares.:nitro,:floor,:exactoand the deprecated:online, which OpenRouter documents as accepted on any model and stackable in any order) are looked through when a slug is mapped to an offered model, soopenai/gpt-oss-120b:nitroruns at the same level as the plain slug (Default every model to high reasoning effort, including Claude Haiku through its thinking budget #548) instead of OpenRouter's own default.:free,:batch,:thinkingand:extendedare catalog entries of their own and are left alone (stripping:freewould resolve to the paid entry).anthropic/slug that carries a variant is no longer pinned toprovider.order = [Anthropic], so a routing the caller chose (:floorfor the cheapest) is not overridden. A plainanthropic/slug is pinned as before.FakeOpenRouteris up and run when it closes. Twelve consecutive runs of the OpenRouter test files (with two more streaming files added) had no hang; a smaller set stalled about one run in three before. Test-only: production uses the async client.Not verified
OpenRouter's documentation does not say whether a routing variant conflicts with an explicit
provider.order. OSA sends none for a caller's own slug, and no longer pins one on ananthropic/variant slug, so it does not arise for a typed slug; the slug is the caller's to have verified.A community
default_modelthat is a variant slug passes config validation but is refused at request time by the pricing check (_check_model_cost), which does not look through the suffix: loud, and not changed here.I could not reproduce the dialog error against the deployed widget; it follows from the code and is covered by tests that fail on the old validator.
Tests
:nitromodel coming back as Custom.:freegets no reasoning field, provider pinning with and without a variant).:online, stacked and catalog handling, and the provider pinning; all killed.Review
An independent Sonnet review found no critical issue and three important ones, all addressed: stacked suffixes (fixed),
anthropic/variant slugs still pinned to a provider (fixed, and the claim corrected), and an ADR bullet that went beyond what was verified (reworded). Also fixed::online, corpus character classes, the parity test's reach, wording, and comment density. Left as documented behavior: a communitydefault_modelvariant slug is refused by the pricing check.