[PR #7713] [MERGED] fix(models): recognize proxy and gateway model ids on their native provider #7889

Closed
opened 2026-10-24 04:08:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7713
Author: @Gunterlie
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @Gunterlie

Base: staging ← Head: fix/proxy-model-id-recognition


📝 Commits (5)

  • 4e876fe fix(models): recognize proxy-tagged model ids on their native provider
  • 4c3d16e fix(models): cover common proxy and gateway id conventions
  • 2c285d1 fix(models): scan proxy id tags linearly and strip samplers after custom parameters
  • a6e78ee fix(models): keep trimmed ids, cap suffix passes, read thinking-disable through the tag
  • 677062f fix(models): trim after an @ modifier and read thinking through trailing tags

📊 Changes

7 files changed (+457 additions, -59 deletions)

View changed files

📝 packages/server/src/services/generation/provider-generation-runtime.ts (+2 -1)
📝 packages/server/src/services/llm/providers/anthropic.provider.ts (+17 -6)
📝 packages/server/src/services/llm/providers/google.provider.ts (+2 -1)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+18 -15)
📝 packages/shared/src/constants/generation-parameter-relevance.ts (+10 -9)
📝 packages/shared/src/constants/model-lists.ts (+141 -27)
➕ scripts/regressions/proxy-model-ids.regression.ts (+267 -0)

📄 Description

Why

This comes from a user report (Android/Termux, v2.5.0, LinkAPI). No issue was opened for it.

"I'd like model IDs including prefixes and/or suffixes (e.g. [次]claude-opus-4-6-thinking, example from LinkAPI) to be correctly recognized on their native provider. … Right now such IDs are treated as unknown even though they refer to a supported model, so they don't receive reasoning effort parameters and more, even if capable. Affects maybe half of all LinkAPI models."

The problem is not LinkAPI-specific. Proxies and gateways decorate model ids in a few common ways: reseller channel tags (new-api/one-api forks), thinking/effort switches in the name, organisation or provider paths, date pins, and dotted versions. On a native provider type (for example an Anthropic connection pointed at a proxy), Marinara looked these ids up in its built-in catalog by exact match only, so it treated them as unknown models. Unknown models on a provider with a catalog get only max tokens and custom parameters: no reasoning effort, no thinking, no sampling controls, and no context or output limits. Many capability checks are also anchored at the start of the id (^gpt-6…, (?:^|\/)gemini-4-argon, (?:^|\/)claude-opus-5[.-]5), so a leading tag defeated them too.

What changed

