Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:3641397194 wq Gpt6 Astra Provider Alias Normalization

From Leeroopedia
Knowledge Sources
Domains AI_Agents, Configuration
Last Updated 2026-10-26 14:00 GMT

Overview

Map common misspellings and variant spellings of provider IDs to canonical names, but only apply alias normalization to legacy preset selections — never to explicit server-side model IDs.

Description

The relay adapter maintains a `PROVIDER_ALIASES` map that translates frequent misspellings (e.g., `gpt6-astra` → `gpt-6-astra`, `gpt-5.6-sol` → `gpt-6.1-sol`, `gpt6.1sol` → `gpt-6.1-sol`) to canonical provider IDs. The `normalizeProviderId` function lowercases the input, checks if it matches a preset directly, then checks the alias map. However, in OpenAI mode's `_preflightOpenAI`, alias normalization is applied only to the `providerId`/`modelId` when deriving a known preset — the actual model ID sent to the server is the original, unnormalized value if no preset matches. This prevents alias normalization from corrupting case-sensitive server-side model IDs.

Usage

Use this heuristic when accepting user-typed provider/model IDs that may contain misspellings. Apply alias normalization for UI convenience (preset selection), but preserve the original string when sending to the server. Never infer entitlement by substring matching — always use exact model ID comparison against the server's model list.

The Insight (Rule of Thumb)

  • Action: Lowercase input, check `PROVIDER_PRESETS` then `PROVIDER_ALIASES`; for OpenAI mode, only normalize when resolving presets, not server model IDs
  • Value: Alias map covers ~12 common misspellings for two providers
  • Trade-off: Slightly more complex resolution; prevents user frustration from typos while avoiding server-side ID corruption
  • Compatibility: Legacy preset selections get normalized; explicit model IDs are preserved as-is

Reasoning

Users frequently mistype provider names in configuration UIs (missing hyphens, swapped digits, concatenated words). Without alias normalization, these would fail with "unknown provider" errors. But server-side model IDs are case-sensitive exact values — normalizing them could send the wrong model name to the API. The solution separates the two paths: `normalizeProviderId` for preset resolution (user convenience), and the original value for server API calls (correctness). The comment in the code explicitly warns: "Explicit model IDs are case-sensitive server values. Only legacy preset selections receive alias normalization; never infer entitlement by substring."

Code Evidence

Alias map from `relay-adapter.js:77-90`:

const PROVIDER_ALIASES = Object.freeze({
  'gpt6-astra': 'gpt-6-astra',
  'gpt-6-asrra': 'gpt-6-astra',
  'gpt6-asrra': 'gpt-6-astra',
  'gpt5.6-sol': 'gpt-6.1-sol',
  'gpt-5-6-sol': 'gpt-6.1-sol',
  'gpt56-sol': 'gpt-6.1-sol',
  'gpt-5.6-sol': 'gpt-6.1-sol',
  'gpt6.1-sol': 'gpt-6.1-sol',
  'gpt6.1sol': 'gpt-6.1-sol',
  'gpt61-sol': 'gpt-6.1-sol',
  'gpt61sol': 'gpt-6.1-sol',
  'gpt-6-1-sol': 'gpt-6.1-sol'
});

Normalization with preset-first check from `relay-adapter.js:134-137`:

function normalizeProviderId(value) {
  const id = text(value).toLowerCase();
  return PROVIDER_PRESETS[id] ? id : (PROVIDER_ALIASES[id] || id);
}

Preset-only normalization in OpenAI mode from `relay-adapter.js:519-525`:

// Explicit model IDs are case-sensitive server values. Only legacy preset
// selections receive alias normalization; never infer entitlement by substring.
const requestedModel = text(modelId) || text(providerId) || 'gpt-6-astra';
const normalizedModel = normalizeProviderId(requestedModel);
const selectedModel = PROVIDER_PRESETS[normalizedModel]?.model || requestedModel;

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment