Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,34 @@ public abstract class AgentSessionStore
/// <param name="session">The session to save.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
/// <returns>A task that represents the asynchronous save operation.</returns>
#pragma warning disable RS0026 // Overloaded by a sessionId-based convenience method.
public abstract ValueTask SaveSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
AgentSession session,
CancellationToken cancellationToken = default);
#pragma warning restore RS0026

/// <summary>
/// Saves an agent session to persistent storage using a session identifier without partitions.
/// </summary>
/// <param name="agent">The agent that owns this session.</param>
/// <param name="sessionId">The logical session identifier.</param>
/// <param name="session">The session to save.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
/// <returns>A task that represents the asynchronous save operation.</returns>
/// <remarks>
/// This is a convenience overload that creates an <see cref="AgentSessionStoreKey"/> from
/// <paramref name="sessionId"/> and calls <see cref="SaveSessionAsync(AIAgent, AgentSessionStoreKey, AgentSession, CancellationToken)"/>.
/// </remarks>
#pragma warning disable RS0026 // Convenience overload that mirrors the AgentSessionStoreKey-based method.
public ValueTask SaveSessionAsync(
AIAgent agent,
string sessionId,
AgentSession session,
CancellationToken cancellationToken = default)
=> this.SaveSessionAsync(agent, new AgentSessionStoreKey(sessionId), session, cancellationToken);
#pragma warning restore RS0026

/// <summary>
/// Retrieves an agent session from persistent storage, or <see langword="null"/> when no session is stored
Expand All @@ -50,10 +73,35 @@ public abstract ValueTask SaveSessionAsync(
/// branches observing one another's changes or modifying the stored state. Implementations that cache a
/// live session must return an independent copy rather than the shared instance.
/// </remarks>
#pragma warning disable RS0026 // Overloaded by a sessionId-based convenience method.
public abstract ValueTask<AgentSession?> GetSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
CancellationToken cancellationToken = default);
#pragma warning restore RS0026

/// <summary>
/// Retrieves an agent session from persistent storage using a session identifier without partitions,
/// or <see langword="null"/> when no session is stored for the given identifier.
/// </summary>
/// <param name="agent">The agent that owns this session.</param>
/// <param name="sessionId">The logical session identifier.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
/// <returns>
/// A task whose result contains the restored session, or <see langword="null"/> when nothing is stored for
/// the given identifier. This method never creates a session.
/// </returns>
/// <remarks>
/// This is a convenience overload that creates an <see cref="AgentSessionStoreKey"/> from
/// <paramref name="sessionId"/> and calls <see cref="GetSessionAsync(AIAgent, AgentSessionStoreKey, CancellationToken)"/>.
/// </remarks>
#pragma warning disable RS0026 // Convenience overload that mirrors the AgentSessionStoreKey-based method.
public ValueTask<AgentSession?> GetSessionAsync(
AIAgent agent,
string sessionId,
CancellationToken cancellationToken = default)
=> this.GetSessionAsync(agent, new AgentSessionStoreKey(sessionId), cancellationToken);
#pragma warning restore RS0026

