fix(qa): surface tool-search bridge results

This commit is contained in:
Vincent Koc
2026-06-22 07:40:27 +02:00
parent 7668ef2d35
commit 4506d8bad6
2 changed files with 51 additions and 0 deletions

View File

@@ -3146,6 +3146,47 @@ describe("qa mock openai server", () => {
expect(String(toolPlanOutput.arguments)).toContain("current");
});
it("summarizes QA tool-search bridge outputs with the nested plugin result marker", async () => {
const server = await startMockServer();
const targetTool = "fake_plugin_tool_17";
const response = await postResponses(server, {
stream: false,
input: [
makeUserInput(
`tool search qa check target=${targetTool}. Call exactly that tool once and then summarize.`,
),
{
type: "function_call_output",
call_id: "call_tool_search_code_1",
output: JSON.stringify({
ok: true,
value: {
tool: {
id: `openclaw:tool-search-e2e-fixture:${targetTool}`,
source: "openclaw",
sourceName: "tool-search-e2e-fixture",
name: targetTool,
description: "x".repeat(260),
},
result: {
content: [
{
type: "text",
text: `FAKE_PLUGIN_OK ${targetTool} {"marker":"code"}`,
},
],
},
},
}),
},
],
});
expect(response.status).toBe(200);
expect(outputText(await response.json())).toBe(`FAKE_PLUGIN_OK ${targetTool}`);
});
it("plans QA tool-search failure calls with denied-input args", async () => {
const server = await startMockServer();

View File

@@ -1482,6 +1482,16 @@ function buildAssistantText(
"- Re-run with a real model for qualitative coverage.",
].join("\n");
}
if (
toolOutput &&
(QA_TOOL_SEARCH_PROMPT_RE.test(allInputText) ||
QA_TOOL_SEARCH_FAILURE_PROMPT_RE.test(allInputText))
) {
const targetTool = extractToolSearchTarget(allInputText);
if (targetTool && toolOutput.includes(targetTool) && toolOutput.includes("FAKE_PLUGIN_OK")) {
return `FAKE_PLUGIN_OK ${targetTool}`;
}
}
if (toolOutput) {
const snippet = toolOutput.replace(/\s+/g, " ").trim().slice(0, 220);
return `Protocol note: I reviewed the requested material. Evidence snippet: ${snippet || "no content"}`;