



























@@ -137,11 +137,13 @@ function preparePromptCacheStream(params: {
137137describe("google prompt cache", () => {
138138it("creates cached content from the system prompt and strips that prompt from live requests", async () => {
139139const now = 1_000_000;
140+const expireTime = new Date(now + 3_600_000).toISOString();
141+const systemPromptDigest = crypto.createHash("sha256").update("Follow policy.").digest("hex");
140142const entries: SessionCustomEntry[] = [];
141143const sessionManager = makeSessionManager(entries);
142144const fetchMock = createCacheFetchMock({
143145name: "cachedContents/system-cache-1",
144-expireTime: new Date(now + 3_600_000).toISOString(),
146+ expireTime,
145147});
146148const { streamFn: innerStreamFn, getCapturedPayload } = createCapturingStreamFn();
147149@@ -192,9 +194,27 @@ describe("google prompt cache", () => {
192194expect(Array.isArray(streamContext(innerStreamFn).tools)).toBe(true);
193195expect(streamOptions(innerStreamFn).temperature).toBe(0.2);
194196expect(getCapturedPayload()?.cachedContent).toBe("cachedContents/system-cache-1");
195-expect(entries).toHaveLength(1);
196-expect(entries[0]?.customType).toBe("openclaw.google-prompt-cache");
197-expect((entries[0]?.data as { status?: string; cachedContent?: string })?.status).toBe("ready");
197+expect(entries).toEqual([
198+{
199+type: "custom",
200+id: "entry-1",
201+parentId: null,
202+timestamp: new Date(1_000).toISOString(),
203+customType: "openclaw.google-prompt-cache",
204+data: {
205+status: "ready",
206+timestamp: now,
207+provider: "google",
208+modelId: "gemini-3.1-pro-preview",
209+modelApi: "google-generative-ai",
210+baseUrl: "https://generativelanguage.googleapis.com/v1beta",
211+ systemPromptDigest,
212+cacheRetention: "long",
213+cachedContent: "cachedContents/system-cache-1",
214+ expireTime,
215+},
216+},
217+]);
198218});
199219200220it("reuses a persisted cache entry without creating a second cache", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。