mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-07 07:42:13 +03:00
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.
24 lines
961 B
TypeScript
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;
|
|
}
|