chore(dead-code): remove unused prompt cache control helper (#5466)

This commit is contained in:
Jan Leon
2026-06-30 02:56:23 +02:00
committed by GitHub
parent a003b1fdc4
commit 467736a1b4
3 changed files with 31 additions and 5 deletions

View File

@@ -1 +1 @@
export { analyzePrefix, shouldInjectCacheControl, generatePromptCacheKey } from "./prefixAnalyzer";
export { analyzePrefix, generatePromptCacheKey } from "./prefixAnalyzer";

View File

@@ -72,10 +72,6 @@ export function analyzePrefix(messages: Message[]): PrefixAnalysis {
};
}
export function shouldInjectCacheControl(analysis: PrefixAnalysis, minTokens = 1024): boolean {
return analysis.prefixTokens >= minTokens && analysis.confidence >= 0.7;
}
export function generatePromptCacheKey(messages: Message[]): string {
const analysis = analyzePrefix(messages);
if (analysis.prefixHash) {

View File

@@ -0,0 +1,30 @@
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { analyzePrefix, generatePromptCacheKey } from "../../src/lib/promptCache";
describe("prompt cache prefix analyzer", () => {
it("captures stable system prefixes and derives a cache key", () => {
const messages = [
{ role: "system", content: "You are helpful." },
{ role: "user", content: "Hello" },
];
const analysis = analyzePrefix(messages);
assert.equal(analysis.prefixEndIdx, 0);
assert.equal(analysis.prefixType, "system_only");
assert.equal(analysis.confidence, 0.9);
assert.ok(analysis.prefixTokens > 0);
assert.match(generatePromptCacheKey(messages), /^omni-[a-f0-9]{32}$/);
});
it("keeps the legacy empty-content key when there is no prefix", () => {
const messages = [{ role: "user", content: "Hello" }];
const analysis = analyzePrefix(messages);
assert.equal(analysis.prefixEndIdx, -1);
assert.equal(generatePromptCacheKey(messages), "omni-e3b0c44298fc1c149afbf4c8996fb924");
});
});