One shared normalizer in packages/shared/src/constants/model-lists.ts; every capability lookup goes through it. The id sent to the provider is never rewritten: requests carry exactly the id the user configured.

  • capabilityModelId(model) — what every capability predicate, resolveProviderReasoningEffort, the parameter-relevance rules and the providers' model-family checks read: trimmed, lower case, without

    • leading channel tags: [次], [SP], [free], 【限时】, (…) (new-api/one-api resellers such as LinkAPI);
    • trailing modifiers: CLIProxyAPI (high) / (8192), Claude Code [1m], new-api @thinking:on, Vertex @20250805.

    Vendor paths stay, because the OpenRouter rules read them.

  • findKnownModel — exact match first, then the catalog form of the id:

    • namespace paths dropped: OpenRouter, Bifrost and LiteLLM vendor/…, Chutes deepseek-ai/…, CLIProxyAPI provider://…;
    • :variant dropped: OpenRouter :free/:thinking, NanoGPT :thinking, Bedrock :0;
    • Bedrock wrapper dropped: us.anthropic.claude-…-v1;
    • Vertex @YYYYMMDD read as Anthropic's -YYYYMMDD;
    • dotted Claude versions hyphenated: Poe and OpenRouter claude-opus-4.6. This generalises the old Opus/Sonnet 5.5-only alias.

    Then known proxy suffixes are removed one at a time, only while the id is still unknown:

    • new-api -thinking, -thinking-<budget>, -nothinking and effort tails -none/-minimal/-low/-medium/-high/-xhigh/-max;
    • AiHubMix -think, -nothink and -search;
    • LinkAPI -r;
    • Chutes -tee;
    • date pins -YYYYMMDD, -YYYY-MM-DD and -MMDD.

    Real catalog ids that end the same way (command-r, gpt-5.1-codex-max, grok-4-0709, grok-4-fast-reasoning, glm-4-32b-0414-128k) match as they are. Real distinct models whose base is not in the catalog (kimi-k2-thinking, grok-4-1-fast-reasoning) stay unknown and do not borrow another model's limits.

  • impliesProxyThinking(model) — ids that make the proxy turn reasoning on whatever the request says:

    • new-api -thinking, -thinking-<budget>, effort tails on Claude/GPT-5/o-series, and @thinking:<on|budget>;
    • AiHubMix -think;
    • CLIProxyAPI (<level|budget>).

    Off forms (-nothinking, -thinking-0, @thinking:off, (none), ()) do not count. Anthropic rejects sampling and forced tool choice while thinking runs, and GPT-5 rejects temperature while reasoning. So:

    • the Anthropic provider drops temperature/top_k/top_p and uses automatic tool choice for these ids;
    • the OpenAI provider drops temperature for GPT-5 effort-tail ids;
    • the parameter editor hides those controls to match.

    Before this change these ids were "unknown", so they got no sampling at all. Without this rule, recognising them would have started sending temperature to a proxy that thinks on its own. Thinking/effort settings Marinara sends still apply where the proxy keeps them.

  • Files touched: model-lists.ts, generation-parameter-relevance.ts, anthropic.provider.ts, openai.provider.ts, google.provider.ts, provider-generation-runtime.ts.

  • New regression scripts/regressions/proxy-model-ids.regression.ts covers:

    • a table of proxy ids per convention and the catalog model each one resolves to;
    • ids that must not be over-normalized;
    • capability predicates read through tags and modifiers;
    • the thinking-implying and off forms;
    • parameter relevance for Anthropic and GPT-5 ids;
    • a wire-level Anthropic stub proving effort/thinking are sent while body.model stays [次]claude-opus-4-6-thinking.

Sources for the conventions:

  • LinkAPI public /api/pricing
  • new-api relaykit/relayconvert/reasoning/suffix.go
  • CLIProxyAPI thinking docs
  • Chutes, AiHubMix and Poe public /v1/models lists
  • OpenRouter, Bifrost, LiteLLM, Bedrock and Vertex id formats

Limits

  • Suffix removal helps only for models in Marinara's built-in catalog; a proxy id for a model Marinara does not list stays unknown, as before.
  • Not stripped, because they cannot be told apart from real model names or their meaning is unclear: dash-joined channel prefixes (AiHubMix cc-, sf-, alicloud-), LinkAPI -openai-compact, -instant, -a, and image -c/-h variants.
  • Capability predicates keep vendor paths, as before (OpenRouter rules depend on them). So anchored GPT checks still do not see a Bifrost-style openai/gpt-5.5 on a native OpenAI connection, though the catalog lookup does.
  • Dotted Claude versions are hyphenated for the catalog lookup only, not in the predicates, so OpenRouter's sampling behaviour for anthropic/claude-opus-4.7 is unchanged.
  • How each proxy merges Marinara's thinking/effort fields with its own suffix handling was not verified against live proxies.

Validation

  • node scripts/run-regressions.mjs --filter proxy-model-ids — passed
  • Related regressions (36 files: claude-opus55, claude-sonnet55, provider-compat, generation-parameter-relevance, gpt-6-astra, grok-tool-completion, codex-reasoning-effort, deepseek/mistral/nanogpt reasoning, responses-*, provider-caching, provider-stream-completion, connection/agent/game parameters, gemini-user-regeneration, prompt, context-fit, connection-model-list and others) — passed
  • pnpm check — passed (exit 0; one pre-existing client lint warning in an untouched file)
  • Local CodeRabbit review (coderabbit review --committed, both commits) — completed, 0 findings

