Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Microsoft Foundry supports two distinct context patterns. Both use Foundry-managed resources, but they attach to an agent differently and solve different problems.
| Pattern | Agent Framework mechanism | Behavior |
|---|---|---|
| File-search RAG | Provider-hosted file-search tool | Searches files and vector stores that your application explicitly uploads and manages in a Foundry project. |
| Managed semantic memory | FoundryMemoryProvider context provider |
Extracts facts and summaries from conversations, stores them by scope, and retrieves relevant memories in later runs. |
For model inference and service-managed Foundry agents, see Microsoft Foundry model provider and Microsoft Foundry Agent Service.
Use file-search RAG
Use this pattern when Foundry should own document ingestion and vector-store lifecycle for a curated knowledge base. File search is a hosted tool rather than a context provider; see the generic file search guidance for tool behavior. Use Foundry IQ (Azure AI Search) when the application's source of truth is a Foundry IQ index.
Create a Foundry vector store and agent
Upload a knowledge-base file, create a vector store, attach FileSearchTool, and create a versioned FoundryAgent.
Reuse persistent vector stores for production knowledge bases instead of creating them for every process run.
Install the package
pip install agent-framework-foundry
Create files and a vector store through the Foundry project OpenAI client, then pass the resulting file-search tool to the agent.
Go supports Foundry-hosted file search through hostedtool.FileSearch on a model-deployment agent. Reference an existing vector store with message.HostedVectorStoreContent in the tool's Inputs. Foundry performs retrieval on the service side.
For provisioning and cleanup, see the Foundry service RAG sample. It uploads a knowledge-base file, creates a vector store, waits for indexing, and invokes a server-side agent version.
Warning
The sample creates and deletes an agent named AskContoso, including its versions, and cleans up its file and vector store. Use a disposable project where that agent name isn't in use.
See File search for the Go tool declaration and Microsoft Foundry model provider for agent construction.
Add managed semantic memory
Use FoundryMemoryProvider when an agent should recall durable user or application context across sessions. Foundry memory stores extracted facts and summaries separately from the full conversation transcript.
Install the package
dotnet add package Microsoft.Agents.AI.Foundry --prerelease
Create FoundryMemoryProvider with a stable scope, ensure the memory store exists, and wait for asynchronous updates before relying on newly extracted memories.
Install the package
pip install agent-framework-foundry
Create the memory store through AIProjectClient, then attach FoundryMemoryProvider to the agent.
The sample disables service-side and local transcript loading so the later response demonstrates semantic memory rather than chat-history replay.
For a hosted agent, derive the memory scope from trusted platform identity rather than caller input or model options. Decide the intended sharing boundary explicitly. A user-only scope shares that user's long-term memories across sandboxes and across agents that use the same project Memory Store. Include an application boundary in the scope or use separate Memory Stores when those agents must not share memory.
Create the Memory provider and project client inside the request-scoped agent
factory when they use the current platform call ID. Conversation storage and
long-term memory are independent: a Responses request with store=false
doesn't undo a Memory provider's deliberate read or write side effects.
Go supports managed Foundry memory through foundryprovider.NewMemoryProvider. Pass the project endpoint, Azure token credential, existing memory-store name, a scope callback, and foundryprovider.MemoryProviderConfig, then add the result to agent.Config.ContextProviders.
The provider retrieves memories before a run and submits conversation updates afterward. The memory store must already exist. Return a stable, nonblank scope derived from the authenticated user or tenant; a demonstration constant isn't suitable for multi-user isolation.
Configure MemoryProviderConfig.Logger for diagnostics and use its message filters to control which content is searched and stored. See the Foundry memory sample and Go provider configuration.
Production considerations
- Reuse persistent vector stores for production knowledge bases.
- Use application-owned stable memory scope identifiers and authorize access before selecting a scope.
- Wait for asynchronous extraction when a subsequent operation depends on newly written memory.
- Keep exact transcripts in a history provider when you need complete conversation records.
- Configure retention, region, and model deployments to match your compliance requirements.
Next steps
Go deeper: