From b175ed582fe2d61bd5ea47eba3ce24a051f7a68f Mon Sep 17 00:00:00 2001 From: Hz_ Date: Wed, 22 Jul 2026 10:38:26 +0800 Subject: [PATCH] fix(go-agent): support Tavily tool names (#17163) ## Summary - Register `TavilySearch` and `TavilyExtract` Canvas component names in the Go Agent tool registry. - Add regression coverage for building both tools by their Python component names. ## Testing - `bash build.sh --test ./internal/agent/tool/...` - `bash build.sh --test ./internal/agent/component/...` --- internal/agent/tool/registry.go | 18 +++++++++++------- internal/agent/tool/registry_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/internal/agent/tool/registry.go b/internal/agent/tool/registry.go index 7388eeecef..2130bcdf53 100644 --- a/internal/agent/tool/registry.go +++ b/internal/agent/tool/registry.go @@ -54,13 +54,17 @@ var registry = map[string]Factory{ "search_my_dateset": buildRetrievalTool, "searxng": buildSearXNGTool, "tavily": buildTavilyTool, - "tavily_extract": buildTavilyExtractTool, - "tushare": noConfig("tushare", func() einotool.BaseTool { return NewTushareTool() }), - "wencai": buildWencaiTool, - "web_crawler": noConfig("web_crawler", func() einotool.BaseTool { return NewCrawlerTool() }), - "wikipedia": buildWikipediaTool, - "wikipedia_search": buildWikipediaTool, - "yahoo_finance": buildYahooFinanceTool, + // Agent DSL tool lists carry the Python Canvas component_name verbatim. + // BuildByName lower-cases names, so register those component names too. + "tavilysearch": buildTavilyTool, + "tavily_extract": buildTavilyExtractTool, + "tavilyextract": buildTavilyExtractTool, + "tushare": noConfig("tushare", func() einotool.BaseTool { return NewTushareTool() }), + "wencai": buildWencaiTool, + "web_crawler": noConfig("web_crawler", func() einotool.BaseTool { return NewCrawlerTool() }), + "wikipedia": buildWikipediaTool, + "wikipedia_search": buildWikipediaTool, + "yahoo_finance": buildYahooFinanceTool, } func noConfig(name string, fn func() einotool.BaseTool) Factory { diff --git a/internal/agent/tool/registry_test.go b/internal/agent/tool/registry_test.go index a01a318f8b..60dcf83578 100644 --- a/internal/agent/tool/registry_test.go +++ b/internal/agent/tool/registry_test.go @@ -40,6 +40,30 @@ func TestBuildAll_UnknownTool(t *testing.T) { } } +func TestBuildByName_TavilyCanvasComponentNames(t *testing.T) { + for _, tc := range []struct { + name string + }{ + {name: "TavilySearch"}, + {name: "TavilyExtract"}, + } { + built, err := BuildByName(tc.name, nil) + if err != nil { + t.Fatalf("BuildByName(%q): %v", tc.name, err) + } + switch tc.name { + case "TavilySearch": + if _, ok := built.(*TavilyTool); !ok { + t.Errorf("BuildByName(%q) returned %T, want *TavilyTool", tc.name, built) + } + case "TavilyExtract": + if _, ok := built.(*TavilyExtractTool); !ok { + t.Errorf("BuildByName(%q) returned %T, want *TavilyExtractTool", tc.name, built) + } + } + } +} + func TestBuildAll_AllRegisteredTools(t *testing.T) { // Every key in registry. names := []string{