Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions sdk/go/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ func TestFindSendsHeadersQueryAndBody(t *testing.T) {
if !ok || len(levels) != 2 || levels[0] != float64(0) || levels[1] != float64(2) {
t.Fatalf("level = %#v", body["level"])
}
if got := body["agent_id"]; got != "agent-7" {
t.Fatalf("agent_id = %#v", got)
}
if got := body["agent_uri"]; got != "viking://peers/agent-7" {
t.Fatalf("agent_uri = %#v", got)
}
writeOK(t, w, map[string]any{
"resources": []map[string]any{
{"uri": "viking://resources/docs/api.md", "context_type": "resource", "score": 0.9},
Expand All @@ -139,6 +145,8 @@ func TestFindSendsHeadersQueryAndBody(t *testing.T) {
Until: "2026-06-18",
TimeField: "created_at",
Level: []int{0, 2},
AgentID: "agent-7",
AgentURI: "viking://peers/agent-7",
})
if err != nil {
t.Fatal(err)
Expand All @@ -154,7 +162,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", "agent_id", "agent_uri")
writeOK(t, w, map[string]any{"resources": []any{}})
}))
defer closeServer()
Expand Down Expand Up @@ -195,6 +203,12 @@ func TestSearchSendsSessionAndSearchFilters(t *testing.T) {
if !ok || len(levels) != 1 || levels[0] != float64(2) {
t.Fatalf("level = %#v", body["level"])
}
if got := body["agent_id"]; got != "agent-7" {
t.Fatalf("agent_id = %#v", got)
}
if got := body["agent_uri"]; got != "viking://peers/agent-7" {
t.Fatalf("agent_uri = %#v", got)
}
writeOK(t, w, map[string]any{"resources": []any{}})
}))
defer closeServer()
Expand All @@ -206,6 +220,8 @@ func TestSearchSendsSessionAndSearchFilters(t *testing.T) {
Until: "2026-06-18",
TimeField: "updated_at",
Level: []int{2},
AgentID: "agent-7",
AgentURI: "viking://peers/agent-7",
}); err != nil {
t.Fatal(err)
}
Expand All @@ -217,7 +233,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", "agent_id", "agent_uri")
writeOK(t, w, map[string]any{"resources": []any{}})
}))
defer closeServer()
Expand Down
4 changes: 4 additions & 0 deletions sdk/go/retrieval.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func (c *Client) Find(ctx context.Context, queryText string, opts *FindOptions)
if len(opts.Level) > 0 {
payload["level"] = opts.Level
}
setString(payload, "agent_id", opts.AgentID)
setString(payload, "agent_uri", opts.AgentURI)
setAny(payload, "telemetry", opts.Telemetry)
var result FindResult
err := c.doJSON(ctx, http.MethodPost, "/api/v1/search/find", nil, payload, &result)
Expand Down Expand Up @@ -66,6 +68,8 @@ func (c *Client) Search(ctx context.Context, queryText string, opts *SearchOptio
if len(opts.Level) > 0 {
payload["level"] = opts.Level
}
setString(payload, "agent_id", opts.AgentID)
setString(payload, "agent_uri", opts.AgentURI)
setAny(payload, "telemetry", opts.Telemetry)
var result FindResult
err := c.doJSON(ctx, http.MethodPost, "/api/v1/search/search", nil, payload, &result)
Expand Down
13 changes: 13 additions & 0 deletions sdk/go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ type FindOptions struct {
Until string
TimeField string
Level []int
// AgentID / AgentURI select the peer whose memories this call is
// scoped to (server FindRequest.agent_id / agent_uri). This is a
// per-call selector and is mutually exclusive with the client-global
// Config.ActorPeerID header: the server rejects a request that sets a
// different peer via both. Leave empty to use the client-global peer.
AgentID string
AgentURI string
}

// SearchOptions controls Search.
Expand All @@ -177,6 +184,12 @@ type SearchOptions struct {
Until string
TimeField string
Level []int
// AgentID / AgentURI select the peer whose memories this call is
// scoped to (server SearchRequest.agent_id / agent_uri). Per-call
// selector, mutually exclusive with the client-global
// Config.ActorPeerID header. Leave empty to use the client-global peer.
AgentID string
AgentURI string
}

// GrepOptions controls Grep.
Expand Down
Loading