From 8c743882ea4d856b1760b6aa0b7c498ddc8305b1 Mon Sep 17 00:00:00 2001 From: r266-tech Date: Fri, 19 Jun 2026 16:50:21 +0800 Subject: [PATCH] feat(sdk/go): expose tags search filter on Find and Search The server and Python SDK accept a validated `tags` retrieval filter, but the Go SDK had no way to send it. Add a `Tags []string` option to FindOptions and SearchOptions and forward it as payload["tags"] to /api/v1/search/find and /api/v1/search/search, omitting the key when the slice is empty (mirroring the existing level filter). Follow-up to #2703, which added since/until/time_field/level to the same Find/Search funcs in the same files the same way. --- sdk/go/client_test.go | 14 ++++++++++++-- sdk/go/retrieval.go | 6 ++++++ sdk/go/types.go | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sdk/go/client_test.go b/sdk/go/client_test.go index 0f82cb1794..d68ea7bb8c 100644 --- a/sdk/go/client_test.go +++ b/sdk/go/client_test.go @@ -123,6 +123,10 @@ func TestFindSendsHeadersQueryAndBody(t *testing.T) { if !ok || len(levels) != 2 || levels[0] != float64(0) || levels[1] != float64(2) { t.Fatalf("level = %#v", body["level"]) } + tags, ok := body["tags"].([]any) + if !ok || len(tags) != 2 || tags[0] != "project-x" || tags[1] != "draft" { + t.Fatalf("tags = %#v", body["tags"]) + } writeOK(t, w, map[string]any{ "resources": []map[string]any{ {"uri": "viking://resources/docs/api.md", "context_type": "resource", "score": 0.9}, @@ -139,6 +143,7 @@ func TestFindSendsHeadersQueryAndBody(t *testing.T) { Until: "2026-06-18", TimeField: "created_at", Level: []int{0, 2}, + Tags: []string{"project-x", "draft"}, }) if err != nil { t.Fatal(err) @@ -154,7 +159,7 @@ func TestFindOmitsSearchFiltersWhenUnset(t *testing.T) { t.Fatalf("path = %s", r.URL.Path) } body := readJSONBody(t, r) - requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level") + requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level", "tags") writeOK(t, w, map[string]any{"resources": []any{}}) })) defer closeServer() @@ -195,6 +200,10 @@ func TestSearchSendsSessionAndSearchFilters(t *testing.T) { if !ok || len(levels) != 1 || levels[0] != float64(2) { t.Fatalf("level = %#v", body["level"]) } + tags, ok := body["tags"].([]any) + if !ok || len(tags) != 1 || tags[0] != "project-x" { + t.Fatalf("tags = %#v", body["tags"]) + } writeOK(t, w, map[string]any{"resources": []any{}}) })) defer closeServer() @@ -206,6 +215,7 @@ func TestSearchSendsSessionAndSearchFilters(t *testing.T) { Until: "2026-06-18", TimeField: "updated_at", Level: []int{2}, + Tags: []string{"project-x"}, }); err != nil { t.Fatal(err) } @@ -217,7 +227,7 @@ func TestSearchOmitsSearchFiltersWhenUnset(t *testing.T) { t.Fatalf("path = %s", r.URL.Path) } body := readJSONBody(t, r) - requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level") + requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level", "tags") writeOK(t, w, map[string]any{"resources": []any{}}) })) defer closeServer() diff --git a/sdk/go/retrieval.go b/sdk/go/retrieval.go index 72d32e3a02..5cd547d15e 100644 --- a/sdk/go/retrieval.go +++ b/sdk/go/retrieval.go @@ -32,6 +32,9 @@ func (c *Client) Find(ctx context.Context, queryText string, opts *FindOptions) if len(opts.Level) > 0 { payload["level"] = opts.Level } + if len(opts.Tags) > 0 { + payload["tags"] = opts.Tags + } setAny(payload, "telemetry", opts.Telemetry) var result FindResult err := c.doJSON(ctx, http.MethodPost, "/api/v1/search/find", nil, payload, &result) @@ -66,6 +69,9 @@ func (c *Client) Search(ctx context.Context, queryText string, opts *SearchOptio if len(opts.Level) > 0 { payload["level"] = opts.Level } + if len(opts.Tags) > 0 { + payload["tags"] = opts.Tags + } setAny(payload, "telemetry", opts.Telemetry) var result FindResult err := c.doJSON(ctx, http.MethodPost, "/api/v1/search/search", nil, payload, &result) diff --git a/sdk/go/types.go b/sdk/go/types.go index 7e18886bcd..49ce35f381 100644 --- a/sdk/go/types.go +++ b/sdk/go/types.go @@ -161,6 +161,7 @@ type FindOptions struct { Until string TimeField string Level []int + Tags []string } // SearchOptions controls Search. @@ -177,6 +178,7 @@ type SearchOptions struct { Until string TimeField string Level []int + Tags []string } // GrepOptions controls Grep.