Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(go-agent): fix Tavily tool array schemas (#17640)

Hz_d1127d597396
diff --git a/internal/agent/tool/tavily.go b/internal/agent/tool/tavily.go
index f85e825828..4eaed95443 100644
--- a/internal/agent/tool/tavily.go
+++ b/internal/agent/tool/tavily.go
@@ -234,11 +234,13 @@ func (t *TavilyTool) Info(_ context.Context) (*schema.ToolInfo, error) {
},
"include_domains": {
Type: schema.Array,
+ ElemInfo: &schema.ParameterInfo{Type: schema.String},
Desc: "Domains that search results must include.",
Required: false,
},
"exclude_domains": {
Type: schema.Array,
+ ElemInfo: &schema.ParameterInfo{Type: schema.String},
Desc: "Domains that search results must exclude.",
Required: false,
},
@@ -254,6 +256,7 @@ func (t *TavilyExtractTool) Info(_ context.Context) (*schema.ToolInfo, error) {
ParamsOneOf: schema.NewParamsOneOfByParams(map[string]*schema.ParameterInfo{
"urls": {
Type: schema.Array,
+ ElemInfo: &schema.ParameterInfo{Type: schema.String},
Desc: "The URLs to extract content from.",
Required: true,
},
diff --git a/internal/agent/tool/tavily_test.go b/internal/agent/tool/tavily_test.go
index 7f3f96c6f1..72b082a339 100644
--- a/internal/agent/tool/tavily_test.go
+++ b/internal/agent/tool/tavily_test.go
@@ -23,6 +23,8 @@ import (
"net/http/httptest"
"strings"
"testing"
+
+ "github.com/cloudwego/eino/schema"
)
func TestTavily_BuildRequest(t *testing.T) {
@@ -183,6 +185,52 @@ func TestTavily_Info(t *testing.T) {
}
}
+func TestTavily_InfoArraySchemasIncludeStringItems(t *testing.T) {
+ t.Parallel()
+
+ info, err := NewTavilyTool().Info(context.Background())
+ if err != nil {
+ t.Fatalf("Tavily Info: %v", err)
+ }
+ assertToolArrayItemType(t, info, "include_domains")
+ assertToolArrayItemType(t, info, "exclude_domains")
+
+ extractInfo, err := NewTavilyExtractTool().Info(context.Background())
+ if err != nil {
+ t.Fatalf("Tavily Extract Info: %v", err)
+ }
+ assertToolArrayItemType(t, extractInfo, "urls")
+}
+
+func assertToolArrayItemType(t *testing.T, info *schema.ToolInfo, fieldName string) {
+ t.Helper()
+
+ params, err := info.ParamsOneOf.ToJSONSchema()
+ if err != nil {
+ t.Fatalf("convert %s schema: %v", info.Name, err)
+ }
+ rawSchema, err := json.Marshal(params)
+ if err != nil {
+ t.Fatalf("marshal %s schema: %v", info.Name, err)
+ }
+ var schemaMap map[string]any
+ if err := json.Unmarshal(rawSchema, &schemaMap); err != nil {
+ t.Fatalf("decode %s schema: %v", info.Name, err)
+ }
+ properties, ok := schemaMap["properties"].(map[string]any)
+ if !ok {
+ t.Fatalf("%s schema properties = %#v", info.Name, schemaMap["properties"])
+ }
+ field, ok := properties[fieldName].(map[string]any)
+ if !ok {
+ t.Fatalf("%s schema field %q = %#v", info.Name, fieldName, properties[fieldName])
+ }
+ items, ok := field["items"].(map[string]any)
+ if !ok || items["type"] != "string" {
+ t.Fatalf("%s schema field %q items = %#v, want {type: string}", info.Name, fieldName, field["items"])
+ }
+}
+
func TestTavily_EmptyQueryReturnsEmptyResults(t *testing.T) {
t.Parallel()