mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-15 11:22:15 +03:00
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.
78 lines
3.6 KiB
TypeScript
78 lines
3.6 KiB
TypeScript
// #2942 — rolling-window prompt memory for deepseek-web. The web API takes only a single
|
|
// `prompt` string, so multi-turn context must be stitched into that prompt. With an
|
|
// explicit `historyWindow > 0`, the last N turns are stitched into a role-tagged
|
|
// transcript.
|
|
//
|
|
// #10527 — with the window unset/<=0 (default), a genuinely multi-turn conversation
|
|
// (any assistant turn present, or more than one user turn) now auto-replays a bounded
|
|
// trajectory instead of the old "system + last user only" behavior, which silently
|
|
// dropped the original task for agentic clients (Cline) that never send OpenAI-native
|
|
// `tools[]`. Only a genuinely single-turn request (one user message, no assistant turns)
|
|
// keeps the minimal "system + last user only" prompt.
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const { messagesToPrompt } = await import("../../open-sse/executors/deepseek-web.ts");
|
|
|
|
const CONVO = [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: "first question" },
|
|
{ role: "assistant", content: "first answer" },
|
|
{ role: "user", content: "second question" },
|
|
];
|
|
|
|
test("window 0 (default) on a multi-turn conversation auto-replays the bounded trajectory (#10527)", () => {
|
|
const prompt = messagesToPrompt(CONVO, 0);
|
|
assert.ok(prompt.includes("You are helpful."), "system prompt present");
|
|
assert.ok(prompt.includes("second question"), "last user message present");
|
|
assert.ok(prompt.includes("first question"), "earlier user turn must survive (#10527)");
|
|
assert.ok(prompt.includes("first answer"), "assistant turn must survive (#10527)");
|
|
});
|
|
|
|
test("default call (no window arg) on a multi-turn conversation behaves like window 0 (#10527)", () => {
|
|
const prompt = messagesToPrompt(CONVO);
|
|
assert.ok(prompt.includes("second question"));
|
|
assert.ok(prompt.includes("first answer"), "assistant turn must survive (#10527)");
|
|
});
|
|
|
|
test("window 0 (default) on a genuinely single-turn request keeps the minimal system + last-user-only prompt", () => {
|
|
const singleTurn = [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: "second question" },
|
|
];
|
|
const prompt = messagesToPrompt(singleTurn, 0);
|
|
assert.equal(prompt, "You are helpful.\n\nsecond question");
|
|
});
|
|
|
|
test("window > 0 stitches recent turns into a role-tagged transcript", () => {
|
|
const prompt = messagesToPrompt(CONVO, 10);
|
|
assert.ok(prompt.includes("You are helpful."), "system prompt still leads");
|
|
assert.ok(prompt.includes("first question"), "earlier user turn carried");
|
|
assert.ok(prompt.includes("first answer"), "assistant turn carried");
|
|
assert.ok(prompt.includes("second question"), "latest user turn carried");
|
|
assert.ok(/User:\s*first question/.test(prompt), "user turns role-tagged");
|
|
assert.ok(/Assistant:\s*first answer/.test(prompt), "assistant turns role-tagged");
|
|
});
|
|
|
|
test("window caps to the last N non-system turns", () => {
|
|
const long = [
|
|
{ role: "system", content: "sys" },
|
|
{ role: "user", content: "u1" },
|
|
{ role: "assistant", content: "a1" },
|
|
{ role: "user", content: "u2" },
|
|
{ role: "assistant", content: "a2" },
|
|
{ role: "user", content: "u3" },
|
|
];
|
|
const prompt = messagesToPrompt(long, 2);
|
|
// last 2 non-system turns are a2 + u3
|
|
assert.ok(prompt.includes("a2"), "second-to-last turn present");
|
|
assert.ok(prompt.includes("u3"), "last turn present");
|
|
assert.ok(!prompt.includes("u1"), "older turn dropped");
|
|
assert.ok(!prompt.includes("a1"), "older turn dropped");
|
|
assert.ok(prompt.includes("sys"), "system prompt always present");
|
|
});
|
|
|
|
test("empty messages -> empty prompt", () => {
|
|
assert.equal(messagesToPrompt([], 10), "");
|
|
});
|