From 1b6bc2ef7d0d16faecb05fd15d56b840c03ce4b4 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 7 Jun 2026 00:02:29 +0200 Subject: [PATCH] fix(test): require native web search proof --- .../openai-web-search-minimal/assertions.mjs | 13 +++------ ...enai-web-search-minimal-assertions.test.ts | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/scripts/e2e/lib/openai-web-search-minimal/assertions.mjs b/scripts/e2e/lib/openai-web-search-minimal/assertions.mjs index 8ac4a8add17c..c142994f2e35 100644 --- a/scripts/e2e/lib/openai-web-search-minimal/assertions.mjs +++ b/scripts/e2e/lib/openai-web-search-minimal/assertions.mjs @@ -46,7 +46,7 @@ function scanSuccessRequest(logPath) { return; } const entry = JSON.parse(trimmed); - if (entry.path !== "/v1/responses") { + if (entry.method !== "POST" || entry.path !== "/v1/responses") { return; } responseCount += 1; @@ -115,15 +115,10 @@ function assertSuccessRequest() { ); } const tools = Array.isArray(success.body.tools) ? success.body.tools : []; - const hasWebSearch = tools.some( - (tool) => - tool?.type === "web_search" || - (tool?.type === "function" && - (tool?.name === "web_search" || tool?.function?.name === "web_search")), - ); - if (!hasWebSearch) { + const hasNativeWebSearch = tools.some((tool) => tool?.type === "web_search"); + if (!hasNativeWebSearch) { throw new Error( - `success request did not include web_search. Body: ${JSON.stringify(success.body)}`, + `success request did not include native web_search. Body: ${JSON.stringify(success.body)}`, ); } if (success.body.reasoning?.effort === "minimal") { diff --git a/test/scripts/openai-web-search-minimal-assertions.test.ts b/test/scripts/openai-web-search-minimal-assertions.test.ts index ca1c6dd61940..15a553661dbf 100644 --- a/test/scripts/openai-web-search-minimal-assertions.test.ts +++ b/test/scripts/openai-web-search-minimal-assertions.test.ts @@ -26,6 +26,7 @@ describe("openai web-search minimal assertions", () => { reasoning: { effort: "low" }, tools: [{ type: "web_search" }], }, + method: "POST", path: "/v1/responses", })}\n`, ); @@ -49,6 +50,7 @@ describe("openai web-search minimal assertions", () => { reasoning: { effort: "low" }, tools: [{ type: "web_search" }], }, + method: "POST", path: "/v1/responses", }, )}\n`, @@ -95,6 +97,7 @@ describe("openai web-search minimal assertions", () => { input: `DO_NOT_DUMP_OLD_RESPONSE${"x".repeat(70 * 1024)}recent response tail`, tools: [{ type: "web_search" }], }, + method: "POST", path: "/v1/responses", })}\n`, ); @@ -109,4 +112,30 @@ describe("openai web-search minimal assertions", () => { rmSync(dir, { force: true, recursive: true }); } }); + + it("rejects function-shaped web_search as native Responses proof", () => { + const dir = mkdtempSync(path.join(tmpdir(), "openclaw-web-search-minimal-")); + try { + const logPath = path.join(dir, "requests.jsonl"); + writeFileSync( + logPath, + `${JSON.stringify({ + body: { + input: "OPENCLAW_SCHEMA_E2E_OK", + reasoning: { effort: "low" }, + tools: [{ name: "web_search", type: "function" }], + }, + method: "POST", + path: "/v1/responses", + })}\n`, + ); + + const result = runAssertSuccessRequest(logPath); + + expect(result.status).not.toBe(0); + expect(result.stderr).toContain("success request did not include native web_search"); + } finally { + rmSync(dir, { force: true, recursive: true }); + } + }); });