From 6c0037f8a14aae65197c37d901174b33fc217505 Mon Sep 17 00:00:00 2001 From: JAE Date: Fri, 27 Mar 2026 04:59:26 +0000 Subject: [PATCH] fix: critical tool registration bug - ChatPanel.setAgent() was overwriting all tools ROOT CAUSE: agent.setTools() registered 8 tools (bash, browser, web-search, image-gen, tts, memory, repl), then chatPanel.setAgent(agent) with no config called this.agent.setTools([artifactsTool]) internally, OVERWRITING all tools. FIX: Pass tools via toolsFactory config parameter so ChatPanel merges them with its own artifacts tool instead of replacing them. This fixes all 'Tool X not found' errors in the web UI. --- packages/web-ui/example/src/main.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/web-ui/example/src/main.ts b/packages/web-ui/example/src/main.ts index 323b6af..30c4896 100644 --- a/packages/web-ui/example/src/main.ts +++ b/packages/web-ui/example/src/main.ts @@ -406,19 +406,20 @@ Persist information across sessions. Use to save important context, user prefere renderApp(); }, }); - // Register tools with the agent + // Register tools via toolsFactory so ChatPanel includes them alongside its artifacts tool const replTool = createJavaScriptReplTool(); - agent.setTools([ - replTool, - createWebSearchTool(), - createBashTool(), - createBrowserTool(), - createImageGenTool(), - createTTSTool(), - ...createMemoryTools(), - ]); costTracker.bindAgent(agent); - chatPanel?.setAgent(agent); + chatPanel?.setAgent(agent, { + toolsFactory: () => [ + replTool, + createWebSearchTool(), + createBashTool(), + createBrowserTool(), + createImageGenTool(), + createTTSTool(), + ...createMemoryTools(), + ], + }); // Hook: live model badge + immediate empty state hide requestAnimationFrame(() => { if (chatPanel?.agentInterface) {