mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +03:00
OmniRoute v3.8.26 — see CHANGELOG.md [3.8.26] for the full notes. Highlights: Vertex AI media generation (#3929), GLM-5.2 effort-tier routing (#3885), sticky round-robin combos (#3846), OpenRouter connection presets (#3878), compression prompt-cache fix (#3936/#3890), and a security pass (form-data/vite + workflow hardening, #3949). Co-authored-by: artickc <artickc@users.noreply.github.com> Co-authored-by: rdself <rdself@users.noreply.github.com> Co-authored-by: herjarsa <herjarsa@users.noreply.github.com> Co-authored-by: Jack Smith <16862258+YunyunZhai@users.noreply.github.com> Co-authored-by: dhaern <dhaern@users.noreply.github.com> Co-authored-by: adivekar-utexas <adivekar-utexas@users.noreply.github.com> Co-authored-by: megamen32 <megamen32@users.noreply.github.com> Co-authored-by: zhiru <zhiru@users.noreply.github.com> Co-authored-by: insoln <insoln@users.noreply.github.com> Co-authored-by: diego-anselmo <diego-anselmo@users.noreply.github.com>
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
/**
|
|
* Tests for #3890: the cache-aware `skipSystemPrompt` flag was computed by
|
|
* getCacheAwareStrategy() but dropped by selectCompressionStrategy() (which can only
|
|
* return a mode string). resolveCacheAwareConfig() applies it: in a caching context the
|
|
* system prompt must stay uncompressed (it is part of the cacheable prefix) even when the
|
|
* operator disabled preserveSystemPrompt.
|
|
*/
|
|
|
|
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { resolveCacheAwareConfig } from "../../../open-sse/services/compression/strategySelector.ts";
|
|
import type { CompressionConfig } from "../../../open-sse/services/compression/types.ts";
|
|
|
|
function cfg(overrides: Partial<CompressionConfig> = {}): CompressionConfig {
|
|
return {
|
|
enabled: true,
|
|
defaultMode: "standard",
|
|
autoTriggerTokens: 0,
|
|
cacheMinutes: 5,
|
|
preserveSystemPrompt: true,
|
|
comboOverrides: {},
|
|
...overrides,
|
|
} as CompressionConfig;
|
|
}
|
|
|
|
describe("resolveCacheAwareConfig (#3890)", () => {
|
|
it("forces preserveSystemPrompt on for a caching request that disabled it", () => {
|
|
const out = resolveCacheAwareConfig(
|
|
cfg({ preserveSystemPrompt: false }),
|
|
{ messages: [{ role: "system", content: "x", cache_control: { type: "ephemeral" } }] },
|
|
{ provider: "anthropic", targetFormat: "claude" }
|
|
);
|
|
assert.equal(out.preserveSystemPrompt, true);
|
|
});
|
|
|
|
it("leaves a non-caching request untouched (preserveSystemPrompt stays false)", () => {
|
|
const out = resolveCacheAwareConfig(
|
|
cfg({ preserveSystemPrompt: false }),
|
|
{ messages: [{ role: "system", content: "x" }] },
|
|
{ provider: "openai" }
|
|
);
|
|
assert.equal(out.preserveSystemPrompt, false);
|
|
});
|
|
|
|
it("returns the same config object when there is no body", () => {
|
|
const base = cfg({ preserveSystemPrompt: false });
|
|
assert.equal(resolveCacheAwareConfig(base), base);
|
|
});
|
|
|
|
it("does not change a config that already preserves the system prompt", () => {
|
|
const out = resolveCacheAwareConfig(
|
|
cfg({ preserveSystemPrompt: true }),
|
|
{ messages: [{ role: "system", content: "x", cache_control: { type: "ephemeral" } }] },
|
|
{ provider: "anthropic", targetFormat: "claude" }
|
|
);
|
|
assert.equal(out.preserveSystemPrompt, true);
|
|
});
|
|
});
|