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({