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 <vincentkoc@ieee.org>
This commit is contained in:
soldforaloss
2026-07-10 19:25:22 -07:00
committed by GitHub
parent f5eacacea5
commit 200e1df007
2 changed files with 25 additions and 3 deletions
@@ -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),
]);
}
@@ -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({