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
fix(api): lower low-credit hint threshold
Rakshith Ramprakash99c0dc6bf750
diff --git a/apps/api/AGENT_HINTS.md b/apps/api/AGENT_HINTS.mdindex 59e936319..532eaa6d1 100644--- a/apps/api/AGENT_HINTS.md+++ b/apps/api/AGENT_HINTS.md@@ -20,7 +20,7 @@ Raw HTTP and ordinary SDK callers receive no hints unless their adapter explicit- Search excerpts: offer Scrape when a web result has no markdown, HTML, or raw HTML. Inspect actual output per result, not the requested scrape setting.- Source page 404/410: offer Search for a current location or alternative. An API cache-miss 404, 429, authentication failure, or timeout does not fire this rule.-- Low credits: when the authoritative billing preflight reports 1,000 credits or fewer, ask the agent to let the user know they should add more credits. This notice does not replace a useful cross-endpoint suggestion.+- Low credits: when the authoritative billing preflight reports fewer than 100 credits, ask the agent to let the user know they should add more credits. This notice does not replace a useful cross-endpoint suggestion.Selection reads only request/response fields and billing state already in memory. It makes no additional network/model calls, reads no additional session/database state, and does not scan page text or classify user intent. No hint appears solely to fill an available slot.diff --git a/apps/api/src/lib/agent-hints.test.ts b/apps/api/src/lib/agent-hints.test.tsindex abb64b348..3a4cbe396 100644--- a/apps/api/src/lib/agent-hints.test.ts+++ b/apps/api/src/lib/agent-hints.test.ts@@ -68,10 +68,10 @@ describe("deterministic agent hints", () => {});it("asks the agent to notify the user when credits are low", () => {- expect(hints({ remainingCredits: 1000 })).toEqual([+ expect(hints({ remainingCredits: 99 })).toEqual(["The connected Firecrawl account is low on credits. Let the user know they should add more credits.",]);- expect(hints({ remainingCredits: 1001 })).toEqual([]);+ expect(hints({ remainingCredits: 100 })).toEqual([]);expect(hints({ remainingCredits: Infinity })).toEqual([]);expect(hints({})).toEqual([]);});diff --git a/apps/api/src/lib/agent-hints.ts b/apps/api/src/lib/agent-hints.tsindex 40124b335..515648703 100644--- a/apps/api/src/lib/agent-hints.ts+++ b/apps/api/src/lib/agent-hints.ts@@ -6,7 +6,7 @@ export interface AgentHintContext {remainingCredits?: number;}-export const AGENT_HINT_LOW_CREDIT_THRESHOLD = 1000;+export const AGENT_HINT_LOW_CREDIT_THRESHOLD = 100;type ObjectValue = Record<string, unknown>;function object(value: unknown): ObjectValue {@@ -53,7 +53,7 @@ export function buildAgentHints(context: AgentHintContext): string[] {const lowCredits =typeof context.remainingCredits === "number" &&Number.isFinite(context.remainingCredits) &&- context.remainingCredits <= AGENT_HINT_LOW_CREDIT_THRESHOLD+ context.remainingCredits < AGENT_HINT_LOW_CREDIT_THRESHOLD? "The connected Firecrawl account is low on credits. Let the user know they should add more credits.": undefined;diff --git a/apps/api/src/middlewares/__tests__/agent-hints.test.ts b/apps/api/src/middlewares/__tests__/agent-hints.test.tsindex e28d25a26..89df3b968 100644--- a/apps/api/src/middlewares/__tests__/agent-hints.test.ts+++ b/apps/api/src/middlewares/__tests__/agent-hints.test.ts@@ -69,7 +69,7 @@ describe("agent hint response middleware", () => {success: true,data: { web: [{ url: "https://example.com", description: "excerpt" }] },};- const response = await request(appFor({ body, remainingCredits: 1000 }))+ const response = await request(appFor({ body, remainingCredits: 99 })).post("/").set("X-Firecrawl-Agent-Hints", "true").send({});@@ -80,8 +80,8 @@ describe("agent hint response middleware", () => {);});- it("does not add a credit notice above the threshold", async () => {- const response = await request(appFor({ remainingCredits: 1001 }))+ it("does not add a credit notice at the threshold", async () => {+ const response = await request(appFor({ remainingCredits: 100 })).post("/").set("X-Firecrawl-Agent-Hints", "true").send({});