From c6dcd74433d47d459b1d18a25eda1da3e2198f42 Mon Sep 17 00:00:00 2001 From: aldoeliacim Date: Sun, 1 Nov 2026 00:56:50 -0600 Subject: [PATCH 1/2] test(compression): verify unchanged-history prefix reuse --- ...4-live-zone-history-regression-coverage.md | 1 + tests/unit/compression/live-zone.test.ts | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 changelog.d/fixes/18304-live-zone-history-regression-coverage.md diff --git a/changelog.d/fixes/18304-live-zone-history-regression-coverage.md b/changelog.d/fixes/18304-live-zone-history-regression-coverage.md new file mode 100644 index 000000000000..89f1543230ae --- /dev/null +++ b/changelog.d/fixes/18304-live-zone-history-regression-coverage.md @@ -0,0 +1 @@ +- **test(compression):** cover unchanged live-zone histories for both Chat Completions `messages` and Responses `input`, including frozen-prefix reuse, current request controls, and avoiding unnecessary compressor calls. This is regression coverage for existing source behavior, not a demonstrated fix for an upstream safety refusal. diff --git a/tests/unit/compression/live-zone.test.ts b/tests/unit/compression/live-zone.test.ts index f611d9048f89..372a92d4ac58 100644 --- a/tests/unit/compression/live-zone.test.ts +++ b/tests/unit/compression/live-zone.test.ts @@ -257,4 +257,36 @@ describe("cache-aligned live-zone compression", () => { assert.equal((calls[1].messages as unknown[]).length, 2); assert.equal(getLiveZoneCacheStats().entries, 0); }); + + for (const field of ["messages", "input"] as const) { + it(`preserves an unchanged ${field} history and current request controls`, async () => { + const calls: Array> = []; + const compress = toolCompressor(calls); + const first = { + model: "synthetic-model", + stream: false, + max_output_tokens: 1024, + reasoning: { effort: "medium" }, + instructions: "stable instructions", + [field]: [ + { role: "user", content: "user turn" }, + { role: "tool", content: "tool output" }, + ], + }; + const firstResult = await applyLiveZoneCompression(first, options, compress); + const repeated = { ...first, stream: true, max_output_tokens: 2048 }; + const unchangedResult = await applyLiveZoneCompression(repeated, options, compress); + + assert.equal(calls.length, 1, "unchanged history must not rerun the compressor"); + assert.deepEqual(unchangedResult.body, { + ...repeated, + [field]: firstResult.body[field], + }); + assert.deepEqual(unchangedResult.stats?.liveZone, { + cacheHit: true, + frozenItems: first[field].length, + liveItems: 0, + }); + }); + } }); From 3080e566f3f6385daba24b4f36f83357914e02ee Mon Sep 17 00:00:00 2001 From: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Date: Sun, 1 Nov 2026 23:05:14 -0300 Subject: [PATCH 2/2] test(compression): cover fail-open when instructions change on an unchanged history Keep the prefix-reuse pair and add its counterpart: changed instructions must rerun the compressor. Move the changelog fragment to maintenance, since this is coverage and not a fix. --- ...4-live-zone-history-regression-coverage.md | 1 - ...4-live-zone-history-regression-coverage.md | 1 + tests/unit/compression/live-zone.test.ts | 20 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) delete mode 100644 changelog.d/fixes/18304-live-zone-history-regression-coverage.md create mode 100644 changelog.d/maintenance/18304-live-zone-history-regression-coverage.md diff --git a/changelog.d/fixes/18304-live-zone-history-regression-coverage.md b/changelog.d/fixes/18304-live-zone-history-regression-coverage.md deleted file mode 100644 index 89f1543230ae..000000000000 --- a/changelog.d/fixes/18304-live-zone-history-regression-coverage.md +++ /dev/null @@ -1 +0,0 @@ -- **test(compression):** cover unchanged live-zone histories for both Chat Completions `messages` and Responses `input`, including frozen-prefix reuse, current request controls, and avoiding unnecessary compressor calls. This is regression coverage for existing source behavior, not a demonstrated fix for an upstream safety refusal. diff --git a/changelog.d/maintenance/18304-live-zone-history-regression-coverage.md b/changelog.d/maintenance/18304-live-zone-history-regression-coverage.md new file mode 100644 index 000000000000..742bc2e33cde --- /dev/null +++ b/changelog.d/maintenance/18304-live-zone-history-regression-coverage.md @@ -0,0 +1 @@ +- **test(compression):** cover unchanged live-zone histories for both Chat Completions `messages` and Responses `input`: frozen-prefix reuse, current request controls, no needless compressor call, and fail-open to full compression when `instructions` change. Regression coverage for existing behavior, with no production change ([#18304](https://github.com/cheaper-inference/OmniRoute/pull/18304)) — thanks @aldoeliacim diff --git a/tests/unit/compression/live-zone.test.ts b/tests/unit/compression/live-zone.test.ts index 372a92d4ac58..bf7295229865 100644 --- a/tests/unit/compression/live-zone.test.ts +++ b/tests/unit/compression/live-zone.test.ts @@ -288,5 +288,25 @@ describe("cache-aligned live-zone compression", () => { liveItems: 0, }); }); + + it(`recompresses an unchanged ${field} history when instructions change`, async () => { + const calls: Array> = []; + const compress = toolCompressor(calls); + const first = { + instructions: "stable instructions", + [field]: [ + { role: "user", content: "user turn" }, + { role: "tool", content: "tool output" }, + ], + }; + await applyLiveZoneCompression(first, options, compress); + const edited = { ...first, instructions: "edited instructions" }; + const editedResult = await applyLiveZoneCompression(edited, options, compress); + + assert.equal(calls.length, 2, "changed instructions must not reuse the frozen prefix"); + assert.equal(calls[1].instructions, "edited instructions"); + assert.deepEqual(calls[1][field], first[field]); + assert.equal(editedResult.body.instructions, "edited instructions"); + }); } });