mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.NET: Add CreateSessionAsync overload with taskId for A2AAgent session resumption (#3924)
* Initial plan * Add CreateSessionAsync overload with contextId and taskId parameters Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com> * Update dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/A2AAgentTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add parameter validation to CreateSessionAsync methods Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com> * Inline parameter validation in CreateSessionAsync methods Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
westey-m
Copilot
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
parent
b68d0f93e3
commit
7ae4b7b537
@@ -63,7 +63,16 @@ public sealed class A2AAgent : AIAgent
|
||||
/// <param name="contextId">The context id to continue.</param>
|
||||
/// <returns>A value task representing the asynchronous operation. The task result contains a new <see cref="AgentSession"/> instance.</returns>
|
||||
public ValueTask<AgentSession> CreateSessionAsync(string contextId)
|
||||
=> new(new A2AAgentSession() { ContextId = contextId });
|
||||
=> new(new A2AAgentSession() { ContextId = Throw.IfNullOrWhitespace(contextId) });
|
||||
|
||||
/// <summary>
|
||||
/// Get a new <see cref="AgentSession"/> instance using an existing context id and task id, to resume that conversation from a specific task.
|
||||
/// </summary>
|
||||
/// <param name="contextId">The context id to continue.</param>
|
||||
/// <param name="taskId">The task id to resume from.</param>
|
||||
/// <returns>A value task representing the asynchronous operation. The task result contains a new <see cref="AgentSession"/> instance.</returns>
|
||||
public ValueTask<AgentSession> CreateSessionAsync(string contextId, string taskId)
|
||||
=> new(new A2AAgentSession() { ContextId = Throw.IfNullOrWhitespace(contextId), TaskId = Throw.IfNullOrWhitespace(taskId) });
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override ValueTask<JsonElement> SerializeSessionCoreAsync(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default)
|
||||
|
||||
Reference in New Issue
Block a user