mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
401a552735
* feat: Add DelegatingAgentSessionStore Add helper for decorator pattern for AgentSessionStore * feat: Add UserIdentityScopedSessionStore Add support for using the ASP.Net Core ambient `ClaimsIdentity` User, along with a user-specified claim type to scope the session store based on authenticated identity. * fix: Harden scope mapping * fix: Add UserIdentityScopeSessionStoreOptions to avoid future breaking changes * Split UserIdentityScopedSessionStore into a separate IsolationKeyProvider and IsolationKeyScopedSessionStore * Add GetService<>() capabilities to interrogate AgentSessionStore delegation chain * Harden default for A2A hosting by using an IsolationKeyScopedAgentSessionStore when no store is available. * Pipe isolation through Hosting helper extension methods * Add comment to samples about adding SessionIsolationKeyProvider * Fix isolation key provider nullability semantics * fix A2A defaults * fixup * remove unneeded keyProvider requirement test * Add trust-model XML docs to AgentSessionStore, InMemoryAgentSessionStore, MapAGUI, A2A entry points Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/e466c53a-faad-40a8-8b5f-83cf0dce0b1d Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com> * fix: Switch ClaimsBasedIsolationKeyProvider to be Singleton * matches HttpContextAccessor and related MAF services * release: Ensure new project is in the release filter * fixup: Integraitaon tests --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
40 lines
1.8 KiB
C#
40 lines
1.8 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Microsoft.Agents.AI.Hosting;
|
|
|
|
/// <summary>
|
|
/// Provides an abstract base class for resolving session isolation keys used to scope agent sessions.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Session isolation keys enable multi-tenant or multi-user scenarios by scoping agent session storage
|
|
/// to a specific logical partition (e.g., user ID, tenant ID, or composite key). Derived classes
|
|
/// implement the key resolution logic appropriate to their hosting environment.
|
|
/// </para>
|
|
/// <para>
|
|
/// When a key is unavailable or cannot be determined, implementations should return <see langword="null"/>.
|
|
/// The consuming session store can then enforce strict behavior (throwing an exception) or fall back
|
|
/// to unscoped storage based on its configuration.
|
|
/// </para>
|
|
/// </remarks>
|
|
public abstract class SessionIsolationKeyProvider
|
|
{
|
|
/// <summary>
|
|
/// Asynchronously retrieves the session isolation key for the current request or execution context.
|
|
/// </summary>
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
|
|
/// <returns>
|
|
/// A task that represents the asynchronous operation. The task result contains the isolation key string,
|
|
/// or <see langword="null"/> if no key is available in the current context.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// Implementations should extract the key from ambient context (e.g., HTTP request headers, claims,
|
|
/// or environment variables). If the key cannot be determined, return <see langword="null"/> to allow
|
|
/// the caller to decide on strict vs. pass-through behavior.
|
|
/// </remarks>
|
|
public abstract ValueTask<string?> GetSessionIsolationKeyAsync(CancellationToken cancellationToken = default);
|
|
}
|