mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Add CreateSessionAsync(conversationId) to FoundryAgent (#5144)
Adds a public CreateSessionAsync(string conversationId, CancellationToken) method to FoundryAgent that delegates to the inner ChatClientAgent, allowing users to create sessions with existing server-side conversation IDs. Fixes #5138
This commit is contained in:
@@ -109,6 +109,27 @@ public sealed class FoundryAgent : DelegatingAIAgent
|
||||
|
||||
#region Convenience methods
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new agent session instance using an existing conversation identifier to continue that conversation.
|
||||
/// </summary>
|
||||
/// <param name="conversationId">The identifier of an existing conversation to continue.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests.</param>
|
||||
/// <returns>
|
||||
/// A value task representing the asynchronous operation. The task result contains a new <see cref="AgentSession"/> instance configured to work with the specified conversation.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method creates an <see cref="AgentSession"/> that relies on server-side chat history storage, where the chat history
|
||||
/// is maintained by the underlying AI service rather than by a local <see cref="ChatHistoryProvider"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Agent sessions created with this method will only work with <see cref="FoundryAgent"/>
|
||||
/// instances that support server-side conversation storage through their underlying <see cref="IChatClient"/>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public ValueTask<AgentSession> CreateSessionAsync(string conversationId, CancellationToken cancellationToken = default)
|
||||
=> ((ChatClientAgent)this.InnerAgent).CreateSessionAsync(conversationId, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a server-side conversation session that appears in the Foundry Project UI.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user