Skip to content

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

fix(search): ignore legacy task context without collecting it (#5109)

Kris Oei57b3b68e75fd
diff --git a/apps/api/src/__tests__/snips/v2/search-feedback.test.ts b/apps/api/src/__tests__/snips/v2/search-feedback.test.ts
index 7ae446d49..c607837ba 100644
--- a/apps/api/src/__tests__/snips/v2/search-feedback.test.ts
+++ b/apps/api/src/__tests__/snips/v2/search-feedback.test.ts
@@ -39,15 +39,13 @@ describeIf(TEST_PRODUCTION)("Search feedback tests", () => {
it.concurrent(
"records feedback and refunds 1 credit on first submission",
async () => {
- const raw = await searchRawFull(
- {
- query: "firecrawl",
- objective: "Find official Firecrawl information",
- clientModel: "claude-sonnet-4-6",
- limit: 3,
- },
- identity,
- );
+ const body = {
+ query: "firecrawl",
+ objective: "Find official Firecrawl information",
+ clientModel: "claude-sonnet-4-6",
+ limit: 3,
+ };
+ const raw = await searchRawFull(body, identity);
expect(raw.statusCode).toBe(200);
expect(typeof raw.body.id).toBe("string");
expect((raw.body.data?.web ?? []).length).toBeGreaterThan(0);
@@ -65,10 +63,9 @@ describeIf(TEST_PRODUCTION)("Search feedback tests", () => {
if (row) searchRow = { options: JSON.parse(row.options ?? "null") };
else await new Promise(resolve => setTimeout(resolve, 1000));
}
- expect(searchRow?.options).toMatchObject({
- objective: "Find official Firecrawl information",
- clientModel: "claude-sonnet-4-6",
- });
+ expect(searchRow?.options).toMatchObject({ query: "firecrawl" });
+ expect(searchRow?.options).not.toHaveProperty("objective");
+ expect(searchRow?.options).not.toHaveProperty("clientModel");
const result = await searchFeedback(
raw.body.id,
diff --git a/apps/api/src/__tests__/snips/v2/search.test.ts b/apps/api/src/__tests__/snips/v2/search.test.ts
index 845bfd8c1..e62212bd6 100644
--- a/apps/api/src/__tests__/snips/v2/search.test.ts
+++ b/apps/api/src/__tests__/snips/v2/search.test.ts
@@ -36,30 +36,31 @@ describeIf(TEST_PRODUCTION || HAS_SEARCH || HAS_PROXY)("Search tests", () => {
);
it.concurrent(
- "accepts optional agent task context",
+ "ignores legacy client model on search requests",
async () => {
- const res = await search(
- {
- query: "firecrawl documentation",
- objective: "Find official Firecrawl API documentation",
- clientModel: "claude-sonnet-4-6",
- limit: 1,
- },
- identity,
- );
+ const body = {
+ query: "firecrawl documentation",
+ clientModel: "claude-sonnet-4-6",
+ limit: 1,
+ };
+ const res = await search(body, identity);
expect(res.web?.length).toBeGreaterThan(0);
},
60000,
);
it.concurrent(
- "ignores invalid agent task context instead of failing the search",
+ "ignores legacy objective on search requests",
async () => {
- const res = await search(
- { query: "firecrawl", objective: "x".repeat(5001), limit: 1 },
- identity,
- );
- expect(res.web?.length).toBeGreaterThan(0);
+ const body = {
+ query: "firecrawl",
+ objective: "Find official documentation",
+ limit: 1,
+ };
+ const res = await searchRaw(body, identity);
+ expect(res.statusCode).toBe(200);
+ expect(res.body.success).toBe(true);
+ expect(res.body.data.web?.length).toBeGreaterThan(0);
},
60000,
);
diff --git a/apps/api/src/controllers/v2/search-schema.test.ts b/apps/api/src/controllers/v2/search-schema.test.ts
index 0106125a1..05274b3b5 100644
--- a/apps/api/src/controllers/v2/search-schema.test.ts
+++ b/apps/api/src/controllers/v2/search-schema.test.ts
@@ -51,41 +51,42 @@ describe("searchRequestSchema highlights", () => {
expect(request.highlights).toBe(false);
});
- it("accepts optional agent task context without changing search defaults", () => {
+ it("keeps search defaults without task context fields", () => {
const request = searchRequestSchema.parse({
query: "React memo docs",
- objective:
- " Find official guidance on preventing unnecessary rerenders ",
- clientModel: " claude-sonnet-4-6 ",
});
expect(request).toMatchObject({
query: "React memo docs",
- objective: "Find official guidance on preventing unnecessary rerenders",
- clientModel: "claude-sonnet-4-6",
limit: 10,
});
expect(
searchRequestSchema.parse({ query: "React memo docs" }),
).not.toHaveProperty("objective");
+ expect(request).not.toHaveProperty("clientModel");
});
it.each([
- { objective: " " },
- { objective: "x".repeat(5001) },
- { objective: null },
+ { clientModel: "claude-sonnet-4-6" },
{ clientModel: " " },
{ clientModel: "x".repeat(129) },
{ clientModel: 42 },
- ])("drops invalid agent task context without failing the search %j", context => {
+ ])("rejects removed client model in the request schema %j", context => {
const result = searchRequestSchema.safeParse({
query: "React memo docs",
...context,
});
- expect(result.success).toBe(true);
- expect(result.data?.objective).toBeUndefined();
- expect(result.data?.clientModel).toBeUndefined();
- expect(result.data?.limit).toBe(10);
+ expect(result.success).toBe(false);
});
+
+ it.each(["Find official rerender guidance", " ", "x".repeat(5001), null])(
+ "rejects objective on search requests: %j",
+ objective => {
+ expect(
+ searchRequestSchema.safeParse({ query: "React memo docs", objective })
+ .success,
+ ).toBe(false);
+ },
+ );
});
diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.ts
index cc9d4e17a..08fcc544a 100644
--- a/apps/api/src/controllers/v2/search.ts
+++ b/apps/api/src/controllers/v2/search.ts
@@ -146,6 +146,8 @@ async function searchControllerInner(
try {
const rawOrigin =
typeof req.body?.origin === "string" ? req.body.origin : undefined;
+ delete (req.body as Record<string, unknown>)?.objective;
+ delete (req.body as Record<string, unknown>)?.clientModel;
req.body = searchRequestSchema.parse(req.body);
const wantsTools = req.body.sources.some(
diff --git a/apps/api/src/controllers/v2/types.ts b/apps/api/src/controllers/v2/types.ts
index b68374592..280c822c5 100644
--- a/apps/api/src/controllers/v2/types.ts
+++ b/apps/api/src/controllers/v2/types.ts
@@ -2559,8 +2559,6 @@ const searchDomainSchema = z
export const searchRequestSchema = z
.strictObject({
query: z.string(),
- objective: z.string().trim().min(1).max(5000).optional().catch(undefined),
- clientModel: z.string().trim().min(1).max(128).optional().catch(undefined),
limit: z.int().positive().finite().max(100).optional().prefault(10),
tbs: z.string().optional(),
filter: z.string().optional(),