fix(test): require native web search proof

This commit is contained in:
Vincent Koc
2026-06-07 00:02:29 +02:00
parent 2102166f86
commit 1b6bc2ef7d
2 changed files with 33 additions and 9 deletions

View File

@@ -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") {

View File

@@ -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 });
}
});
});