Files
OmniRoute/tests/unit/cursor-live-catalog-passthrough.test.ts
Praveen K Palaniswamy 65e81158ab fix(ollama): route models by advertised capability (#11088)
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host.

Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean.

Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
2026-08-23 11:45:01 -03:00

91 lines
3.3 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
resolveRequestedModel,
encodeAgentRunRequest,
} from "../../open-sse/utils/cursorAgentProtobuf";
import { CURSOR_REWRITE_FAILURE_IDS } from "./fixtures/cursor-rewrite-failure-ids";
test("resolveRequestedModel passes live-catalog Claude effort ids through verbatim", () => {
const live = new Set(["claude-opus-5-low"]);
assert.deepEqual(resolveRequestedModel("claude-opus-5-low", { liveCatalogIds: live }), {
modelId: "claude-opus-5-low",
parameters: [],
});
});
test("resolveRequestedModel passes live-catalog GPT reasoning ids through verbatim", () => {
const live = new Set(["gpt-5.6-sol-medium"]);
assert.deepEqual(resolveRequestedModel("gpt-5.6-sol-medium", { liveCatalogIds: live }), {
modelId: "gpt-5.6-sol-medium",
parameters: [],
});
});
test("resolveRequestedModel still strips effort when id is absent from live catalog", () => {
const live = new Set(["composer-2"]);
assert.deepEqual(resolveRequestedModel("claude-opus-5-low", { liveCatalogIds: live }), {
modelId: "claude-opus-5",
parameters: [{ id: "effort", value: "low" }],
});
assert.deepEqual(resolveRequestedModel("gpt-5.5-high", { liveCatalogIds: live }), {
modelId: "gpt-5.5",
parameters: [{ id: "reasoning", value: "high" }],
});
});
test("resolveRequestedModel still strips effort when liveCatalogIds is omitted", () => {
assert.deepEqual(resolveRequestedModel("claude-opus-4-8-high"), {
modelId: "claude-opus-4-8",
parameters: [{ id: "effort", value: "high" }],
});
});
test("resolveRequestedModel maps auto to default even when auto is in the live catalog", () => {
const live = new Set(["auto", "auto-cost", "claude-opus-5-low"]);
assert.deepEqual(resolveRequestedModel("auto", { liveCatalogIds: live }), {
modelId: "default",
parameters: [],
});
assert.deepEqual(resolveRequestedModel("auto-cost", { liveCatalogIds: live }), {
modelId: "default",
parameters: [{ id: "optimization", value: "cost" }],
});
});
test("resolveRequestedModel passes composer-*-fast through when present in live catalog", () => {
const live = new Set(["composer-2.5-fast", "composer-2-fast"]);
assert.deepEqual(resolveRequestedModel("composer-2.5-fast", { liveCatalogIds: live }), {
modelId: "composer-2.5-fast",
parameters: [],
});
assert.deepEqual(resolveRequestedModel("composer-2-fast", { liveCatalogIds: live }), {
modelId: "composer-2-fast",
parameters: [],
});
});
test("resolveRequestedModel passes every rewrite-failure id through when all are live", () => {
const live = new Set<string>(CURSOR_REWRITE_FAILURE_IDS);
for (const id of CURSOR_REWRITE_FAILURE_IDS) {
assert.deepEqual(
resolveRequestedModel(id, { liveCatalogIds: live }),
{ modelId: id, parameters: [] },
id
);
}
});
test("encodeAgentRunRequest embeds verbatim live catalog model id", () => {
const live = new Set(["claude-opus-5-low"]);
const buf = encodeAgentRunRequest({
modelId: "claude-opus-5-low",
userText: "hi",
liveCatalogIds: live,
});
const text = buf.toString("latin1");
const full = text.split("claude-opus-5-low").length - 1;
assert.ok(full >= 4, `verbatim id must appear in RequestedModel + ModelDetails (got ${full})`);
assert.ok(!text.includes("effort"), "must not emit effort parameter for live verbatim id");
});