/// <summary>
/// Retrieves the stored session for the given identifiers, or creates a new one when none is stored.
Expand All @@ -63,10 +111,12 @@ public abstract ValueTask SaveSessionAsync(
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
/// <returns>A task whose result is always a usable session.</returns>
/// <remarks>
/// The default implementation calls <see cref="GetSessionAsync"/> and creates a session through
/// <see cref="AIAgent.CreateSessionAsync"/> only when the lookup returns <see langword="null"/>.
/// Implementations that override <see cref="GetSessionAsync"/> receive this behavior automatically.
/// The default implementation calls <see cref="GetSessionAsync(AIAgent, AgentSessionStoreKey, CancellationToken)"/>
/// and creates a session through <see cref="AIAgent.CreateSessionAsync"/> only when the lookup returns
/// <see langword="null"/>. Implementations that override
/// <see cref="GetSessionAsync(AIAgent, AgentSessionStoreKey, CancellationToken)"/> receive this behavior automatically.
/// </remarks>
#pragma warning disable RS0026 // Overloaded by a sessionId-based convenience method.
public virtual async ValueTask<AgentSession> GetOrCreateSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
Expand All @@ -77,6 +127,27 @@ public virtual async ValueTask<AgentSession> GetOrCreateSessionAsync(
return await this.GetSessionAsync(agent, key, cancellationToken).ConfigureAwait(false)
?? await agent.CreateSessionAsync(cancellationToken).ConfigureAwait(false);
}
#pragma warning restore RS0026

/// <summary>
/// Retrieves the stored session for the given session identifier without partitions, or creates a new one
/// when none is stored.
/// </summary>
/// <param name="agent">The agent that owns this session.</param>
/// <param name="sessionId">The logical session identifier.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
/// <returns>A task whose result is always a usable session.</returns>
/// <remarks>
/// This is a convenience overload that creates an <see cref="AgentSessionStoreKey"/> from
/// <paramref name="sessionId"/> and calls <see cref="GetOrCreateSessionAsync(AIAgent, AgentSessionStoreKey, CancellationToken)"/>.
/// </remarks>
#pragma warning disable RS0026 // Convenience overload that mirrors the AgentSessionStoreKey-based method.
public ValueTask<AgentSession> GetOrCreateSessionAsync(
AIAgent agent,
string sessionId,
CancellationToken cancellationToken = default)
=> this.GetOrCreateSessionAsync(agent, new AgentSessionStoreKey(sessionId), cancellationToken);
#pragma warning restore RS0026

/// <summary>
/// Deletes a stored agent session, if present.
Expand All @@ -88,10 +159,31 @@ public virtual async ValueTask<AgentSession> GetOrCreateSessionAsync(
/// <remarks>
/// Implementations delete the session and treat a missing session as a no-op.
/// </remarks>
#pragma warning disable RS0026 // Overloaded by a sessionId-based convenience method.
public abstract ValueTask DeleteSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
CancellationToken cancellationToken = default);
#pragma warning restore RS0026

/// <summary>
/// Deletes a stored agent session identified by a session identifier without partitions, if present.
/// </summary>
/// <param name="agent">The agent that owns this session.</param>
/// <param name="sessionId">The logical session identifier.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
/// <returns>A task that represents the asynchronous delete operation.</returns>
/// <remarks>
/// This is a convenience overload that creates an <see cref="AgentSessionStoreKey"/> from
/// <paramref name="sessionId"/> and calls <see cref="DeleteSessionAsync(AIAgent, AgentSessionStoreKey, CancellationToken)"/>.
/// </remarks>
#pragma warning disable RS0026 // Convenience overload that mirrors the AgentSessionStoreKey-based method.
public ValueTask DeleteSessionAsync(
AIAgent agent,
string sessionId,
CancellationToken cancellationToken = default)
=> this.DeleteSessionAsync(agent, new AgentSessionStoreKey(sessionId), cancellationToken);
#pragma warning restore RS0026

/// <summary>Asks the store for an object of the specified type.</summary>
/// <param name="serviceType">The type of object being requested.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]virtual Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession?>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.AgentSessionStoreKey(string! sessionId, System.Collections.Generic.IReadOnlyDictionary<string!, string!>? partitions = null) -> void
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.Equals(Microsoft.Agents.AI.AgentSessionStoreKey? other) -> bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]virtual Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession?>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.AgentSessionStoreKey(string! sessionId, System.Collections.Generic.IReadOnlyDictionary<string!, string!>? partitions = null) -> void
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.Equals(Microsoft.Agents.AI.AgentSessionStoreKey? other) -> bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]virtual Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession?>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.AgentSessionStoreKey(string! sessionId, System.Collections.Generic.IReadOnlyDictionary<string!, string!>? partitions = null) -> void
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.Equals(Microsoft.Agents.AI.AgentSessionStoreKey? other) -> bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]abstract Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]virtual Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, Microsoft.Agents.AI.AgentSessionStoreKey! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession?>
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.SaveSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, Microsoft.Agents.AI.AgentSession! session, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.DeleteSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
[MAAI001]Microsoft.Agents.AI.AgentSessionStore.GetOrCreateSessionAsync(Microsoft.Agents.AI.AIAgent! agent, string! sessionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.Agents.AI.AgentSession!>
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.AgentSessionStoreKey(string! sessionId, System.Collections.Generic.IReadOnlyDictionary<string!, string!>? partitions = null) -> void
[MAAI001]Microsoft.Agents.AI.AgentSessionStoreKey.Equals(Microsoft.Agents.AI.AgentSessionStoreKey? other) -> bool
Expand Down
Loading
Loading