From c86e121688c3cf1a1423192effdb0ae68918d5ed Mon Sep 17 00:00:00 2001 From: Satyam Tiwari Date: Fri, 13 Feb 2026 15:41:37 +0530 Subject: [PATCH] refactor: update tool registry usage and enhance WebSearchTool execution result handling --- pkg/agent/loop.go | 4 ++-- pkg/tools/web.go | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 02885a4..dfe466d 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -77,9 +77,9 @@ func createToolRegistry(workspace string, restrict bool, cfg *config.Config, msg DuckDuckGoMaxResults: cfg.Tools.Web.DuckDuckGo.MaxResults, DuckDuckGoEnabled: cfg.Tools.Web.DuckDuckGo.Enabled, }); searchTool != nil { - toolsRegistry.Register(searchTool) + registry.Register(searchTool) } - toolsRegistry.Register(tools.NewWebFetchTool(50000)) + registry.Register(tools.NewWebFetchTool(50000)) // Message tool - available to both agent and subagent // Subagent uses it to communicate directly with user diff --git a/pkg/tools/web.go b/pkg/tools/web.go index 2d0fd07..6fc89c9 100644 --- a/pkg/tools/web.go +++ b/pkg/tools/web.go @@ -248,7 +248,7 @@ func (t *WebSearchTool) Parameters() map[string]interface{} { } } -func (t *WebSearchTool) Execute(ctx context.Context, args map[string]interface{}) (string, error) { +func (t *WebSearchTool) Execute(ctx context.Context, args map[string]interface{}) *ToolResult { query, ok := args["query"].(string) if !ok { return ErrorResult("query is required") @@ -261,7 +261,15 @@ func (t *WebSearchTool) Execute(ctx context.Context, args map[string]interface{} } } - return t.provider.Search(ctx, query, count) + result, err := t.provider.Search(ctx, query, count) + if err != nil { + return ErrorResult(fmt.Sprintf("search failed: %v", err)) + } + + return &ToolResult{ + ForLLM: result, + ForUser: result, + } } type WebFetchTool struct {