Manual verification

  • Manually verify [次]claude-opus-4-6-thinking on an Anthropic connection via LinkAPI shows the reasoning effort control and hides temperature in the generation parameters editor.
  • Manually verify a chat on that connection sends output_config.effort and thinking (debug mode final request log) with model exactly [次]claude-opus-4-6-thinking, and that LinkAPI answers without a 400.
  • Manually verify the same connection with reasoning effort Off still answers (no temperature sent; the proxy thinks on its own).
  • Manually verify [SP]claude-opus-4-6 (no suffix) shows reasoning effort and temperature, and sends temperature with effort Off.
  • Manually verify a tagged Gemini id (for example [次]gemini-2.5-pro) on a Google connection via LinkAPI shows reasoning effort.
  • Manually verify an AiHubMix id such as claude-sonnet-4-5-think on an Anthropic connection shows reasoning effort and answers.
  • Manually verify a Chutes id such as zai-org/GLM-5.1-TEE on a custom connection shows the GLM 5.1 context size.
  • Manually verify an unrelated unknown id on Anthropic (for example my-custom-model) still shows only max tokens and custom parameters.

Summary by CodeRabbit

  • Bug Fixes
    • Improved model capability recognition for IDs with proxy, gateway, channel, or suffix modifiers.
    • Adjusted reasoning and sampling options for supported models, including when sampling controls are available and which tool choices can be selected.
    • Improved known-model matching across providers while preserving distinct or unrecognized model IDs.
    • Ensured proxy-thinking models use compatible settings in Anthropic and OpenAI requests.
  • Tests
    • Added coverage for model recognition, generation settings, and Anthropic request behavior.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7713 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/proxy-model-id-recognition` --- ### 📝 Commits (5) - [`4e876fe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4e876fe1f5ad2799c16a59f3683e4f46f0698779) fix(models): recognize proxy-tagged model ids on their native provider - [`4c3d16e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4c3d16e28e2e841be91d56859d198d27da3debe0) fix(models): cover common proxy and gateway id conventions - [`2c285d1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2c285d1ec133ffea20abf128617a6954ffcda1f4) fix(models): scan proxy id tags linearly and strip samplers after custom parameters - [`a6e78ee`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a6e78eec88cf3e64a11288470a6d42686921e578) fix(models): keep trimmed ids, cap suffix passes, read thinking-disable through the tag - [`677062f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/677062f403f985e5b15751cdb1a516bc1d28fa27) fix(models): trim after an @ modifier and read thinking through trailing tags ### 📊 Changes **7 files changed** (+457 additions, -59 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/generation/provider-generation-runtime.ts` (+2 -1) 📝 `packages/server/src/services/llm/providers/anthropic.provider.ts` (+17 -6) 📝 `packages/server/src/services/llm/providers/google.provider.ts` (+2 -1) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+18 -15) 📝 `packages/shared/src/constants/generation-parameter-relevance.ts` (+10 -9) 📝 `packages/shared/src/constants/model-lists.ts` (+141 -27) ➕ `scripts/regressions/proxy-model-ids.regression.ts` (+267 -0) </details> ### 📄 Description ## Why This comes from a user report (Android/Termux, v2.5.0, LinkAPI). No issue was opened for it. > "I'd like model IDs including prefixes and/or suffixes (e.g. `[次]claude-opus-4-6-thinking`, example from LinkAPI) to be correctly recognized on their native provider. … Right now such IDs are treated as unknown even though they refer to a supported model, so they don't receive reasoning effort parameters and more, even if capable. Affects maybe half of all LinkAPI models." The problem is not LinkAPI-specific. Proxies and gateways decorate model ids in a few common ways: reseller channel tags (new-api/one-api forks), thinking/effort switches in the name, organisation or provider paths, date pins, and dotted versions. On a native provider type (for example an Anthropic connection pointed at a proxy), Marinara looked these ids up in its built-in catalog by exact match only, so it treated them as unknown models. Unknown models on a provider with a catalog get only max tokens and custom parameters: no reasoning effort, no thinking, no sampling controls, and no context or output limits. Many capability checks are also anchored at the start of the id (`^gpt-6…`, `(?:^|\/)gemini-4-argon`, `(?:^|\/)claude-opus-5[.-]5`), so a leading tag defeated them too. ## What changed One shared normalizer in `packages/shared/src/constants/model-lists.ts`; every capability lookup goes through it. **The id sent to the provider is never rewritten**: requests carry exactly the id the user configured. - `capabilityModelId(model)` — what every capability predicate, `resolveProviderReasoningEffort`, the parameter-relevance rules and the providers' model-family checks read: trimmed, lower case, without - leading channel tags: `[次]`, `[SP]`, `[free]`, `【限时】`, `(…)` (new-api/one-api resellers such as LinkAPI); - trailing modifiers: CLIProxyAPI `(high)` / `(8192)`, Claude Code `[1m]`, new-api `@thinking:on`, Vertex `@20250805`. Vendor paths stay, because the OpenRouter rules read them. - `findKnownModel` — exact match first, then the catalog form of the id: - namespace paths dropped: OpenRouter, Bifrost and LiteLLM `vendor/…`, Chutes `deepseek-ai/…`, CLIProxyAPI `provider://…`; - `:variant` dropped: OpenRouter `:free`/`:thinking`, NanoGPT `:thinking`, Bedrock `:0`; - Bedrock wrapper dropped: `us.anthropic.claude-…-v1`; - Vertex `@YYYYMMDD` read as Anthropic's `-YYYYMMDD`; - dotted Claude versions hyphenated: Poe and OpenRouter `claude-opus-4.6`. This generalises the old Opus/Sonnet 5.5-only alias. Then known proxy suffixes are removed one at a time, **only while the id is still unknown**: - new-api `-thinking`, `-thinking-<budget>`, `-nothinking` and effort tails `-none`/`-minimal`/`-low`/`-medium`/`-high`/`-xhigh`/`-max`; - AiHubMix `-think`, `-nothink` and `-search`; - LinkAPI `-r`; - Chutes `-tee`; - date pins `-YYYYMMDD`, `-YYYY-MM-DD` and `-MMDD`. Real catalog ids that end the same way (`command-r`, `gpt-5.1-codex-max`, `grok-4-0709`, `grok-4-fast-reasoning`, `glm-4-32b-0414-128k`) match as they are. Real distinct models whose base is not in the catalog (`kimi-k2-thinking`, `grok-4-1-fast-reasoning`) stay unknown and do not borrow another model's limits. - `impliesProxyThinking(model)` — ids that make the proxy turn reasoning on whatever the request says: - new-api `-thinking`, `-thinking-<budget>`, effort tails on Claude/GPT-5/o-series, and `@thinking:<on|budget>`; - AiHubMix `-think`; - CLIProxyAPI `(<level|budget>)`. Off forms (`-nothinking`, `-thinking-0`, `@thinking:off`, `(none)`, `()`) do not count. Anthropic rejects sampling and forced tool choice while thinking runs, and GPT-5 rejects temperature while reasoning. So: - the Anthropic provider drops temperature/top_k/top_p and uses automatic tool choice for these ids; - the OpenAI provider drops temperature for GPT-5 effort-tail ids; - the parameter editor hides those controls to match. Before this change these ids were "unknown", so they got no sampling at all. Without this rule, recognising them would have started sending temperature to a proxy that thinks on its own. Thinking/effort settings Marinara sends still apply where the proxy keeps them. - Files touched: `model-lists.ts`, `generation-parameter-relevance.ts`, `anthropic.provider.ts`, `openai.provider.ts`, `google.provider.ts`, `provider-generation-runtime.ts`. - New regression `scripts/regressions/proxy-model-ids.regression.ts` covers: - a table of proxy ids per convention and the catalog model each one resolves to; - ids that must not be over-normalized; - capability predicates read through tags and modifiers; - the thinking-implying and off forms; - parameter relevance for Anthropic and GPT-5 ids; - a wire-level Anthropic stub proving effort/thinking are sent while `body.model` stays `[次]claude-opus-4-6-thinking`. Sources for the conventions: - LinkAPI public `/api/pricing` - new-api `relaykit/relayconvert/reasoning/suffix.go` - CLIProxyAPI thinking docs - Chutes, AiHubMix and Poe public `/v1/models` lists - OpenRouter, Bifrost, LiteLLM, Bedrock and Vertex id formats ## Limits - Suffix removal helps only for models in Marinara's built-in catalog; a proxy id for a model Marinara does not list stays unknown, as before. - Not stripped, because they cannot be told apart from real model names or their meaning is unclear: dash-joined channel prefixes (AiHubMix `cc-`, `sf-`, `alicloud-`), LinkAPI `-openai-compact`, `-instant`, `-a`, and image `-c`/`-h` variants. - Capability predicates keep vendor paths, as before (OpenRouter rules depend on them). So anchored GPT checks still do not see a Bifrost-style `openai/gpt-5.5` on a native OpenAI connection, though the catalog lookup does. - Dotted Claude versions are hyphenated for the catalog lookup only, not in the predicates, so OpenRouter's sampling behaviour for `anthropic/claude-opus-4.7` is unchanged. - How each proxy merges Marinara's thinking/effort fields with its own suffix handling was not verified against live proxies. ## Validation - `node scripts/run-regressions.mjs --filter proxy-model-ids` — passed - Related regressions (36 files: claude-opus55, claude-sonnet55, provider-compat, generation-parameter-relevance, gpt-6-astra, grok-tool-completion, codex-reasoning-effort, deepseek/mistral/nanogpt reasoning, responses-*, provider-caching, provider-stream-completion, connection/agent/game parameters, gemini-user-regeneration, prompt, context-fit, connection-model-list and others) — passed - `pnpm check` — passed (exit 0; one pre-existing client lint warning in an untouched file) - Local CodeRabbit review (`coderabbit review --committed`, both commits) — completed, 0 findings ## Manual verification - [ ] Manually verify `[次]claude-opus-4-6-thinking` on an Anthropic connection via LinkAPI shows the reasoning effort control and hides temperature in the generation parameters editor. - [ ] Manually verify a chat on that connection sends `output_config.effort` and `thinking` (debug mode final request log) with `model` exactly `[次]claude-opus-4-6-thinking`, and that LinkAPI answers without a 400. - [ ] Manually verify the same connection with reasoning effort Off still answers (no temperature sent; the proxy thinks on its own). - [ ] Manually verify `[SP]claude-opus-4-6` (no suffix) shows reasoning effort and temperature, and sends temperature with effort Off. - [ ] Manually verify a tagged Gemini id (for example `[次]gemini-2.5-pro`) on a Google connection via LinkAPI shows reasoning effort. - [ ] Manually verify an AiHubMix id such as `claude-sonnet-4-5-think` on an Anthropic connection shows reasoning effort and answers. - [ ] Manually verify a Chutes id such as `zai-org/GLM-5.1-TEE` on a custom connection shows the GLM 5.1 context size. - [ ] Manually verify an unrelated unknown id on Anthropic (for example `my-custom-model`) still shows only max tokens and custom parameters. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved model capability recognition for IDs with proxy, gateway, channel, or suffix modifiers. * Adjusted reasoning and sampling options for supported models, including when sampling controls are available and which tool choices can be selected. * Improved known-model matching across providers while preserving distinct or unrecognized model IDs. * Ensured proxy-thinking models use compatible settings in Anthropic and OpenAI requests. * **Tests** * Added coverage for model recognition, generation settings, and Anthropic request behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:08:32 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7889
No description provided.