Skip to content

.NET: Scope OpenAI hosting storage by isolation key - #8146

Merged
SergeyMenshykh merged 4 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-openai-storage-scoping
Sep 8, 2026
Merged

.NET: Scope OpenAI hosting storage by isolation key#8146
SergeyMenshykh merged 4 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-openai-storage-scoping

Conversation

@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Motivation & Context

Align OpenAI-compatible hosting storage with the existing AgentIsolationKeyProvider behavior 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

  • What are the major changes? OpenAI conversation, conversation-index, and response storage identifiers now use the registered isolation key; coverage and hosting guidance are updated accordingly.
  • What is the impact of these changes? Applications that configure agent isolation receive caller-scoped OpenAI hosting state. Applications without an isolation provider retain the existing shared in-memory behavior.
  • What do you want reviewers to focus on? Consistency with the existing isolation-key transformation and compatibility across conversation and response flows.

Related Issue

Related to #3000.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 8, 2026 10:55
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net labels Sep 8, 2026
@SergeyMenshykh
SergeyMenshykh marked this pull request as ready for review September 8, 2026 10:55
@SergeyMenshykh SergeyMenshykh self-assigned this Sep 8, 2026

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.

🟡 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(...) from Microsoft.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.

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

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>
@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue Sep 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 8, 2026
@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue Sep 8, 2026
Merged via the queue into microsoft:main with commit a903a4e Sep 8, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants