Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
address review round 6: delta-isolate the credit-budget poll
Karan Lokchandani49c5c0f28b0b
diff --git a/apps/api/src/__tests__/snips/v2/research.test.ts b/apps/api/src/__tests__/snips/v2/research.test.tsindex 57f6022b3..696fcf16d 100644--- a/apps/api/src/__tests__/snips/v2/research.test.ts+++ b/apps/api/src/__tests__/snips/v2/research.test.ts@@ -335,6 +335,16 @@ describeIf(HAS_RESEARCH)("Research API", () => {async () => {const forwardedIp = "198.51.100.11";const afterId = await maxKeylessUsageRowId();+ // Delta-isolated like the row check: the keyless_credits key on this+ // fixed IP lives for a day, so a leftover increment from an earlier+ // run must not read as a stray charge now.+ const creditsBefore = KEYLESS_PROXY_SECRET+ ? Number(+ (await redisRateLimitClient.get(+ `keyless_credits:${forwardedIp}`,+ )) ?? "0",+ )+ : 0;const { res, ip } = await issueAndResolveKeylessIp(forwardedIp, () =>researchRaw(@@ -369,7 +379,7 @@ describeIf(HAS_RESEARCH)("Research API", () => {Number((await redisRateLimitClient.get(`keyless_credits:${ip}`)) ??"0",- ) > 0 || null,+ ) > creditsBefore || null,6000,500,);