.NET: Scope OpenAI hosting storage by isolation key - #8146
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The separator-collision test does not exercise the stated collision, and new guards diverge from the repository’s required validation convention.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Scopes OpenAI response, conversation, and index storage by caller isolation keys while retaining shared behavior when isolation is unconfigured.
Changes:
- Adds isolation-key storage decorators and response-key scoping.
- Covers conversation/response isolation flows.
- Updates hosting security guidance.
File summaries
| File | Description |
|---|---|
OpenAIResponsesIsolationTests.cs |
Tests response ownership isolation. |
OpenAIConversationsIsolationTests.cs |
Tests conversation and index isolation. |
ServiceCollectionExtensions.cs |
Injects isolation into response storage. |
InMemoryResponsesService.cs |
Scopes response and conversation storage IDs. |
IsolationKeyResolver.cs |
Composes escaped scoped identifiers. |
EndpointRouteBuilderExtensions.Responses.cs |
Applies isolation to agent-specific responses. |
EndpointRouteBuilderExtensions.Conversations.cs |
Wraps conversation storage and indexing. |
IsolationKeyScopedConversationStorage.cs |
Adds scoped conversation storage decorator. |
IsolationKeyScopedAgentConversationIndex.cs |
Adds scoped conversation-index decorator. |
AgentWebChat.AgentHost/Program.cs |
Expands production isolation guidance. |
af-hosting/README.md |
Documents multi-user isolation requirements. |
Review details
Suppressed comments (1)
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Conversations/IsolationKeyScopedConversationStorage.cs:62
- Standalone .NET guards in this repository use
_ = Throw.IfNull(...)fromMicrosoft.Shared.Diagnostics(for example,dotnet/src/Microsoft.Agents.AI.Hosting/AIHostAgent.cs:72-73); please use that pattern here.
ArgumentNullException.ThrowIfNull(conversation);
- Files reviewed: 11/11 changed files
- Comments generated: 4
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): c68716c27714
Model: gpt-5.6-sol-fast
Overview
The PR consistently scopes conversation, conversation-index, and response storage keys while preserving bare wire identifiers; strict missing-key behavior and broad cross-caller tests provide strong guardrails. Two residual issues remain: resolver construction assumes a singleton isolation provider despite the public custom-provider contract, and index scoping multiplies a fixed global cache by the number of callers. These can prevent endpoint startup for scoped providers and make conversation listings incomplete beyond 1,000 active caller-agent partitions.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 2 files. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Conversations/IsolationKeyScopedAgentConversationIndex.cs, dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/ServiceCollectionExtensions.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Motivation & Context
Align OpenAI-compatible hosting storage with the existing
AgentIsolationKeyProviderbehavior used by other hosting surfaces. This keeps caller-scoped state handling consistent when applications opt into agent isolation while preserving current behavior for applications without a provider.Description & Review Guide
Related Issue
Related to #3000.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.