Description
The recent change to AgentSessionStore replaced the methods that accepted a string conversation ID:
ValueTask<AgentSession> GetSessionAsync(
AIAgent agent,
string conversationId,
CancellationToken cancellationToken = default);
ValueTask SaveSessionAsync(
AIAgent agent,
string conversationId,
AgentSession session,
CancellationToken cancellationToken = default);
with methods that accept an AgentSessionStoreKey:
ValueTask<AgentSession?> GetSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
CancellationToken cancellationToken = default);
ValueTask SaveSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
AgentSession session,
CancellationToken cancellationToken = default);
AgentSessionStoreKey enables useful scenarios such as partitioning and session isolation. However, applications that only need a session ID must now update every call site to explicitly create a key:
await sessionStore.GetSessionAsync(
agent,
new AgentSessionStoreKey(sessionId),
cancellationToken);
await sessionStore.SaveSessionAsync(
agent,
new AgentSessionStoreKey(sessionId),
session,
cancellationToken);
To preserve the simpler API for the common case and reduce the migration work caused by this signature change, AgentSessionStore could provide convenience overloads that accept a string sessionId. These overloads would create an AgentSessionStoreKey and delegate to the primary methods.
This would retain AgentSessionStoreKey as the extensible API while allowing existing call sites that do not require partitions to remain concise.
Code Sample
A possible implementation in AgentSessionStore would be:
public ValueTask<AgentSession?> GetSessionAsync(
AIAgent agent,
string sessionId,
CancellationToken cancellationToken = default)
{
return GetSessionAsync(agent, new(sessionId), cancellationToken);
}
public ValueTask SaveSessionAsync(
AIAgent agent,
string sessionId,
AgentSession session,
CancellationToken cancellationToken = default)
{
return SaveSessionAsync(agent, new(sessionId), session, cancellationToken);
}
The overloads should be concrete forwarding methods rather than additional abstract members. Implementations of `AgentSessionStore` would therefore continue to implement only the `AgentSessionStoreKey`-based methods:
public override ValueTask<AgentSession?> GetSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
CancellationToken cancellationToken = default);
public override ValueTask SaveSessionAsync(
AIAgent agent,
AgentSessionStoreKey key,
AgentSession session,
CancellationToken cancellationToken = default);
Consumers that only have a session ID could continue to use the simpler form:
AgentSession? session = await sessionStore.GetSessionAsync(
agent,
sessionId,
cancellationToken);
await sessionStore.SaveSessionAsync(
agent,
sessionId,
session,
cancellationToken);
The proposed overloads would:
- reduce source changes when migrating from the previous API;
- preserve a concise API for applications that only need a session ID;
- avoid requiring every consumer to repeat
new AgentSessionStoreKey(sessionId);
- keep the
AgentSessionStoreKey overloads as the canonical implementation path;
- preserve support for partitions and isolation when callers need those capabilities.
Language/SDK
.NET
Description
The recent change to
AgentSessionStorereplaced the methods that accepted a string conversation ID:with methods that accept an
AgentSessionStoreKey:AgentSessionStoreKeyenables useful scenarios such as partitioning and session isolation. However, applications that only need a session ID must now update every call site to explicitly create a key:To preserve the simpler API for the common case and reduce the migration work caused by this signature change,
AgentSessionStorecould provide convenience overloads that accept astring sessionId. These overloads would create anAgentSessionStoreKeyand delegate to the primary methods.This would retain
AgentSessionStoreKeyas the extensible API while allowing existing call sites that do not require partitions to remain concise.Code Sample
A possible implementation in
AgentSessionStorewould be:The proposed overloads would:
new AgentSessionStoreKey(sessionId);AgentSessionStoreKeyoverloads as the canonical implementation path;Language/SDK
.NET