Skip to content

feat(models): add opt-in low-noise /v1/models catalog mode#4427

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.32from
Rahulsharma0810:fix/model-catalog-low-noise
Jun 21, 2026
Merged

feat(models): add opt-in low-noise /v1/models catalog mode#4427
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.32from
Rahulsharma0810:fix/model-catalog-low-noise

Conversation

@Rahulsharma0810

@Rahulsharma0810 Rahulsharma0810 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Implements the MODELS_CATALOG_PREFIX_MODE setting proposed by @diegosouzapw in #4424.

The /v1/models endpoint currently emits two catalog entries per model whenever a provider's short alias differs from its canonical ID (e.g. ds-web/model and deepseek-web/model). This PR adds an opt-in way to suppress the duplicate while keeping full backward compatibility.

New setting

MODELS_CATALOG_PREFIX_MODE = dual (default) | alias | canonical
Mode /v1/models output How to set
dual (default) both alias + canonical prefix — unchanged from today
alias alias prefix only (e.g. ds-web/model) env var or feature-flags dashboard
canonical canonical provider-id only (e.g. deepseek-web/model) env var or feature-flags dashboard

A per-request ?prefix=<mode> query-param override is also supported, so individual clients can choose their preferred form without changing the global setting.

Request-side alias resolution is unchanged — all prefix forms remain routable regardless of catalog mode.

Measured impact on a real instance

Metric Count
Total model entries (dual mode) 868
Cross-prefix duplicate suffix groups 84
Exact duplicate IDs 3
DeepSeek Web alone 14 pairs

Switching to alias mode eliminates all 84 cross-prefix duplicate suffix groups.

Files changed

File What changed
src/shared/constants/featureFlagDefinitions.ts New MODELS_CATALOG_PREFIX_MODE enum flag (dual/alias/canonical, default dual)
src/shared/utils/featureFlags.ts getModelsCatalogPrefixMode() helper
src/app/api/v1/models/catalog.ts Wire prefixMode + ?prefix= param at all 3 provider-ID emission sites
tests/unit/models-catalog-low-noise-flag.test.ts 4 new tests: alias mode, dual mode, ?prefix=alias, ?prefix=canonical
tests/unit/feature-flags-settings.test.ts Update flag assertion for new enum shape

Tests

node --import tsx/esm --test tests/unit/feature-flags-settings.test.ts        → 44/44 ✓
node --import tsx/esm --test tests/unit/models-catalog-route.test.ts           → 42/42 ✓
node --import tsx/esm --test tests/unit/models-catalog-low-noise-flag.test.ts  → 4/4   ✓
npm run check:file-size                                                         → PASS  ✓

What's not in this PR (can be follow-ups)

  • Dashboard UI selector for the enum value
  • Exact-duplicate ID deduplication (codex/gpt-5.5 ×2 etc.)
  • Per-request X-Prefix-Mode header alternative

Relates to #4424

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@Rahulsharma0810 Rahulsharma0810 force-pushed the fix/model-catalog-low-noise branch from 3af48f2 to 1c23c3f Compare June 21, 2026 10:30
Rahulsharma0810 and others added 3 commits June 21, 2026 08:50
…override

Implements the low-noise catalog design from issue diegosouzapw#4424, aligned with
@diegosouzapw's proposed shape.

## Problem
GET /v1/models returns duplicate-looking model entries when a provider's
alias differs from its canonical ID (e.g. ds-web vs deepseek-web). On a
real instance: 868 total entries, 84 cross-prefix duplicate suffix groups,
3 exact duplicate IDs. DeepSeek Web alone contributes 14 pairs.

## Solution
Add a 3-value enum setting MODELS_CATALOG_PREFIX_MODE:

  dual (default)  — backward-compatible, emits alias + canonical IDs
  alias           — alias-prefix only (e.g. ds-web/model)
  canonical       — canonical provider-id only (e.g. deepseek-web/model)

Also adds a per-request ?prefix=<mode> query-param override so clients
can select their prefix style per-call without changing the global setting.

Request-time alias resolution is unchanged — all forms stay routable.

## Files changed
- src/shared/constants/featureFlagDefinitions.ts: new enum flag
- src/shared/utils/featureFlags.ts: getModelsCatalogPrefixMode() helper
- src/app/api/v1/models/catalog.ts: wire prefixMode at 3 emission sites
- tests/unit/models-catalog-low-noise-flag.test.ts: 4 tests (alias mode,
  dual mode, ?prefix=alias override, ?prefix=canonical override)
- tests/unit/feature-flags-settings.test.ts: update flag assertion

Relates to: diegosouzapw#4424
In canonical prefix mode, synced and custom model sections were pushing
aliasId unconditionally before the includeCanonical guard, so canonical
mode still emitted both ds-web/* and deepseek-web/* entries.

Gate the alias-prefixed push with includeAlias=true and fix the parent
reference in the canonical entry to null when includeAlias is false.

Before: canonical mode returned 656 models (both prefixes present)
After:  canonical mode returns 124 models (only canonical prefix)
…ize baseline (review)

Co-authored-by: diegosouzapw <diego.souza@cdwasolutions.com.br>
@diegosouzapw diegosouzapw force-pushed the fix/model-catalog-low-noise branch from d27dd35 to 84fe309 Compare June 21, 2026 11:53
@diegosouzapw diegosouzapw changed the base branch from main to release/v3.8.32 June 21, 2026 11:53
@diegosouzapw diegosouzapw merged commit 620da16 into diegosouzapw:release/v3.8.32 Jun 21, 2026
10 of 14 checks passed
diegosouzapw pushed a commit to Rahulsharma0810/OmniRoute that referenced this pull request Jun 21, 2026
…iants

When the catalog emits canonical-prefixed model ids (MODELS_CATALOG_PREFIX_MODE=canonical),
no-thinking variants built by appendNoThinkingVariants were using the raw alias prefix
(e.g. cc/...) instead of the canonical provider name (e.g. claude/...), making the
variant ids inconsistent with the rest of the catalog.

Changes:
- open-sse/utils/noThinkingAlias.ts: add normalizeProviderPrefix() helper and optional
  aliasToCanonical param to appendNoThinkingVariants(). When the map is provided, the
  inner provider prefix of each generated no-think id is normalized to its canonical form.
- src/app/api/v1/models/catalog.ts: pass aliasToProviderId when prefixMode === 'canonical'
  so variant ids are canonical-prefix-consistent.
- tests/unit/no-thinking-alias.test.ts: 2 new tests covering alias normalization and
  no-map passthrough.

Refs: diegosouzapw#4427
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.

2 participants