Commit 041229571851

Vincent Demeester <vincent@sbr.pm>
2026-02-10 16:01:45
feat: add configurable limit to search tools
Changed default result count from 5 to 10 and added optional limit parameter to all three search tools.
1 parent 13be118
Changed files (1)
dots
pi
agent
extensions
search
dots/pi/agent/extensions/search/index.ts
@@ -100,6 +100,7 @@ export default function (pi: ExtensionAPI) {
       "Performs a web search using the DuckDuckGo API to answer questions or find information.",
     parameters: Type.Object({
       query: Type.String({ description: "The search query." }),
+      limit: Type.Optional(Type.Number({ description: "Maximum number of results (default 10)" })),
     }),
     renderCall(args, theme) {
       let text = theme.fg("toolTitle", theme.bold("web_search "));
@@ -124,10 +125,11 @@ export default function (pi: ExtensionAPI) {
 
     async execute(_toolCallId, params, signal) {
       try {
+        const maxResults = params.limit ?? 10;
         const { results, backend, errors } = await searchWithFallback(
           getActiveBackends(),
           params.query,
-          5,
+          maxResults,
           signal,
         );
 
@@ -166,6 +168,7 @@ export default function (pi: ExtensionAPI) {
         description:
           "The code search query. Examples: 'readFile repo:owner/project', 'my_function language:python'",
       }),
+      limit: Type.Optional(Type.Number({ description: "Maximum number of results (default 10)" })),
     }),
     renderCall(args, theme) {
       let text = theme.fg("toolTitle", theme.bold("github_search "));
@@ -237,8 +240,9 @@ export default function (pi: ExtensionAPI) {
           };
         }
 
+        const maxResults = params.limit ?? 10;
         const results = items
-          .slice(0, 5)
+          .slice(0, maxResults)
           .map(
             (item: any) =>
               `Path: ${item.path} (Repo: ${item.repository.full_name})\nURL: ${item.html_url}`,
@@ -265,6 +269,7 @@ export default function (pi: ExtensionAPI) {
       query: Type.String({
         description: "The question to search for.",
       }),
+      limit: Type.Optional(Type.Number({ description: "Maximum number of results (default 10)" })),
     }),
     renderCall(args, theme) {
       let text = theme.fg("toolTitle", theme.bold("stack_overflow_search "));
@@ -310,8 +315,9 @@ export default function (pi: ExtensionAPI) {
           };
         }
 
+        const maxResults = params.limit ?? 10;
         const results = items
-          .slice(0, 5)
+          .slice(0, maxResults)
           .map(
             (item: any) =>
               `[Score: ${item.score}] ${item.is_answered ? "(Answered)" : ""} ${item.title}\nURL: ${item.link}`,