Skip to content

Add an OpenAI Responses file-search (vector store) hosted-tool agent example - #662

Open
PratikDhanave (PratikDhanave) wants to merge 4 commits into
microsoft:mainfrom
PratikDhanaveFork:openai-filesearch-example
Open

Add an OpenAI Responses file-search (vector store) hosted-tool agent example#662
PratikDhanave (PratikDhanave) wants to merge 4 commits into
microsoft:mainfrom
PratikDhanaveFork:openai-filesearch-example

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

What

Adds examples/02-agents/providers/openai/filesearch/main.go, a new example that builds an OpenAI Responses agent using the hosted file-search (vector store) tool. It wires hostedtool.FileSearch with a message.HostedVectorStoreContent input and MaximumResultCount, runs a retrieval-style query via RunText, and prints the grounded answer.

No production code is touched — the file-search wiring already exists in provider/openaiprovider/responses.go (case *hostedtool.FileSearch -> responses.FileSearchToolParam, appending VectorStoreID to VectorStoreIDs and mapping MaximumResultCount to MaxNumResults); this only adds the missing example surface for it.

Why

The hosted file-search / RAG path had no example anywhere under examples/ (grep for FileSearch/VectorStore returned zero hits). Web search and code interpreter hosted tools already ship examples, so this fills the file-search gap and mirrors the .NET/Python samples, where hosted file-search over a vector store is a first-class documented agent scenario. It keeps the Go port aligned with the other SDKs' example coverage.

How it is tested

  • go build ./... passes.
  • go vet ./examples/... passes.
  • The run is gated on a VECTOR_STORE_ID env var: when unset it prints setup instructions and returns, mirroring how other provider examples gate on credentials, so it is safe in CI without a live vector store.

The example follows the existing hosted-tool example layout (e.g. foundry/step21_web_search) and reuses the shared examples/internal/demo helpers (NewLogger, Response, Assistant).

Copilot AI review requested due to automatic review settings July 23, 2026 08:18
@PratikDhanave
PratikDhanave (PratikDhanave) requested a review from a team as a code owner July 23, 2026 08:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Go example demonstrating how to wire the OpenAI Responses hosted file_search tool against a hosted vector store, aligning the Go SDK’s example coverage with other hosted-tool examples (e.g., web search) and other language SDK samples.

Changes:

  • Introduces examples/02-agents/providers/openai/filesearch/main.go, an OpenAI Responses agent example that configures hostedtool.FileSearch with HostedVectorStoreContent and MaximumResultCount.
  • Gates execution on VECTOR_STORE_ID to keep the example safe to build/run in CI without requiring a live vector store.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +23
import (
"context"
"os"

"github.com/microsoft/agent-framework-go/agent"
"github.com/microsoft/agent-framework-go/examples/internal/demo"
"github.com/microsoft/agent-framework-go/message"
"github.com/microsoft/agent-framework-go/provider/openaiprovider"
"github.com/microsoft/agent-framework-go/tool"
"github.com/microsoft/agent-framework-go/tool/hostedtool"
"github.com/openai/openai-go/v3"
)

// vectorStoreID identifies the OpenAI vector store the file-search tool queries.
// Create one via the OpenAI dashboard or API, upload your documents to it, then
// export its identifier before running this example:
//
// export VECTOR_STORE_ID=vs_...
var vectorStoreID = os.Getenv("VECTOR_STORE_ID")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in b0870b0: VECTOR_STORE_ID is now read via strings.TrimSpace, so trailing newlines or whitespace-only values are normalized before the empty-guard check.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Jul 23, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Add examples/02-agents/providers/openai/filesearch demonstrating the
hosted file-search (vector store) tool with an OpenAI Responses agent.
The example wires hostedtool.FileSearch with a HostedVectorStoreContent
input and MaximumResultCount, runs a retrieval-style query via RunText,
and gates the run on VECTOR_STORE_ID so CI does not require a live store.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added area:examples Changes files in the examples area size:medium At most 100 changed lines across at most 5 files pending-auto-risk Automatic risk classification is in progress labels Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Parity Review — ✅ No Issues Found

This PR adds only an example file (examples/02-agents/providers/openai/filesearch/main.go) with no changes to production code or exported Go APIs.

Cross-repo example coverage check:

  • .NET equivalent: dotnet/samples/02-agents/AgentProviders/foundry/Agent_Step16_FileSearch/ — hosted file-search over a vector store is a documented Foundry-provider scenario.
  • Python equivalent: python/samples/02-agents/providers/openai/client_with_file_search.py — direct OpenAI Responses provider file-search sample.

The Go example fills the same gap that these upstream samples cover, using the already-shipped hostedtool.FileSearch + message.HostedVectorStoreContent wiring in provider/openaiprovider/responses.go. The scenario, credential-gating pattern, and helper usage are consistent with the existing Go hosted-tool examples (foundry/step21_web_search, etc.).

Label assessment: No exported API surface changed → public-api-change label correctly absent. parity-approved label is appropriate and retained.

Generated by Go API Consistency Review Agent · sonnet46 · 16.4 AIC · ⌖ 5.7 AIC · ⊞ 6K ·

@github-actions github-actions Bot added failed-auto-risk Automatic risk classification was inconclusive or failed and removed pending-auto-risk Automatic risk classification is in progress labels Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:examples Changes files in the examples area failed-auto-risk Automatic risk classification was inconclusive or failed parity-approved Go API consistency review found no parity issues size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants