Skip to content

Commit 99c63db

Browse files
committed
fix(catalog): restore architecture modalities; tighten docs and tests
Rebuild resolveComboCatalogMember on current provider-fetch so the Nebius architecture.modality path is not regressed. Document maxInputTokens before the 128k fallback and that disabled providers never catalog. Pin contextCapped falsy when a high cap does not clamp.
1 parent 39f677c commit 99c63db

4 files changed

Lines changed: 29 additions & 24 deletions

File tree

‎docs-site/src/content/docs/reference/configuration/routing.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ A combo remains directly routable even when it cannot be listed. `ocx sync`, `/v
183183
Codex picker list it only when every target exposes capabilities that can be intersected:
184184

185185
- a positive `contextWindow`, from live metadata, registry hints, provider
186-
`modelContextWindows` / `contextWindow`, or — when the provider is known but every source
187-
omits a window — a conservative 128,000-token fallback (clamped by `providerContextCaps` when
188-
set); and
186+
`modelContextWindows` / `contextWindow`, a known positive `maxInputTokens` on the member row,
187+
or — when the provider is known and enabled but every source still omits a window — a
188+
conservative 128,000-token fallback (clamped by `providerContextCaps` when set); and
189189
- a non-empty `inputModalities` intersection, treating an omitted member value as `["text"]`.
190190

191-
A target on an unknown/disabled provider with no discovery row, or targets with disjoint modalities,
192-
removes the combo from the catalog. Sync emits a summary warning and the dashboard marks it
193-
**Needs attention**. Add context metadata, align modalities, or target models with discoverable
194-
compatible capabilities.
191+
A target on a disabled provider (even with a complete discovery row), on an unknown provider with
192+
no discovery row, or targets with disjoint modalities, removes the combo from the catalog. Sync
193+
emits a summary warning and the dashboard marks it **Needs attention**. Add context metadata,
194+
align modalities, or target models with discoverable compatible capabilities.
195195

196196
## Request history and routing analytics
197197

‎docs-site/src/content/docs/zh-cn/reference/configuration/routing.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ selector 校验、冲突规则和隐私说明见[提供方配置](/reference/con
8383
即使某个 combo 不能被列出,它仍然可以直接路由。只有当所有目标都暴露出可以交集的能力时,`ocx sync`、`/v1/models` 和 Codex 选择器才会列出它:
8484

8585
- 一个正的 `contextWindow`,来源可以是实时元数据、注册表提示、提供方的
86-
`modelContextWindows` / `contextWindow`,或者——当提供方已知但所有来源都未给出窗口时——
86+
`modelContextWindows` / `contextWindow`、成员行上已知的正 `maxInputTokens`,或者——当提供方已知且启用但所有来源仍未给出窗口时——
8787
保守的 128,000 token 回退(若配置了 `providerContextCaps` 则会按上限夹紧);以及
8888
- 非空的 `inputModalities` 交集,其中省略的成员值按 `["text"]` 处理。
8989

90-
目标位于未知/已禁用且无 discovery 行的提供方,或目标之间的模态互不相交时,combo 会从
90+
目标位于已禁用提供方(即使有完整 discovery 行)、未知且无 discovery 行的提供方,或目标之间的模态互不相交时,combo 会从
9191
目录中移除。同步时会输出一条汇总警告,仪表板会将其标记为 **Needs attention**。
9292
补充上下文元数据、对齐模态,或者把目标模型切换为可发现且兼容的能力。
9393

‎src/codex/catalog/provider-fetch.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ export function applyConfigHintsToCachedModels(name: string, prov: OcxProviderCo
607607
return models.map(model => applyProviderConfigHints(name, prov, model, contextCap));
608608
}
609609

610+
610611
/**
611612
* Last-resort context window for combo member synthesis when discovery and
612613
* provider config both omit one. Matches the catalog entry default in
@@ -619,9 +620,9 @@ const COMBO_MEMBER_CONTEXT_FALLBACK = 128_000;
619620
* Prefer discovery metadata; when the target is missing from the gather map or
620621
* lacks a positive contextWindow, synthesize from the (registry-enriched)
621622
* provider config so combos remain catalogued when targets are configured but
622-
* discovery metadata is incomplete. Disabled/missing providers stay unresolved.
623-
* When hints still omit contextWindow, apply COMBO_MEMBER_CONTEXT_FALLBACK so a
624-
* live row without ctx (common for LiteLLM / custom xai ids) does not drop the
623+
* discovery metadata is incomplete. Disabled providers stay unresolved.
624+
* When hints still omit contextWindow, prefer known maxInputTokens, else
625+
* COMBO_MEMBER_CONTEXT_FALLBACK so a live row without ctx does not drop the
625626
* whole combo from the public catalog.
626627
*/
627628
export function resolveComboCatalogMember(
@@ -661,8 +662,6 @@ export function resolveComboCatalogMember(
661662
id: target.model,
662663
provider: target.provider,
663664
};
664-
// Reuse the same hint path configured/static catalog rows use when a provider
665-
// config exists; otherwise keep the base (possibly incomplete) discovery row.
666665
const hinted = prov
667666
? applyProviderConfigHints(target.provider, prov, base, contextCap)
668667
: base;
@@ -676,16 +675,10 @@ export function resolveComboCatalogMember(
676675
: (typeof base.maxInputTokens === "number" && base.maxInputTokens > 0
677676
? base.maxInputTokens
678677
: undefined);
679-
// Prefer config/discovery; fall back so incomplete live rows still catalog.
680-
// Pure ghosts (no discovery row) on a known provider still synthesize: live
681-
// discovery is often incomplete for LiteLLM/custom relays, and dropping the
682-
// whole combo solely for a missing /v1/models row is worse than a stub window.
683678
const uncappedContext = hintedContext
684679
?? knownMaxInput
685680
?? (existing || prov ? COMBO_MEMBER_CONTEXT_FALLBACK : undefined);
686681
if (uncappedContext === undefined) return undefined;
687-
// Fallback bypasses applyProviderConfigHints' cap path — clamp here so a
688-
// providerContextCaps value below 128k still wins (same semantics as hints).
689682
const usedFallback = hintedContext === undefined;
690683
const cappedContext = applyProviderContextCap(uncappedContext, contextCap);
691684
const contextWindow = cappedContext ?? uncappedContext;
@@ -695,8 +688,6 @@ export function resolveComboCatalogMember(
695688
&& cappedContext !== uncappedContext;
696689

697690
const inputModalities = hinted.inputModalities ?? base.inputModalities ?? ["text"];
698-
// applyProviderConfigHints already folds configuredReasoningEfforts; keep an
699-
// explicit fallback for stubs that only had base fields.
700691
const reasoningEfforts = hinted.reasoningEfforts
701692
?? (prov ? configuredReasoningEfforts(prov, target.model) : undefined)
702693
?? base.reasoningEfforts;
@@ -843,6 +834,17 @@ function modelInputModalities(
843834
value === "text" || value === "image" || value === "audio"
844835
));
845836
if (explicit && explicit.length > 0) return explicit;
837+
const architecture = plainRecord(item.architecture);
838+
const architectureModality = typeof architecture?.modality === "string"
839+
? normalizedMetadataString(architecture.modality, 64)
840+
: undefined;
841+
if (architectureModality?.includes("->")) {
842+
const [rawInput = ""] = architectureModality.split("->");
843+
const inferred = rawInput
844+
.split("+")
845+
.filter(value => value === "text" || value === "image" || value === "audio");
846+
if (inferred.length > 0) return [...new Set(inferred)];
847+
}
846848
if (capabilityRecord?.vision === false) return ["text"];
847849
if (capabilityRecord?.vision === true || capabilities?.some(value => value === "vision" || value === "image-input")) {
848850
return ["text", "image"];

‎tests/codex-catalog.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,15 +841,18 @@ describe("combo catalog capability intersection", () => {
841841
contextCapped: true,
842842
});
843843
// Cap above the fallback leaves 128k (no artificial raise, no capped flag).
844-
expect(resolveComboCatalogMember(
844+
const aboveCap = resolveComboCatalogMember(
845845
{ provider: "a", model: "ghost" },
846846
new Map(),
847847
new Map([["a", { adapter: "openai-chat", baseUrl: "https://a.example/v1" }]]),
848848
200_000,
849-
)).toMatchObject({
849+
);
850+
expect(aboveCap).toMatchObject({
850851
contextWindow: 128_000,
851852
maxInputTokens: 128_000,
852853
});
854+
// Cap may be recorded for bookkeeping (contextCapped: false) but must not claim a clamp.
855+
expect(aboveCap?.contextCapped).toBeFalsy();
853856
// No provider entry and no discovery row — cannot invent a member.
854857
expect(resolveComboCatalogMember(
855858
{ provider: "missing", model: "ghost" },

0 commit comments

Comments
 (0)