mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-16 11:52:26 +03:00
Validated on the combined 12-PR batch board + the resolved merge against the post-#11232 tip: focused suites 73/73 (learned-reasoning-effort-caps, synced-capabilities-learned-effort-override, synced-effort-suffix-learned-validation, effort-tiers-loop-catalog-e2e, reasoning-effort-clamp-and-retry, reasoning-effort-learned-capability) + opencode-plugin effort-tier-variants 4/4, typecheck:core clean, gates within baseline. The stacked-branch conflict after #11232 squash-landed was resolved by hand (the learned-caps module keeps both the Set API and the new model-scoped lookup). The effort_tiers loop is closed end-to-end: catalog advertises exactly what the upstream accepts, and -<tier> suffix variants resolve against the learned set. Thank you @maxmad64bis!
99 lines
3.7 KiB
TypeScript
99 lines
3.7 KiB
TypeScript
/**
|
|
* effort_tiers loop — learned set overrides synced metadata in catalog
|
|
* capabilities (design 2026-08-23, decisions: appris > sync, in-memory).
|
|
* Records go through the REAL record path (executor-style connection keys)
|
|
* then read back through the catalog builders — proves the key-space bridge,
|
|
* unlike a unit injection of the same string on both sides.
|
|
*/
|
|
import { test, after, beforeEach } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
recordLearnedReasoningEffort,
|
|
__test_resetLearnedReasoningEffortCaps,
|
|
} from "../../open-sse/services/learnedReasoningEffortCaps.ts";
|
|
import {
|
|
buildSyncedCapabilities,
|
|
mergeSyncedCapabilities,
|
|
} from "../../src/app/api/v1/models/syncedCapabilities.ts";
|
|
|
|
beforeEach(() => __test_resetLearnedReasoningEffortCaps());
|
|
after(() => __test_resetLearnedReasoningEffortCaps());
|
|
|
|
const SYNC_TIERS = ["none", "low", "medium", "high", "xhigh"];
|
|
|
|
test("learned set replaces synced effort_tiers", () => {
|
|
recordLearnedReasoningEffort("openai-compatible-chat-eaff6869", "x-preview-f-free", [
|
|
"low",
|
|
"high",
|
|
"max",
|
|
]);
|
|
const caps = buildSyncedCapabilities(
|
|
{ id: "x-preview-f-free", supportedThinkingEfforts: SYNC_TIERS },
|
|
"huggingface"
|
|
);
|
|
assert.deepEqual(caps?.effort_tiers, ["low", "high", "max"]);
|
|
});
|
|
|
|
test("nothing learned keeps synced metadata untouched", () => {
|
|
const caps = buildSyncedCapabilities(
|
|
{ id: "some-synced-model", supportedThinkingEfforts: SYNC_TIERS },
|
|
"huggingface"
|
|
);
|
|
assert.deepEqual(caps?.effort_tiers, SYNC_TIERS);
|
|
});
|
|
|
|
test("neither learned nor synced yields undefined", () => {
|
|
const caps = buildSyncedCapabilities({ id: "plain-model" }, "huggingface");
|
|
assert.equal(caps, undefined);
|
|
});
|
|
|
|
test("merge path keeps vision AND applies the learned override", () => {
|
|
recordLearnedReasoningEffort("conn-a", "vision-model", ["low", "max"]);
|
|
const merged = mergeSyncedCapabilities(
|
|
{ tool_calling: true },
|
|
{ id: "vision-model", supportsVision: true, supportedThinkingEfforts: SYNC_TIERS },
|
|
"huggingface"
|
|
);
|
|
assert.equal(merged?.vision, true);
|
|
assert.equal(merged?.tool_calling, true);
|
|
assert.deepEqual(merged?.effort_tiers, ["low", "max"]);
|
|
});
|
|
|
|
// Exclusion gate (#7694): codex/glm/kimi already own a conflicting
|
|
// `-{effort}` suffix mechanism — the blind opencode-plugin mapping must never
|
|
// see effort_tiers for them, learned or synced, or it double-handles the suffix.
|
|
for (const ownedBy of ["codex", "glm", "glm-cn", "glmt", "kimi", "kimi-coding-apikey"]) {
|
|
test(`build: excluded provider "${ownedBy}" never gets effort_tiers (synced)`, () => {
|
|
const caps = buildSyncedCapabilities(
|
|
{ id: "excluded-model", supportedThinkingEfforts: SYNC_TIERS },
|
|
ownedBy
|
|
);
|
|
assert.equal(caps?.effort_tiers, undefined);
|
|
});
|
|
|
|
test(`build: excluded provider "${ownedBy}" never gets effort_tiers (learned)`, () => {
|
|
recordLearnedReasoningEffort(`conn-${ownedBy}`, "excluded-model", ["low", "max"]);
|
|
const caps = buildSyncedCapabilities(
|
|
{ id: "excluded-model", supportedThinkingEfforts: SYNC_TIERS },
|
|
ownedBy
|
|
);
|
|
assert.equal(caps?.effort_tiers, undefined);
|
|
});
|
|
}
|
|
|
|
test("excluded provider still gets vision through buildSyncedCapabilities", () => {
|
|
const caps = buildSyncedCapabilities({ id: "codex-vision-model", supportsVision: true }, "codex");
|
|
assert.deepEqual(caps, { vision: true });
|
|
});
|
|
|
|
test("merge path also excludes codex/glm/kimi from effort_tiers", () => {
|
|
recordLearnedReasoningEffort("conn-glm", "glm-model", ["low", "max"]);
|
|
const merged = mergeSyncedCapabilities(
|
|
{ tool_calling: true },
|
|
{ id: "glm-model", supportsVision: true, supportedThinkingEfforts: SYNC_TIERS },
|
|
"glm"
|
|
);
|
|
assert.equal(merged?.vision, true);
|
|
assert.equal(merged?.effort_tiers, undefined);
|
|
});
|