Skip to content

feat(sdk/go): expose agent_id/agent_uri peer selector on Find and Search#2758

Merged
MaojiaSheng merged 1 commit into
volcengine:mainfrom
r266-tech:feat/gosdk-agent-id-uri-peer-selector
Jun 22, 2026
Merged

feat(sdk/go): expose agent_id/agent_uri peer selector on Find and Search#2758
MaojiaSheng merged 1 commit into
volcengine:mainfrom
r266-tech:feat/gosdk-agent-id-uri-peer-selector

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Follow-up in the Go SDK parity cluster (after merged #2703 date/level filters; siblings #2730 tags, #2731 include_provenance).

Gap

The server FindRequest / SearchRequest accept and actively use agent_id / agent_uri (openviking/server/routers/search.py): normalize_request_peer_id normalizes them, and find/search call _ctx_with_legacy_actor_peer(ctx, request.agent_id) to scope retrieval to that peer (setting both actor_peer_id and legacy_agent_id).

The Go SDK had no way to send a per-call peer selector — FindOptions/SearchOptions lacked the fields and Find()/Search() never sent them. The only Go path was the client-global X-OpenViking-Actor-Peer header from Config.ActorPeerID (transport.go), and that header path does not set legacy_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: add AgentID / AgentURI to FindOptions and SearchOptions, 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 via setString(payload, "agent_id", opts.AgentID) / "agent_uri" in both Find and SearchsetString omits 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 the requireBodyKeysAbsent checks so unset options omit them.

GoDoc notes the per-call selector is mutually exclusive with the client-global Config.ActorPeerID header (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-change retrieval.go (agent_id = <nil>), confirming the forwarding is actually covered.

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.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 95
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@MaojiaSheng MaojiaSheng merged commit 4a746d5 into volcengine:main Jun 22, 2026
4 of 5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants