feat(sdk/go): expose agent_id/agent_uri peer selector on Find and Search#2758
Merged
MaojiaSheng merged 1 commit intoJun 22, 2026
Merged
Conversation
Server FindRequest/SearchRequest accept and use agent_id/agent_uri to scope retrieval to a peer (_ctx_with_legacy_actor_peer), but the Go SDK could only set a client-global X-OpenViking-Actor-Peer header and had no per-call selector. Add AgentID/AgentURI to FindOptions/SearchOptions (appended for unkeyed-literal compat, mirroring volcengine#2703) and forward them via setString (omit-empty) in Find and Search; add request-body tests.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
MaojiaSheng
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up in the Go SDK parity cluster (after merged #2703 date/level filters; siblings #2730 tags, #2731 include_provenance).
Gap
The server
FindRequest/SearchRequestaccept and actively useagent_id/agent_uri(openviking/server/routers/search.py):normalize_request_peer_idnormalizes them, andfind/searchcall_ctx_with_legacy_actor_peer(ctx, request.agent_id)to scope retrieval to that peer (setting bothactor_peer_idandlegacy_agent_id).The Go SDK had no way to send a per-call peer selector —
FindOptions/SearchOptionslacked the fields andFind()/Search()never sent them. The only Go path was the client-globalX-OpenViking-Actor-Peerheader fromConfig.ActorPeerID(transport.go), and that header path does not setlegacy_agent_id. So Go callers couldn't do per-call agent-scoped retrieval, unlike the Python SDK and the generated web-studio client.Change
types.go: addAgentID/AgentURItoFindOptionsandSearchOptions, appended after the existing fields (keeps unkeyed-composite-literal compatibility, same convention as fix(sdk/go): expose search date and level filters #2703).retrieval.go: forward viasetString(payload, "agent_id", opts.AgentID)/"agent_uri"in bothFindandSearch—setStringomits empty values, so the keys are sent only when set.client_test.go: assert both keys are forwarded on each path, and add them to therequireBodyKeysAbsentchecks so unset options omit them.GoDoc notes the per-call selector is mutually exclusive with the client-global
Config.ActorPeerIDheader (the server rejects a request that sets a different peer via both,search.py_ctx_with_legacy_actor_peer).The Go SDK stays a thin HTTP client: it forwards these server-owned values rather than duplicating server-side peer validation.
Test
go vet ./...clean;go test ./...passes. The two send-tests fail against the pre-changeretrieval.go(agent_id = <nil>), confirming the forwarding is actually covered.