// Copyright (c) Microsoft. All rights reserved. using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; using Azure.AI.AgentServer.Responses; using Azure.AI.AgentServer.Responses.Models; using Microsoft.Shared.DiagnosticIds; namespace Microsoft.Agents.AI.Foundry.Hosting; /// /// Resolves the per-request for a Foundry hosted agent. /// /// /// /// Implementations are invoked once per incoming Responses API request. The returned /// establishes the identity of a freshly created session and /// is validated against the live request on every subsequent invocation that resumes the same session. /// /// /// The default implementation registered when no custom /// is present in DI maps the platform-injected x-agent-user-isolation-key and /// x-agent-chat-isolation-key headers via . Hosting samples and contributor-only environments /// can register an alternate implementation in DI to provide values when the platform headers are absent /// (e.g., during local Docker debugging). /// /// /// Implementations must return a whose /// and are both non-null and non-whitespace. Returning either as null /// (or throwing from ) is treated as a configuration error and surfaces as a /// 500 from the hosting layer. /// /// [Experimental(DiagnosticIds.Experiments.AIOpenAIResponses)] public abstract class HostedSessionIsolationKeyProvider { /// /// Resolves the for the supplied request. /// /// The per-request from the Azure AI Responses Server SDK. /// The describing the incoming request. /// The to monitor for cancellation requests. /// /// A with non-null and /// , or when the implementation cannot /// produce identity keys for the current request. A result is treated as a /// configuration error by the hosting layer and surfaces as 500. /// public abstract ValueTask GetKeysAsync( ResponseContext context, CreateResponse request, CancellationToken cancellationToken); }