mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-15 03:12:36 +03:00
fix(routing): stop reactive-compaction log from lying when compression is disabled (#11977)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
- fix(routing): stop the reactive-compaction debug log from lying when compression is globally disabled (#11977)
|
||||
@@ -1958,7 +1958,9 @@ export async function handleChatCore({
|
||||
if (!promptCompressionEnabled) {
|
||||
log?.debug?.(
|
||||
"CONTEXT",
|
||||
"Prompt Compression engines disabled; reactive context compaction still applies when over threshold"
|
||||
reactiveContextCompactionEnabled
|
||||
? "Prompt Compression engines disabled; reactive context compaction still applies when over threshold"
|
||||
: "Prompt Compression engines disabled; reactive context compaction is ALSO disabled — large histories will NOT be trimmed before reaching the upstream provider"
|
||||
);
|
||||
}
|
||||
if (isCombo && comboName) {
|
||||
|
||||
71
tests/unit/chatcore-stale-compaction-log.test.mjs
Normal file
71
tests/unit/chatcore-stale-compaction-log.test.mjs
Normal file
@@ -0,0 +1,71 @@
|
||||
// Regression guard for #11977: the diagnostic log fired unconditionally whenever
|
||||
// promptCompressionEnabled was false, claiming "reactive context compaction still
|
||||
// applies when over threshold" even on a default install where
|
||||
// reactiveContextCompactionEnabled is ALSO false (DEFAULT_COMPRESSION_CONFIG.enabled
|
||||
// === false, per #9200's gating). That left operators with zero diagnostic signal for
|
||||
// the real failure mode: large histories reaching the upstream provider untrimmed
|
||||
// (e.g. Antigravity's 400 once session history grows past its real request-size
|
||||
// ceiling). The fix branches the log on reactiveContextCompactionEnabled so the
|
||||
// message reflects which safety net, if any, is actually still active.
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
const source = readFileSync(
|
||||
new URL("../../open-sse/handlers/chatCore.ts", import.meta.url),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
test("gating expressions exist as documented (sanity check, tracks real source)", () => {
|
||||
assert.match(
|
||||
source,
|
||||
/let promptCompressionEnabled =\s*\n\s*compressionSettingsResult\.enabled && !compressionExcluded && apiKeyCompressionEnabled;/
|
||||
);
|
||||
assert.match(
|
||||
source,
|
||||
/reactiveContextCompactionEnabled = compressionSettingsResult\.enabled && !compressionExcluded;/
|
||||
);
|
||||
});
|
||||
|
||||
test("on default install, reactiveContextCompactionEnabled is provably false whenever the log fires", () => {
|
||||
const compressionSettingsResultEnabled = false; // DEFAULT_COMPRESSION_CONFIG.enabled
|
||||
const compressionExcluded = false;
|
||||
const apiKeyCompressionEnabled = true;
|
||||
|
||||
const promptCompressionEnabled =
|
||||
compressionSettingsResultEnabled && !compressionExcluded && apiKeyCompressionEnabled;
|
||||
const reactiveContextCompactionEnabled = compressionSettingsResultEnabled && !compressionExcluded;
|
||||
|
||||
const logFires = !promptCompressionEnabled;
|
||||
|
||||
assert.equal(logFires, true, "the log fires on every default-config request");
|
||||
assert.equal(
|
||||
reactiveContextCompactionEnabled,
|
||||
false,
|
||||
"reactive compaction is ALSO disabled here — the old unconditional message was false for this branch"
|
||||
);
|
||||
});
|
||||
|
||||
test("the log statement branches on reactiveContextCompactionEnabled so it stays accurate in both cases", () => {
|
||||
const blockMatch = source.match(
|
||||
/if \(!promptCompressionEnabled\) \{[\s\S]{0,400}\}/
|
||||
);
|
||||
assert.ok(blockMatch, "expected to find the promptCompressionEnabled debug-log block");
|
||||
const block = blockMatch[0];
|
||||
|
||||
assert.match(
|
||||
block,
|
||||
/reactiveContextCompactionEnabled/,
|
||||
"expected the debug-log block to branch on reactiveContextCompactionEnabled"
|
||||
);
|
||||
assert.match(
|
||||
block,
|
||||
/still applies when over threshold/,
|
||||
"expected the true-branch message (reactive compaction still active) to be preserved"
|
||||
);
|
||||
assert.match(
|
||||
block,
|
||||
/reactive context compaction is ALSO disabled/,
|
||||
"expected a distinct false-branch message for the fully-disabled default-install case"
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user