From c3506e3a2ca870f4f898a3a700a4fad211dc9caa Mon Sep 17 00:00:00 2001 From: teamchong <25894545+teamchong@users.noreply.github.com> Date: Tue, 19 May 2026 17:33:34 -0400 Subject: [PATCH] fix(transform): flip compressHistory default to false Round-3 measurement on 2026-05-19 with 128-turn history showed the feature loses money: 21K chars of text replaced with 140K tokens of imagery, net -250% savings per request on this traffic shape. The MARGINAL warning has been in the code comments since the feature shipped - it was opt-in via --history / COMPRESS_HISTORY=1 originally for exactly this reason. The recent flag-removal commit flipped it on as default without re-verifying the savings claim against current traffic. The math in baselineCost() correctly reports negative savings when imgTokensEst > txtReplaced, so the dashboard was honest about the loss - the bug is shipping the feature on by default before measuring a positive delta on representative traffic. Re-enable per-deployment via env var when measurement confirms a positive saved_pct on the specific shape. --- src/core/transform.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/transform.ts b/src/core/transform.ts index 80a5d3e..6fb83ce 100644 --- a/src/core/transform.ts +++ b/src/core/transform.ts @@ -124,12 +124,14 @@ const DEFAULTS: Required = { // `find` over a big tree or `grep -r` can easily exceed this; the paging // marker tells the model what was elided. Tuneable per session. maxImagesPerToolResult: 10, - // Variant C history-image: ON. Single codepath — every compression - // mode the proxy supports is always active. Round-3 measurement called - // out ~3% cache-topology risk; that's mitigated by the static-slab - // cache_control placement which stays anchored on the system image and - // doesn't depend on history compression's image-replacement chain. - compressHistory: true, + // Variant C history-image: OFF. Round-3 spec called this MARGINAL + // (~1× per-call) against HIGH cache-topology risk. Live measurement on + // 2026-05-19 confirmed the warning: with 128-turn history, replacing + // ~21k chars of text with ~140k tokens of imagery LOSES money on every + // request. The math in `baselineCost` correctly reports negative savings + // when imgTokensEst > txtReplaced. Re-enable per-deployment only after + // measuring a positive delta on your specific traffic shape. + compressHistory: false, historyKeepTail: 4, historyMinPrefix: 10, // English ~4 chars/tok default (= the CHARS_PER_TOKEN constant declared