Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(models): resolve a relay generation from the owner's whole key set

pengwei26944666877485365389f
diff --git a/apps/desktop/electron/main/models-dev-catalog.ts b/apps/desktop/electron/main/models-dev-catalog.ts
index 8130761e3..86474430b 100644
--- a/apps/desktop/electron/main/models-dev-catalog.ts
+++ b/apps/desktop/electron/main/models-dev-catalog.ts
@@ -9,7 +9,7 @@ import {
type Provider,
} from "@earendil-works/pi-ai";
import { builtinProviders } from "@earendil-works/pi-ai/providers/all";
-import { PI_VENDOR_ALIASES, settingsOperationMetadata } from "./pi-model-metadata.ts";
+import { PI_VENDOR_ALIASES, relayFamilyPublisher, settingsOperationMetadata } from "./pi-model-metadata.ts";
import {
MODEL_VENDOR_PREFIXES,
NAMED_ENDPOINT_PRESETS,
@@ -17,7 +17,6 @@ import {
stripReleaseSuffix,
stripVariantSuffix,
} from "@pi-desktop/shared";
-import { RELAY_FAMILY_PUBLISHERS } from "./pi-model-metadata.ts";
import type {
ModelCost,
ModelCostTier,
@@ -655,6 +654,45 @@ function providerKeyCandidates(value: string | undefined): string[] {
return [...new Set([key, ...(PROVIDER_ALIASES[key] ?? [])])].filter(Boolean);
}
+/**
+ * The vendor's sibling catalog keys: one weight owner ships a public key plus
+ * its regional, token-plan and coding-plan keys, and all of them are the
+ * vendor's own records rather than reseller copies. Kept separate from
+ * `PROVIDER_ALIASES` because that map feeds provider identification for every
+ * row, while these only extend the relay owner fallback's second tier.
+ */
+const RELAY_OWNER_ALIASES: Readonly<Record<string, readonly string[]>> = {
+ alibaba: [
+ "alibaba",
+ "alibaba-cn",
+ "alibaba-token-plan",
+ "alibaba-token-plan-cn",
+ "alibaba-coding-plan",
+ "alibaba-coding-plan-cn",
+ ],
+ tencent: ["tencent", "tencent-tokenhub", "tencent-token-plan", "tencent-coding-plan"],
+ moonshotai: ["moonshotai", "moonshotai-cn", "kimi-code-plan-cn", "kimi-code-plan-global"],
+};
+
+/**
+ * The owner key sets a relay lookup consults, in order. The first tier is
+ * exactly the keys this app already maps to the publisher, so an id that
+ * resolves today resolves identically. The second tier adds the vendor's
+ * sibling keys and is consulted only when the first tier states nothing at all
+ * — never when it reports a conflict, because a vendor contradicting itself
+ * about its own id is already a final answer.
+ */
+function relayOwnerKeyTiers(publisher: string): Set<string>[] {
+ const normalize = (keys: readonly string[]) =>
+ new Set(keys.map((key) => normalizedProviderKey(key)).filter(Boolean));
+ const primary = normalize(providerKeyCandidates(publisher));
+ const widened = normalize([
+ ...primary,
+ ...(RELAY_OWNER_ALIASES[normalizedProviderKey(publisher)] ?? []),
+ ]);
+ return widened.size > primary.size ? [primary, widened] : [primary];
+}
+
/**
* Publishers this app ships a provider for: the models.dev keys behind the
* first-class presets and the known endpoints, which mirror the providers pi-ai
@@ -1021,6 +1059,28 @@ function modelWithSharedCapabilities(
return borrowedModel(entries);
}
+/**
+ * Resolve the owner's records for one id. No record states nothing
+ * (`undefined`, so the caller keeps looking); one record, or several that agree
+ * on shape and capacity, answer; a split owner statement is `null` — the owner
+ * itself contradicts, so the id must not be guessed from catalog order.
+ */
+function settleOwnerRecords(
+ candidates: readonly ModelsDevModel[],
+): ModelsDevModel | null | undefined {
+ if (candidates.length === 0) return undefined;
+ const active = candidates.filter((model) => model.status?.toLowerCase() !== "deprecated");
+ const pool = active.length > 0 ? active : candidates;
+ if (pool.length === 1) return pool[0];
+ const first = pool[0];
+ const agreed = pool.every(
+ (model) =>
+ capabilitySignature(model) === capabilitySignature(first) &&
+ JSON.stringify(model.limit) === JSON.stringify(first.limit),
+ );
+ return agreed ? pool[0] : null;
+}
+
/**
* Middle value of the numbers the publishers state. Even counts take the lower
* of the two middles, so a borrow never rounds a window up on its own.
@@ -1188,6 +1248,14 @@ function leafOf(normalized: string): string {
return normalized.slice(normalized.lastIndexOf("/") + 1);
}
+/**
+ * The normalized leaf of an id, used as a map/set key. `leafOf` expects an
+ * already-normalized id; this accepts a raw one.
+ */
+function leafKey(id: string): string {
+ return normalizedModelId(leafOf(normalizedModelId(id)));
+}
+
/**
* The narrow deployment labels the legacy relay lookup was allowed to strip to
* reach a published base ID. Model variants such as `thinking`, `preview`,
@@ -1617,8 +1685,12 @@ export class ModelsDevCatalog {
shared-record matching continues to apply. */
const relayOwnerKey = preferredProvider
? undefined
- : RELAY_FAMILY_PUBLISHERS[leafOf(requested).split(/[-.]/)[0] ?? ""];
- const ownerRecord = relayOwnerKey ? this.unanchoredOwnerRecord(requested) : undefined;
+ : relayFamilyPublisher(leafOf(requested));
+ /* Canonical translation is the weakest step: it maps one published name
+ onto another, so it only runs when the ordinary lookup found nothing. */
+ const ownerRecord = relayOwnerKey
+ ? this.unanchoredOwnerRecord(requested, !result && !deploymentFallback)
+ : undefined;
const borrowed = ownerRecord === null
? undefined
: ownerRecord ?? result ?? deploymentFallback ??
@@ -1754,46 +1826,81 @@ export class ModelsDevCatalog {
* - When the relay names the owner's canonical generation id (the
* catalog's internal name, e.g. `deepseek-v4.1-flash`), the owner's
* own live record for that canonical id answers.
+ * - When the relay names a generation the owner publishes under another
+ * ID, models.dev's own canonical declaration translates the name, but
+ * only when at least two distinct publishers corroborate the same
+ * owner-prefixed target. The capacity still comes from the owner's own
+ * record for the translated ID, never from the declarers.
*/
- private unanchoredOwnerRecord(requested: string): ModelsDevModel | null | undefined {
- const ownerKey = RELAY_FAMILY_PUBLISHERS[leafOf(requested).split(/[-.]/)[0] ?? ""];
+ private unanchoredOwnerRecord(
+ requested: string,
+ allowTranslation: boolean,
+ ): ModelsDevModel | null | undefined {
+ const ownerKey = relayFamilyPublisher(leafOf(requested));
if (!ownerKey) return undefined;
- const ownerKeys = new Set(providerKeyCandidates(ownerKey));
+ const [primary, widened] = relayOwnerKeyTiers(ownerKey);
+ // The tier the app already used decides on its own, conflict included: a
+ // vendor contradicting itself about its own id is a final answer.
+ const settled = this.ownerRecordForKeys(primary, requested, allowTranslation);
+ if (settled !== undefined || !widened) return settled;
+ // The widened tier is added evidence only. It may supply the record the
+ // primary tier could not, but a conflict between the vendor's sibling keys
+ // must not suppress an answer this app already produced.
+ return this.ownerRecordForKeys(widened, requested, allowTranslation) ?? undefined;
+ }
+
+ /**
+ * The owner's own record for `requested`, looked up under exactly `ownerKeys`:
+ * first the served id and its notation aliases as whole published ids, then
+ * the owner's canonical declaration for that name, then — only when nothing
+ * else in the lookup resolved the id — a corroborated canonical translation.
+ */
+ private ownerRecordForKeys(
+ ownerKeys: ReadonlySet<string>,
+ requested: string,
+ allowTranslation: boolean,
+ ): ModelsDevModel | null | undefined {
const ownerHits = (id: string): ModelsDevModel[] =>
(this.lookupIndex?.candidates(id) ?? [])
- .filter(({ model, provider }) =>
- normalizedModelId(model.modelId) === id &&
- ownerKeys.has(normalizedProviderKey(provider.providerKey)),
+ .filter(
+ ({ model, provider }) =>
+ normalizedModelId(model.modelId) === id &&
+ ownerKeys.has(normalizedProviderKey(provider.providerKey)),
)
.map((entry) => entry.model);
- const pick = (hits: ModelsDevModel[]): ModelsDevModel | null | undefined => {
- if (hits.length === 0) return undefined;
- if (hits.length === 1) return hits[0];
- if (hits.length > 1) {
- const signature = capabilitySignature(hits[0]);
- const limit = JSON.stringify(hits[0].limit);
- if (
- hits.every(
- (model) =>
- capabilitySignature(model) === signature &&
- JSON.stringify(model.limit) === limit,
- )
- ) {
- return hits[0];
- }
- }
- return null;
- };
// Notation aliases and one whitelisted deployment label, each checked as
// a whole published id; the wire id is never rewritten.
const candidates = relayNotationCandidates(requested);
for (const candidate of candidates) {
- const hit = pick(ownerHits(candidate));
+ const hit = settleOwnerRecords(ownerHits(candidate));
if (hit !== undefined) return hit;
}
// The relay named the owner's canonical generation id; the owner's own
// live record for it answers.
- return this.canonicalOwnerRecord(ownerKeys, candidates);
+ const canonical = this.ownerCanonicalRecords(ownerKeys, candidates);
+ if (canonical !== undefined) return canonical;
+ // The relay named a generation the owner publishes under a different id;
+ // a corroborated canonical declaration translates it. This is the weakest
+ // step, so it never displaces an id that already resolved: mapping one
+ // published name onto another must not outrank a record for the served id.
+ if (!allowTranslation) return undefined;
+ return this.ownerAliasedRecords(ownerKeys, candidates);
+ }
+
+ /** The owner's records this predicate accepts, keyed by publisher and id. */
+ private ownerRecordsMatching(
+ ownerKeys: ReadonlySet<string>,
+ accept: (model: ModelsDevModel) => boolean,
+ ): ModelsDevModel[] {
+ const records = new Map<string, ModelsDevModel>();
+ for (const provider of this.providers.values()) {
+ if (!ownerKeys.has(normalizedProviderKey(provider.providerKey))) continue;
+ for (const model of provider.models) {
+ if (!accept(model)) continue;
+ records.set(`${provider.providerKey}\u0000${model.modelId}`, model);
+ }
+ }
+ return [...records.values()];
}
/**
@@ -1803,31 +1910,65 @@ export class ModelsDevCatalog {
* nothing is claimed. Reseller copies never enter this set: only the
* weight owner's records may answer a canonical name.
*/
- private canonicalOwnerRecord(ownerKeys: Set<string>, targets: string[]): ModelsDevModel | null | undefined {
+ private ownerCanonicalRecords(
+ ownerKeys: ReadonlySet<string>,
+ targets: readonly string[],
+ ): ModelsDevModel | null | undefined {
if (targets.length === 0) return undefined;
- const wanted = new Set(targets.map((id) => normalizedModelId(leafOf(id))));
- const records = new Map<string, ModelsDevModel>();
+ const wanted = new Set(targets.map((id) => leafKey(id)));
+ return settleOwnerRecords(
+ this.ownerRecordsMatching(ownerKeys, (model) => {
+ const canonical = model.canonicalModelId;
+ return canonical ? wanted.has(leafKey(canonical)) : false;
+ }),
+ );
+ }
+
+ /** The owner's own records whose published leaf is one of `leaves`. */
+ private ownerRecordsForLeaves(
+ ownerKeys: ReadonlySet<string>,
+ leaves: readonly string[],
+ ): ModelsDevModel[] {
+ const wanted = new Set(leaves.map((id) => leafKey(id)));
+ return this.ownerRecordsMatching(ownerKeys, (model) => wanted.has(leafKey(model.modelId)));
+ }
+
+ /**
+ * Translate a relay-only generation name to the ID the owner publishes, using
+ * models.dev's own canonical declaration as the translation.
+ *
+ * Only a corroborated translation counts: at least two distinct publishers
+ * must state the same owner-prefixed canonical id for the served name, so one
+ * reseller's private alias is never evidence. A name the declaration maps
+ * back to itself states nothing new. An ambiguous or uncorroborated
+ * translation returns `undefined` — the caller keeps its previous answer, so
+ * this step can only add resolutions, never remove one. The capacity comes
+ * from the owner's own record for the translated ID, never from a declarer.
+ */
+ private ownerAliasedRecords(
+ ownerKeys: ReadonlySet<string>,
+ servedLeaves: readonly string[],
+ ): ModelsDevModel | null | undefined {
+ const served = new Set(servedLeaves.map((id) => leafKey(id)));
+ if (served.size === 0) return undefined;
+ const declarers = new Map<string, Set<string>>();
for (const provider of this.providers.values()) {
- if (!ownerKeys.has(normalizedProviderKey(provider.providerKey))) continue;
for (const model of provider.models) {
const canonical = model.canonicalModelId;
if (!canonical) continue;
- if (!wanted.has(normalizedModelId(leafOf(canonical)))) continue;
- records.set(`${provider.providerKey}\u0000${model.modelId}`, model);
+ if (!served.has(leafKey(model.modelId))) continue;
+ const target = leafKey(canonical);
+ if (served.has(target)) continue;
+ const prefix = normalizedModelId(canonical).split("/")[0] ?? "";
+ if (!prefix || !ownerKeys.has(normalizedProviderKey(prefix))) continue;
+ const seen = declarers.get(target) ?? new Set<string>();
+ seen.add(normalizedProviderKey(provider.providerKey));
+ declarers.set(target, seen);
}
}
- const candidates = [...records.values()];
- if (candidates.length === 0) return undefined;
- const active = candidates.filter((model) => model.status?.toLowerCase() !== "deprecated");
- const pool = active.length > 0 ? active : candidates;
- if (pool.length === 1) return pool[0];
- const first = pool[0];
- const agreed = pool.every(
- (model) =>
- capabilitySignature(model) === capabilitySignature(first) &&
- JSON.stringify(model.limit) === JSON.stringify(first.limit),
- );
- return agreed ? pool[0] : null;
+ const corroborated = [...declarers.entries()].filter(([, keys]) => keys.size >= 2);
+ if (corroborated.length !== 1) return undefined;
+ return settleOwnerRecords(this.ownerRecordsForLeaves(ownerKeys, [corroborated[0][0]]));
}
/**
diff --git a/apps/desktop/electron/main/pi-model-metadata.ts b/apps/desktop/electron/main/pi-model-metadata.ts
index af518549a..bc2275f7a 100644
--- a/apps/desktop/electron/main/pi-model-metadata.ts
+++ b/apps/desktop/electron/main/pi-model-metadata.ts
@@ -23,7 +23,24 @@ export const RELAY_FAMILY_PUBLISHERS: Record<string, string> = {
// Open-weight families whose owner publishes the IDs a relay actually serves.
mimo: "xiaomi", glm: "zai", deepseek: "deepseek",
kimi: "moonshotai", minimax: "minimax",
+ qwen: "alibaba", hy: "tencent",
};
+
+/**
+ * The publisher that owns the weights behind a served leaf, when the family
+ * names one. A generation number rides on the family token (`qwen3`,
+ * `hy4-preview`), so the token's letters name the owner; only trailing digits
+ * are stripped, and a token registered as-is always wins first, so `o1` stays
+ * OpenAI rather than collapsing to an unregistered `o`.
+ */
+export function relayFamilyPublisher(leafId: string): string | undefined {
+ const token = leafId.split(/[-.]/)[0] ?? "";
+ for (const candidate of [token, token.replace(/\d+$/, "")]) {
+ const publisher = RELAY_FAMILY_PUBLISHERS[candidate];
+ if (publisher) return publisher;
+ }
+ return undefined;
+}
const leaf = (id: string) => id.toLowerCase().split("/").at(-1);
// Only deployment-added environment/context labels are safe to remove as a
// fallback. Model variants such as `thinking`, `preview`, and dated releases
diff --git a/apps/desktop/test/models-dev-catalog.test.mjs b/apps/desktop/test/models-dev-catalog.test.mjs
index 505d21997..99ea2efef 100644
--- a/apps/desktop/test/models-dev-catalog.test.mjs
+++ b/apps/desktop/test/models-dev-catalog.test.mjs
@@ -1956,3 +1956,167 @@ test("a generation name the catalog never publishes stays unmatched", async (t)
vendorKey: "custom", baseUrl: "https://relay.example/v1", modelId: "gemini-3-flash",
}), undefined);
});
+
+test("a vendor's sibling keys answer for a family the primary key never states", async (t) => {
+ // `qwen3.8-flash` lives only on Alibaba's token-plan key, while the relay
+ // serves it under the family name. The primary key states nothing, so the
+ // vendor's own sibling key supplies the record rather than a reseller copy.
+ const catalog = await loadFixtureCatalog(t, {
+ gateway: { api: "https://gateway.example/v1", models: {} },
+ alibaba: { models: { "qwen3.7-flash": {
+ id: "qwen3.7-flash", tool_call: true, limit: { context: 1_000_000, output: 131_072 },
+ } } },
+ "alibaba-token-plan": { models: { "qwen3.8-flash": {
+ id: "qwen3.8-flash", tool_call: true, limit: { context: 1_000_000, output: 131_072 },
+ } } },
+ });
+ const match = catalog.findModel({
+ vendorKey: "custom", baseUrl: "https://relay.example/v1", modelId: "qwen3.8-flash",
+ });
+ assert.equal(match?.providerKey, "alibaba-token-plan");
+ assert.equal(match?.limit.context, 1_000_000);
+ assert.equal(match?.limit.output, 131_072);
+});
+
+test("a sibling key that contradicts the primary key cannot suppress its answer", async (t) => {
+ // The vendor's public key states one capacity and its regional key another.
+ // The primary tier still answers, exactly as it did before sibling keys were
+ // consulted: widening the owner set is added evidence, never a veto.
+ const catalog = await loadFixtureCatalog(t, {
+ gateway: { api: "https://gateway.example/v1", models: {} },
+ minimax: { models: { "MiniMax-M2.7": {
+ id: "MiniMax-M2.7", tool_call: true, limit: { context: 204_800, output: 131_072 },
+ } } },
+ "minimax-cn": { models: { "MiniMax-M2.7": {
+ id: "MiniMax-M2.7", tool_call: true, limit: { context: 128_000, output: 65_536 },
+ } } },
+ });
+ // `minimax-cn` is already an alias of `minimax`, so both keys sit in the
+ // primary tier and their disagreement stays a final "nothing to claim".
+ assert.equal(catalog.findModel({
+ vendorKey: "custom", baseUrl: "https://relay.example/v1", modelId: "MiniMax-M2.7",
+ }), undefined);
+});
+
+test("a corroborated canonical declaration translates a relay-only generation name", async (t) => {
+ // The relay serves `gemini-3-flash`, which its owner never publishes; two
+ // independent publishers carry it only under a vendor-prefixed id and both
+ // declare it canonical for `gemini-3-flash-preview`. Their own capability
+ // flags disagree — as resellers' do in the live catalog — so no shared
+ // reseller record answers and the owner path decides. The declaration only
+ // translates the name; the capacity stays Google's own.
+ const catalog = await loadFixtureCatalog(t, {
+ gateway: { api: "https://gateway.example/v1", models: {} },
+ google: { models: { "gemini-3-flash-preview": {
+ id: "gemini-3-flash-preview", tool_call: true,
+ limit: { context: 1_048_576, output: 65_536 },
+ } } },
+ neon: { models: { "google/gemini-3-flash": {
+ id: "google/gemini-3-flash", tool_call: true,
+ modalities: { input: ["text", "image"], output: ["text"] },
+ canonical_model_id: "google/gemini-3-flash-preview",
+ limit: { context: 1_000_000, output: 1 },
+ } } },
+ pioneer: { models: { "google/gemini-3-flash": {
+ id: "google/gemini-3-flash", tool_call: true,
+ canonical_model_id: "google/gemini-3-flash-preview",
+ limit: { context: 1_000_000, output: 2 },
+ } } },
+ });
+ const match = catalog.findModel({
+ vendorKey: "custom", baseUrl: "https://relay.example/v1", modelId: "gemini-3-flash",
+ });
+ assert.equal(match?.providerKey, "google", "the owner's own record answers");
+ assert.equal(match?.modelId, "gemini-3-flash-preview");
+ assert.equal(match?.limit.context, 1_048_576, "capacity comes from the owner, not the declarers");
+ assert.equal(match?.limit.output, 65_536);
+});
+
+test("one reseller's private alias is not evidence for a canonical translation", async (t) => {
+ // A single publisher's own naming choice must not rewrite the id: the served
+ // name keeps the record that reseller publishes for it, and the owner's
+ // preview record is never projected onto it.
+ const catalog = await loadFixtureCatalog(t, {
+ gateway: { api: "https://gateway.example/v1", models: {} },
+ google: { models: { "gemini-3-flash-preview": {
+ id: "gemini-3-flash-preview", tool_call: true, limit: { context: 1_048_576 },
+ } } },
+ "some-reseller": { models: { "google/gemini-3-flash": {
+ id: "google/gemini-3-flash", tool_call: true,
+ canonical_model_id: "google/gemini-3-flash-preview",
+ limit: { context: 1_000_000 },
+ } } },
+ });
+ const match = catalog.findModel({
+ vendorKey: "custom", baseUrl: "https://relay.example/v1", modelId: "gemini-3-flash",
+ });
+ assert.equal(match?.providerKey, "some-reseller", "the served id keeps its own publisher");
+ assert.equal(match?.limit.context, 1_000_000, "an uncorroborated alias never borrows the owner's capacity");
+});
+
+test("an ambiguous canonical translation stays unmatched", async (t) => {
+ // Two corroborated targets say the name maps two ways. The resellers disagree
+ // on capability flags, so no shared record answers either; nothing is claimed.
+ const catalog = await loadFixtureCatalog(t, {
+ gateway: { api: "https://gateway.example/v1", models: {} },
+ google: { models: {
+ "gemini-3-flash-preview": {
+ id: "gemini-3-flash-preview", tool_call: true, limit: { context: 1_048_576 },
+ },
+ "gemini-3-flash-lite": {
+ id: "gemini-3-flash-lite", tool_call: true, limit: { context: 1_000_000 },
+ },
+ } },
+ neon: { models: { "google/gemini-3-flash": {
+ id: "google/gemini-3-flash", tool_call: true,
+ modalities: { input: ["text", "image"], output: ["text"] },
+ canonical_model_id: "google/gemini-3-flash-preview",
+ limit: { context: 1_000_000 },
+ } } },
+ pioneer: { models: { "google/gemini-3-flash": {
+ id: "google/gemini-3-flash", tool_call: true,
+ canonical_model_id: "google/gemini-3-flash-preview",
+ limit: { context: 1_000_000 },
+ } } },
+ opencode: { models: { "google/gemini-3-flash": {
+ id: "google/gemini-3-flash", tool_call: true,
+ modalities: { input: ["text", "image"], output: ["text"] },
+ canonical_model_id: "google/gemini-3-flash-lite",
+ limit: { context: 1_000_000 },
+ } } },
+ vercel: { models: { "google/gemini-3-flash": {
+ id: "google/gemini-3-flash", tool_call: true,
+ canonical_model_id: "google/gemini-3-flash-lite",
+ limit: { context: 1_000_000 },
+ } } },
+ });
+ assert.equal(catalog.findModel({
+ vendorKey: "custom", baseUrl: "https://relay.example/v1", modelId: "gemini-3-flash",
+ }), undefined);
+});
+
+test("a canonical translation never displaces an id that already resolves", async (t) => {
+ // The relay's id is published outright by a reseller, so the ordinary lookup
+ // answers. A corroborated declaration pointing elsewhere must not override
+ // that: translation only fills a gap, it never rewrites a served name.
+ const catalog = await loadFixtureCatalog(t, {
+ gateway: { api: "https://gateway.example/v1", models: {} },
+ google: { models: { "gemini-3-flash-preview": {
+ id: "gemini-3-flash-preview", tool_call: true, limit: { context: 1_048_576 },
+ } } },
+ neon: { models: { "gemini-3-flash": {
+ id: "gemini-3-flash", tool_call: true,
+ canonical_model_id: "google/gemini-3-flash-preview",
+ limit: { context: 1_000_000 },
+ } } },
+ pioneer: { models: { "gemini-3-flash": {
+ id: "gemini-3-flash", tool_call: true,
+ canonical_model_id: "google/gemini-3-flash-preview",
+ limit: { context: 1_000_000 },
+ } } },
+ });
+ const match = catalog.findModel({
+ vendorKey: "custom", baseUrl: "https://relay.example/v1", modelId: "gemini-3-flash",
+ });
+ assert.equal(match?.modelId, "gemini-3-flash", "the served id keeps its own record");
+});
diff --git a/docs/spec/03-runtime/13-model-catalog-and-selection.md b/docs/spec/03-runtime/13-model-catalog-and-selection.md
index e6df84ac2..c86fb024d 100644
--- a/docs/spec/03-runtime/13-model-catalog-and-selection.md
+++ b/docs/spec/03-runtime/13-model-catalog-and-selection.md
@@ -290,9 +290,18 @@ weight owner's published record when that owner names the model. This record
outranks shared reseller matches without changing the configured wire ID.
Lookup accepts dotted/dashed version notation, one whitelisted deployment
label, and the owner's published canonical generation ID; semantic variants
-and unpublished generations remain distinct. If owner aliases disagree on
-capabilities or limits, no owner record is borrowed. When the owner publishes
-no matching record, the existing shared catalog matching rules still apply.
+and unpublished generations remain distinct. The owner's own sibling keys
+(regional, token-plan and coding-plan) are consulted as added evidence when the
+public key states nothing, so a generation the vendor ships only on one of its
+keys still resolves; a sibling key never vetoes an answer the public key
+already gave. When the relay names a generation the owner publishes under
+another ID, models.dev's own canonical declaration translates the name, but
+only when at least two distinct publishers corroborate the same owner-prefixed
+target and the ordinary lookup resolved nothing — the capacity still comes from
+the owner's record for the translated ID, never from the declarers. If owner
+aliases disagree on capabilities or limits, no owner record is borrowed. When
+the owner publishes no matching record, the existing shared catalog matching
+rules still apply.
`source: "cache"` reads Host caches and configured bindings without network.
`source: "refresh"` probes the selected endpoint/account and decorates returned
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index c8d903125..606f80773 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -1070,8 +1070,11 @@ identify the platform validation still needed.
the endpoint takes precedence over the catalog for that field; omitted fields
independently use catalog metadata. For an unanchored relay, a published
owner record outranks reseller matches; dotted/dashed version aliases and one
- whitelisted deployment label keep the served ID intact, and conflicting
- owner records do not supply guessed limits.
+ whitelisted deployment label keep the served ID intact, the owner's sibling
+ keys add evidence when the public key states nothing, and a corroborated
+ canonical declaration translates a name the owner publishes under another ID
+ without rewriting the served ID. Conflicting owner records do not supply
+ guessed limits.
- **Specs linked**: `03-runtime/12-provider-config-schema.md`, `03-runtime/13-model-catalog-and-selection.md`
- **Acceptance**: B (multi-model provider configuration)
- **Milestone**: M2
diff --git a/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.md b/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.md
index 84f3e50ae..e8a271b8b 100644
--- a/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.md
+++ b/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.md
@@ -56,6 +56,7 @@ AI 服务和 OAuth 厂商账户编辑器共用已选模型面板。每个已选
- 能力徽章
- 可选的上下文窗口
- 服务模型列表为某字段报告正安全整数上下文/输入或输出上限时,该值优先于目录;未报告的字段独立回退到目录值。缺失或非正数不作猜测。
+- 未锚定的中转站(OpenAI 兼容)服务已知模型家族时,可读取权重所有者的已发布记录,该记录优先于转售商共识且不改写配置的线上 ID;所有者的地区/套餐兄弟键仅在其公开键未表态时作为补充证据,不会否决公开键的结论。仅当普通查找无结果、且至少两个不同发布者一致声明同一所有者前缀目标时,才按 models.dev 的 canonical 声明做名称换算,容量始终取自所有者自己的记录。所有者别名在能力或上限上互相矛盾时不借用任何所有者记录。
- 上限值与用量计数经同一个紧凑格式化函数(`formatCompactTokenCount`)渲染:
`M` 量级最多两位小数、`K` 量级一位小数,去掉末尾零;`K` 尾数若进位到 1000
则提升到 `M` 量级。1M 附近的已发布窗口因此保持可区分(1000000 显示 `1M`,