Files
OmniRoute/open-sse/services/compression/cacheAwareConfig.ts
Diego Rodrigues de Sa e Souza 898aac5771 feat(compression): QuantumLock cache-prefix stabilization (opt-in, default off) (#5260)
roadmap #11: QuantumLock cache-prefix stabilization (opt-in, default off). Locally validated release-green (typecheck + file-size + 47 quantumLock/analytics tests; restored withRiskGate import + preserved release CHANGELOG bullets). Integrated into release/v3.8.40.
2026-06-28 21:59:46 -03:00

24 lines
961 B
TypeScript

import type { CompressionConfig } from "./types.ts";
import type { CachingDetectionContext } from "./cachingAware.ts";
import { detectCachingContext, getCacheAwareStrategy } from "./cachingAware.ts";
/**
* #3890: honor the cache-aware `skipSystemPrompt` decision that
* `getCacheAwareStrategy` already computes but `selectCompressionStrategy`
* cannot return. In a caching context the system prompt is part of the
* cacheable prefix, so compressing it breaks the upstream prompt cache.
*/
export function resolveCacheAwareConfig(
config: CompressionConfig,
body?: Record<string, unknown>,
context?: CachingDetectionContext
): CompressionConfig {
if (!body) return config;
const ctx = detectCachingContext(body, context);
const cacheAware = getCacheAwareStrategy(config.defaultMode, ctx);
if (cacheAware.skipSystemPrompt && config.preserveSystemPrompt === false) {
return { ...config, preserveSystemPrompt: true };
}
return config;
}