From 0022087cc0201fd899a9ee83f75dea9399fffb2f Mon Sep 17 00:00:00 2001 From: Vaayne Date: Tue, 30 Dec 2025 17:50:48 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs:=20clarify=20hub=20exec=20r?= =?UTF-8?q?eturn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/mcpServers/hub/index.ts | 2 +- src/renderer/src/config/prompts.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/mcpServers/hub/index.ts b/src/main/mcpServers/hub/index.ts index 6647a3c803..479725cf43 100644 --- a/src/main/mcpServers/hub/index.ts +++ b/src/main/mcpServers/hub/index.ts @@ -81,7 +81,7 @@ export class HubServer { code: { type: 'string', description: - 'JavaScript code to execute. Can use async/await. Available helpers: parallel(...promises), settle(...promises). The last expression is returned.' + 'JavaScript code to execute. Runs inside an async function. Can use async/await. Available helpers: parallel(...promises), settle(...promises). Use return (or a final expression) to produce output; otherwise result is undefined.' } }, required: ['code'] diff --git a/src/renderer/src/config/prompts.ts b/src/renderer/src/config/prompts.ts index 88e95cc3ac..225848225c 100644 --- a/src/renderer/src/config/prompts.ts +++ b/src/renderer/src/config/prompts.ts @@ -479,7 +479,7 @@ You have access to MCP tools via the hub server. 1. Call \`search\` with relevant keywords to discover tools 2. Review the returned function signatures and their parameters 3. Call \`exec\` with JavaScript code using those functions (you can chain multiple MCP tools in one \`exec\`) -4. The last expression in your code becomes the result (avoid top-level \`return\`) +4. The last expression (or an explicit \`return\`) becomes the result. If you don't return anything, the result is \`undefined\`. ### Example Usage @@ -527,7 +527,7 @@ exec({ - Handle errors gracefully with try/catch when needed - Use \`parallel()\` for independent operations to improve performance - Prefer a single \`exec\` for multi-step flows to reduce round-trips -- Avoid top-level \`return\`; use the last expression or wrap in an async IIFE +- Return a value (or end with a final expression) so \`exec\` produces output - Use the exact tool names/signatures returned by \`search\` `