From 200e1df007749f3d19635297c1babeb565c9a720 Mon Sep 17 00:00:00 2001 From: soldforaloss Date: Fri, 10 Jul 2026 19:25:22 -0700 Subject: [PATCH] fix(exa): cache disabled content options separately (#103653) * fix(exa): partition cache by disabled content options * fix(exa): align cache keys with effective contents --------- Co-authored-by: Vincent Koc --- .../src/exa-web-search-provider.runtime.ts | 6 ++--- .../exa/src/exa-web-search-provider.test.ts | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/extensions/exa/src/exa-web-search-provider.runtime.ts b/extensions/exa/src/exa-web-search-provider.runtime.ts index f07bcdcbcae0..b177110a602a 100644 --- a/extensions/exa/src/exa-web-search-provider.runtime.ts +++ b/extensions/exa/src/exa-web-search-provider.runtime.ts @@ -453,6 +453,8 @@ function buildExaCacheKey(params: { dateBefore?: string; contents?: ExaContentsArgs; }): string { + const contents = params.contents ?? { highlights: true }; + return buildSearchCacheKey([ "exa", params.endpoint, @@ -462,9 +464,7 @@ function buildExaCacheKey(params: { params.freshness, params.dateAfter, params.dateBefore, - params.contents?.highlights ? JSON.stringify(params.contents.highlights) : undefined, - params.contents?.text ? JSON.stringify(params.contents.text) : undefined, - params.contents?.summary ? JSON.stringify(params.contents.summary) : undefined, + JSON.stringify(contents), ]); } diff --git a/extensions/exa/src/exa-web-search-provider.test.ts b/extensions/exa/src/exa-web-search-provider.test.ts index 01315c459b15..5503d8d04f9c 100644 --- a/extensions/exa/src/exa-web-search-provider.test.ts +++ b/extensions/exa/src/exa-web-search-provider.test.ts @@ -153,6 +153,28 @@ describe("exa web search provider", () => { ); }); + it("partitions Exa cache keys by effective content options", () => { + const base = { + endpoint: "https://api.exa.ai/search", + type: "auto" as const, + query: "openclaw", + count: 5, + }; + const defaultKey = testing.buildExaCacheKey(base); + + expect( + testing.buildExaCacheKey({ ...base, contents: { highlights: true } }), + ).toBe(defaultKey); + + const disabledKeys = [ + testing.buildExaCacheKey({ ...base, contents: { highlights: false } }), + testing.buildExaCacheKey({ ...base, contents: { text: false } }), + testing.buildExaCacheKey({ ...base, contents: { summary: false } }), + ]; + expect(disabledKeys).not.toContain(defaultKey); + expect(new Set(disabledKeys).size).toBe(disabledKeys.length); + }); + it("normalizes Exa result descriptions from highlights before text", () => { expect( testing.resolveExaDescription({