






















@@ -36,6 +36,7 @@ const OPENAI_TOOL_MIN_CACHE_READ = 4_096;
3636const OPENAI_TOOL_MIN_HIT_RATE = 0.85;
3737const OPENAI_IMAGE_MIN_CACHE_READ = 3_840;
3838const OPENAI_IMAGE_MIN_HIT_RATE = 0.82;
39+const LARGE_CACHE_PROMPT_SECTIONS = 1_024;
3940const LIVE_TEST_PNG_URL = new URL(
4041"../../apps/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png",
4142import.meta.url,
@@ -1026,6 +1027,40 @@ describeCacheLive("embedded agent runner prompt caching (live)", () => {
102610278 * 60_000,
10271028);
102810291030+it(
1031+"keeps OpenAI cache reuse across a large embedded prompt",
1032+async () => {
1033+const sessionId = `${OPENAI_SESSION_ID}-large`;
1034+const warmup = await runEmbeddedCacheProbe({
1035+ ...fixture,
1036+cacheRetention: "short",
1037+prefix: OPENAI_PREFIX,
1038+providerTag: "openai",
1039+ sessionId,
1040+suffix: "large-warmup",
1041+promptSections: LARGE_CACHE_PROMPT_SECTIONS,
1042+});
1043+const hit = await runEmbeddedCacheProbe({
1044+ ...fixture,
1045+cacheRetention: "short",
1046+prefix: OPENAI_PREFIX,
1047+providerTag: "openai",
1048+ sessionId,
1049+suffix: "large-hit",
1050+promptSections: LARGE_CACHE_PROMPT_SECTIONS,
1051+});
1052+logLiveCache(
1053+`openai large prompt sections=${LARGE_CACHE_PROMPT_SECTIONS} warmup=${warmup.usage.cacheWrite} hit=${hit.usage.cacheRead} input=${hit.usage.input} rate=${hit.hitRate.toFixed(3)}`,
1054+);
1055+1056+expect(warmup.usage.cacheWrite ?? 0).toBeGreaterThan(0);
1057+expect(hit.usage.cacheRead ?? 0).toBeGreaterThan(4_096);
1058+expect(hit.hitRate).toBeGreaterThanOrEqual(0.4);
1059+await expectCacheTraceStages(sessionId, ["cache:state", "cache:result"]);
1060+},
1061+12 * 60_000,
1062+);
1063+10291064it(
10301065"keeps OpenAI cache reuse when structured system context only changes by whitespace and line endings",
10311066async () => {
@@ -1363,5 +1398,39 @@ describeCacheLive("embedded agent runner prompt caching (live)", () => {
13631398},
136413998 * 60_000,
13651400);
1401+1402+it(
1403+"keeps Anthropic cache reuse across a large embedded prompt",
1404+async () => {
1405+const sessionId = `${ANTHROPIC_SESSION_ID}-large`;
1406+const warmup = await runEmbeddedCacheProbe({
1407+ ...fixture,
1408+cacheRetention: "short",
1409+prefix: ANTHROPIC_PREFIX,
1410+providerTag: "anthropic",
1411+ sessionId,
1412+suffix: "large-warmup",
1413+promptSections: LARGE_CACHE_PROMPT_SECTIONS,
1414+});
1415+const hit = await runEmbeddedCacheProbe({
1416+ ...fixture,
1417+cacheRetention: "short",
1418+prefix: ANTHROPIC_PREFIX,
1419+providerTag: "anthropic",
1420+ sessionId,
1421+suffix: "large-hit",
1422+promptSections: LARGE_CACHE_PROMPT_SECTIONS,
1423+});
1424+logLiveCache(
1425+`anthropic large prompt sections=${LARGE_CACHE_PROMPT_SECTIONS} warmup=${warmup.usage.cacheWrite} hit=${hit.usage.cacheRead} input=${hit.usage.input} rate=${hit.hitRate.toFixed(3)}`,
1426+);
1427+1428+expect(warmup.usage.cacheWrite ?? 0).toBeGreaterThan(0);
1429+expect(hit.usage.cacheRead ?? 0).toBeGreaterThan(4_096);
1430+expect(hit.hitRate).toBeGreaterThanOrEqual(0.3);
1431+await expectCacheTraceStages(sessionId, ["cache:state", "cache:result"]);
1432+},
1433+12 * 60_000,
1434+);
13661435});
13671436});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。