Files
OmniRoute/tests/unit/m365-tone-model-variants.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

61 lines
2.9 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
M365_MODEL_TONE_MAP,
resolveToneForModel,
resolveChatInvocationOverrides,
} from "../../open-sse/executors/copilot-m365-frames.ts";
import { copilot_m365_webProvider } from "../../open-sse/config/providers/registry/copilot-m365-web/index.ts";
// #7872 — tone-selected model variants for copilot-m365-web.
// The wiring (model id → tone → invocation payload) is unit-tested here; whether a tone
// actually selects that model upstream is a live enterprise-tenant check (release-drain).
test("resolveToneForModel maps each variant id to its confirmed tone", () => {
assert.equal(resolveToneForModel("copilot-m365-claude-opus"), "Claude_Opus");
assert.equal(resolveToneForModel("copilot-m365-gpt-5-6-reasoning"), "Gpt_5_6_Reasoning");
assert.equal(resolveToneForModel("copilot-m365-gpt-5-5-chat"), "Gpt_5_5_Chat");
});
test("resolveToneForModel returns undefined for the bare id and unknown ids", () => {
// bare id must fall back to the tier default, not a hard-coded tone
assert.equal(resolveToneForModel("copilot-m365"), undefined);
assert.equal(resolveToneForModel("totally-unknown"), undefined);
assert.equal(resolveToneForModel(undefined), undefined);
assert.equal(resolveToneForModel(""), undefined);
});
test("model-driven tone overrides the tier default; bare id keeps the tier tone", () => {
const enterprise = resolveChatInvocationOverrides("enterprise");
const individual = resolveChatInvocationOverrides(undefined);
// enterprise tier default tone is Magic; individual/EDU now also sends
// "Magic" (capitalized) — the 2026-08-21 capture (#11069) showed lowercase
// "magic" is part of the shape that gets silently dropped (ping-only socket).
assert.equal(enterprise.tone, "Magic");
assert.equal(individual.tone, "Magic");
// precedence: resolveToneForModel(model) ?? overrides.tone (mirrors the executor wiring)
const toneFor = (model: string | undefined, tierTone: string) =>
resolveToneForModel(model) ?? tierTone;
// a variant id wins over BOTH tier defaults
assert.equal(toneFor("copilot-m365-claude-opus", enterprise.tone), "Claude_Opus");
assert.equal(toneFor("copilot-m365-claude-opus", individual.tone), "Claude_Opus");
// the bare id keeps whatever the tier resolved (both "Magic" post-#11069)
assert.equal(toneFor("copilot-m365", enterprise.tone), "Magic");
assert.equal(toneFor("copilot-m365", individual.tone), "Magic");
});
test("registry exposes the bare id (first) plus every tone variant", () => {
const ids = copilot_m365_webProvider.models.map((m) => m.id);
assert.equal(ids[0], "copilot-m365", "bare Auto/default id must be first");
for (const variantId of Object.keys(M365_MODEL_TONE_MAP)) {
assert.ok(ids.includes(variantId), `registry missing variant ${variantId}`);
}
// no duplicate ids
assert.equal(ids.length, new Set(ids).size);
});