Skip to content

Computer use for the Pi coding agent — Windows apps, browsers and desktops through native UI trees, screenshots and real input.

test: tool_search loads the typed tools per query (LPT-934)

alexshpunt-clanker[bot]4d1b17a9a8d2
diff --git a/docs/computer-resources.md b/docs/computer-resources.md
index 76465d4..e27cdce 100644
--- a/docs/computer-resources.md
+++ b/docs/computer-resources.md
@@ -11,7 +11,7 @@ The current desktop scope is Windows, with Pi running on it directly or in its W
## Typed tools
-Some operations have their own tool with typed fields, in both modes. They are deferred like the tools above: one `tool_search` for computer loads them. Their receipts match Insert receipts.
+Some operations have their own tool with typed fields, in both modes. They are deferred like the tools above: `tool_search` loads the best matches of a query, such as `computer open window` or `computer wait browser`. Their receipts match Insert receipts.
| Tool | Does | Replaces |
| --- | --- | --- |
diff --git a/test/extension-modes.integration.test.ts b/test/extension-modes.integration.test.ts
index 4461cf0..ba1f23f 100644
--- a/test/extension-modes.integration.test.ts
+++ b/test/extension-modes.integration.test.ts
@@ -31,15 +31,17 @@ test("without Pi Agent IDE, tool_search finds the deferred computer tools and th
{ id: "guide", name: "computer_read", arguments: { path: "docs:computer" } },
{ id: "session", name: "computer_read", arguments: { path: "computer:session" } },
{ id: "close", name: "computer_insert", arguments: { path: "computer:session", text: '{"action":"close"}' } },
+ { id: "more", name: "tool_search", arguments: { query: "computer wait browser" } },
{ id: "display", name: "computer_display", arguments: { display: "computer:display/primary", width: 1920, height: 1080 } },
{ id: "delete", name: "computer_delete", arguments: { path: "computer:session" } },
]);
- expect(getToolCallNames(result)).toEqual(["tool_search", "computer_read", "computer_read", "computer_insert", "computer_display", "computer_delete"]);
+ expect(getToolCallNames(result)).toEqual(["tool_search", "computer_read", "computer_read", "computer_insert", "tool_search", "computer_display", "computer_delete"]);
for (const id of ["find", "guide", "session", "close", "delete"])
expect(getToolExecution(result, id).isError, getToolResultText(result, id)).toBe(false);
expect(getToolResultText(result, "find")).toContain("computer_read");
- // One search for computer loads the whole namespace.
- for (const tool of ["computer_open", "computer_window", "computer_display", "computer_wait", "computer_browser", "computer_delete"]) expect(getToolResultText(result, "find")).toContain(tool);
+ // tool_search loads the best matches of each query, at most 8 by default.
+ for (const tool of ["computer_open", "computer_window", "computer_display", "computer_delete"]) expect(getToolResultText(result, "find")).toContain(tool);
+ for (const tool of ["computer_wait", "computer_browser"]) expect(getToolResultText(result, "more")).toContain(tool);
// A typed tool refuses a bad address with a receipt before any native work.
expect(getToolExecution(result, "display").isError).toBe(true);
expect(getToolResultText(result, "display")).not.toContain("unknown");