Files
OmniRoute/tests/unit/chatcore-noauth-echo-model-10571.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

46 lines
2.1 KiB
TypeScript

/**
* Regression test for PR #10571 — chatCore auto-echoes the listing-valid
* `<alias>/<model>` form in the response `model` field for bare (unprefixed)
* requests routed to a no-auth catalog provider (e.g. `opencode`), so clients
* that validate `response.model` against the provider's entry in
* `/v1/models` (which lists models under the provider's alias prefix) don't
* warn/reject.
*
* `resolveNoAuthEchoModel()` (`open-sse/handlers/chatCore/noAuthEchoModel.ts`)
* is a pure extraction of the inline logic chatCore.ts wires into its
* `echoModel` computation.
*/
import { test } from "node:test";
import assert from "node:assert/strict";
import { resolveNoAuthEchoModel } from "../../open-sse/handlers/chatCore/noAuthEchoModel.ts";
import { REGISTRY } from "../../open-sse/config/providerRegistry.ts";
test("aliases a bare model routed to a no-auth provider to <alias>/<model>", () => {
const alias = REGISTRY["opencode"]?.alias;
assert.ok(alias, "opencode must declare an alias in the registry for this test to be meaningful");
assert.equal(resolveNoAuthEchoModel("big-pickle", "opencode"), `${alias}/big-pickle`);
});
test("is a no-op (returns null) for an unregistered provider id", () => {
assert.equal(resolveNoAuthEchoModel("some-model", "provider-with-no-registry-entry"), null);
});
test("is a no-op (returns null) for a non-noAuth provider", () => {
assert.equal(resolveNoAuthEchoModel("gpt-5.5", "openai"), null);
});
test("is a no-op (returns null) when the requested model already has a provider prefix", () => {
assert.equal(resolveNoAuthEchoModel("opencode/big-pickle", "opencode"), null);
});
test("is a no-op (returns null) for empty/non-string requested model", () => {
assert.equal(resolveNoAuthEchoModel("", "opencode"), null);
assert.equal(resolveNoAuthEchoModel(null, "opencode"), null);
assert.equal(resolveNoAuthEchoModel(undefined, "opencode"), null);
});
test("is a no-op (returns null) for a null/undefined provider", () => {
assert.equal(resolveNoAuthEchoModel("big-pickle", null), null);
assert.equal(resolveNoAuthEchoModel("big-pickle", undefined), null);
});