diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/GenericTool.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/GenericTool.tsx index 995c18df05..5ea634a69a 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/GenericTool.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/GenericTool.tsx @@ -305,15 +305,60 @@ function getWebAccordionData( string, unknown >; - const url = - getStringField(inp as Record, "url", "query") ?? - "Web content"; + const query = getStringField(inp, "query"); + const url = getStringField(inp, "url") ?? query ?? "Web content"; + + const results = Array.isArray(output.results) + ? (output.results as Array>) + : null; + + if (results) { + return { + title: `${results.length} search result${results.length === 1 ? "" : "s"}`, + description: query ? truncate(query, 80) : undefined, + content: ( +
+ {results.map((r, i) => { + const title = getStringField(r, "title") ?? "(untitled)"; + const href = getStringField(r, "url") ?? ""; + const snippet = getStringField(r, "snippet"); + const pageAge = getStringField(r, "page_age"); + return ( +
+ {href ? ( + + {title} + + ) : ( + {title} + )} + {href && ( +
+ {truncate(href, 100)} +
+ )} + {snippet && ( +

{snippet}

+ )} + {pageAge && ( +
{pageAge}
+ )} +
+ ); + })} +
+ ), + }; + } - // Try direct string fields first, then MCP content blocks, then raw JSON let content = getStringField(output, "content", "text", "_raw"); if (!content) content = extractMcpText(output); if (!content) { - // Fallback: render the raw JSON so the accordion isn't empty try { const raw = JSON.stringify(output, null, 2); if (raw !== "{}") content = raw; @@ -327,11 +372,7 @@ function getWebAccordionData( const message = getStringField(output, "message"); return { - title: statusCode - ? `Response (${statusCode})` - : url - ? "Web fetch" - : "Search results", + title: statusCode ? `Response (${statusCode})` : "Web fetch", description: truncate(url, 80), content: content ? ( {content} diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/helpers.ts index f8da6fbc2f..345a2a7ca5 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/helpers.ts +++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/GenericTool/helpers.ts @@ -60,6 +60,7 @@ export function getToolCategory(toolName: string): ToolCategory { case "bash_exec": return "bash"; case "web_fetch": + case "web_search": case "WebSearch": case "WebFetch": return "web";