refactor: update tool registry usage and enhance WebSearchTool execution result handling

This commit is contained in:
Satyam Tiwari
2026-02-13 15:41:37 +05:30
parent e0a766243e
commit c86e121688
2 changed files with 12 additions and 4 deletions

View File

@@ -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

View File

@@ -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 {