






















@@ -30,6 +30,100 @@ describe("prompt cache retention", () => {
3030).toBeUndefined();
3131});
323233+it("passes explicit cacheRetention through for openai-completions providers when supportsPromptCacheKey (issue #81281)", () => {
34+// Regression: openai-completions providers with prefix-caching backends
35+// (oMLX, llama.cpp, etc.) set compat.supportsPromptCacheKey: true and
36+// cacheRetention: "long" but the wrapper was silently dropping the
37+// user's explicit cacheRetention because the provider is neither in the
38+// anthropic family nor google-eligible.
39+expect(
40+resolveCacheRetention(
41+{ cacheRetention: "long" },
42+"omlx-local",
43+"openai-completions",
44+"local_model",
45+true,
46+),
47+).toBe("long");
48+expect(
49+resolveCacheRetention(
50+{ cacheRetention: "short" },
51+"omlx-local",
52+"openai-completions",
53+"local_model",
54+true,
55+),
56+).toBe("short");
57+expect(
58+resolveCacheRetention(
59+{ cacheRetention: "none" },
60+"omlx-local",
61+"openai-completions",
62+"local_model",
63+true,
64+),
65+).toBe("none");
66+});
67+68+it("does not honor explicit cacheRetention for openai-completions without supportsPromptCacheKey", () => {
69+// Providers that route via openai-completions but do not advertise prompt
70+// caching (e.g. amazon-bedrock proxying amazon.* nova models) must keep
71+// the explicit cacheRetention from leaking into the outgoing payload.
72+expect(
73+resolveCacheRetention(
74+{ cacheRetention: "long" },
75+"amazon-bedrock",
76+"openai-completions",
77+"amazon.nova-micro-v1:0",
78+),
79+).toBeUndefined();
80+expect(
81+resolveCacheRetention(
82+{ cacheRetention: "long" },
83+"omlx-local",
84+"openai-completions",
85+"local_model",
86+false,
87+),
88+).toBeUndefined();
89+});
90+91+it("returns undefined for openai-completions without explicit cacheRetention", () => {
92+// Without an explicit user choice, openai-completions providers fall back
93+// to the transport-level default ("short") rather than receiving a
94+// wrapper-injected value.
95+expect(
96+resolveCacheRetention(undefined, "omlx-local", "openai-completions", "local_model", true),
97+).toBeUndefined();
98+expect(
99+resolveCacheRetention({}, "omlx-local", "openai-completions", "local_model", true),
100+).toBeUndefined();
101+});
102+103+it("does not map legacy cacheControlTtl for openai-completions prompt-cache-key providers", () => {
104+// Legacy TTL aliases were Anthropic/Google semantics; OpenAI-compatible
105+// completions providers need an explicit cacheRetention value before the
106+// wrapper forwards retention to the transport.
107+expect(
108+resolveCacheRetention(
109+{ cacheControlTtl: "1h" },
110+"omlx-local",
111+"openai-completions",
112+"local_model",
113+true,
114+),
115+).toBeUndefined();
116+expect(
117+resolveCacheRetention(
118+{ cacheControlTtl: "5m" },
119+"omlx-local",
120+"openai-completions",
121+"local_model",
122+true,
123+),
124+).toBeUndefined();
125+});
126+33127it("identifies supported direct Google cache families", () => {
34128expect(
35129isGooglePromptCacheEligible({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。