mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-07 18:42:25 +00:00
fix(test): require native web search proof
This commit is contained in:
@@ -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") {
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user