Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nsc/fix rate limits alexandria (#4725)

Nicolas556c12c9d293
diff --git a/apps/api/src/routes/exchange.ts b/apps/api/src/routes/exchange.ts
index c199cffc3..f342e625d 100644
--- a/apps/api/src/routes/exchange.ts
+++ b/apps/api/src/routes/exchange.ts
@@ -152,11 +152,12 @@ async function providerTermsAcceptController(req: Request, res: Response) {
export const exchangeRouter = express.Router();
-// Data routes take the plan's scrape-equivalent budget (base 10/min, multiplier
-// scaled). Dashboard and publisher routes below stay on the flat Labs limit.
+// Discover is a flat 10,000/min catalogue read. Retrieve and records/fetch take
+// the plan's scrape-equivalent budget (base 10/min, multiplier scaled).
+// Dashboard and publisher routes below stay on the flat Labs limit.
exchangeRouter.get(
"/discover{/*path}",
- authMiddleware(RateLimiterMode.Exchange),
+ authMiddleware(RateLimiterMode.ExchangeDiscover),
wrap(exchangeProxy(DISCOVER_TIMEOUT_MS, { requiresRetrieveFlag: false })),
);
diff --git a/apps/api/src/services/rate-limiter.test.ts b/apps/api/src/services/rate-limiter.test.ts
index 6d945b233..10ec9bb09 100644
--- a/apps/api/src/services/rate-limiter.test.ts
+++ b/apps/api/src/services/rate-limiter.test.ts
@@ -408,6 +408,15 @@ describe("getAutumnRateLimiter", () => {
);
});
+ it("gives exchange discover a flat 10000 regardless of multiplier", () => {
+ expect(
+ getAutumnRateLimiter(RateLimiterMode.ExchangeDiscover, 1).points,
+ ).toBe(10000);
+ expect(
+ getAutumnRateLimiter(RateLimiterMode.ExchangeDiscover, 1000).points,
+ ).toBe(10000);
+ });
+
it("replaces the computed limit with the override for that mode", () => {
const limiter = getAutumnRateLimiter(
RateLimiterMode.Scrape,
diff --git a/apps/api/src/services/rate-limiter.ts b/apps/api/src/services/rate-limiter.ts
index e5f4810d4..92e1682d5 100644
--- a/apps/api/src/services/rate-limiter.ts
+++ b/apps/api/src/services/rate-limiter.ts
@@ -39,6 +39,8 @@ const fallbackRateLimits: Record<RateLimiterMode, number> = {
developerSearch: 100,
labs: 1000,
exchange: 100,
+ // Catalogue reads only; no paid tool runs behind them.
+ exchangeDiscover: 10000,
};
/**
diff --git a/apps/api/src/types.ts b/apps/api/src/types.ts
index 79f264d35..bf216cffc 100644
--- a/apps/api/src/types.ts
+++ b/apps/api/src/types.ts
@@ -161,6 +161,7 @@ export enum RateLimiterMode {
DeveloperSearch = "developerSearch",
Labs = "labs",
Exchange = "exchange",
+ ExchangeDiscover = "exchangeDiscover",
}
export type AuthResponse =