Skip to content

Commit 578dcfa

Browse files
Copilotbrandonh-msftadamsitnik
authored
chore: Rename SendMessageStreamAsync method to SendMessageStreamingAsync (#127)
* Initial plan * Rename SendMessageStreamAsync method to SendMessageStreamingAsync Co-authored-by: brandonh-msft <20270743+brandonh-msft@users.noreply.github.com> * Fix merge conflicts and compilation errors - Resolved merge conflicts in TaskManagerTests.cs preserving both helper methods and renamed method - Fixed nullable reference warnings in TaskManager.cs - Updated all SendMessageStreamAsync calls to SendMessageStreamingAsync - All 249 tests passing Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: brandonh-msft <20270743+brandonh-msft@users.noreply.github.com> Co-authored-by: Brandon H <brandonh-msft@users.noreply.github.com> Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com> Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
1 parent 7c25208 commit 578dcfa

File tree

10 files changed

+152
-152
lines changed

10 files changed

+152
-152
lines changed

samples/A2ACli/Host/A2ACli.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private static async Task<bool> CompleteTaskAsync(
252252
Console.WriteLine($"Send task payload => {JsonSerializer.Serialize(payload, jsonOptions)}");
253253
if (streaming)
254254
{
255-
await foreach (var result in client.SendMessageStreamAsync(payload, cancellationToken))
255+
await foreach (var result in client.SendMessageStreamingAsync(payload, cancellationToken))
256256
{
257257
Console.WriteLine($"Stream event => {JsonSerializer.Serialize(result, jsonOptions)}");
258258
}

samples/AgentClient/Samples/MessageBasedCommunicationSample.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static async Task RunAsync()
7676
await SendMessageAsync(agentClient, userMessage);
7777

7878
// 5. Send the message using streaming API
79-
await SendMessageStreamAsync(agentClient, userMessage);
79+
await SendMessageStreamingAsync(agentClient, userMessage);
8080
}
8181

8282
/// <summary>
@@ -100,13 +100,13 @@ private static async Task SendMessageAsync(A2AClient agentClient, Message userMe
100100
/// <param name="agentClient">The A2A client for communicating with the agent.</param>
101101
/// <param name="userMessage">The message to send to the agent.</param>
102102
/// <returns>A task representing the asynchronous operation.</returns>
103-
private static async Task SendMessageStreamAsync(A2AClient agentClient, Message userMessage)
103+
private static async Task SendMessageStreamingAsync(A2AClient agentClient, Message userMessage)
104104
{
105105
Console.WriteLine("\nStreaming Message Communication");
106106
Console.WriteLine($" Sending message via streaming API: {((TextPart)userMessage.Parts[0]).Text}");
107107

108108
// Send the message and get the response as a stream
109-
await foreach (SseItem<A2AEvent> sseItem in agentClient.SendMessageStreamAsync(new MessageSendParams { Message = userMessage }))
109+
await foreach (SseItem<A2AEvent> sseItem in agentClient.SendMessageStreamingAsync(new MessageSendParams { Message = userMessage }))
110110
{
111111
Message agentResponse = (Message)sseItem.Data;
112112

src/A2A.AspNetCore/A2AHttpProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ internal static Task<IResult> SendMessageAsync(ITaskManager taskManager, ILogger
129129
internal static IResult SendMessageStream(ITaskManager taskManager, ILogger logger, MessageSendParams sendParams, CancellationToken cancellationToken)
130130
=> WithExceptionHandling(logger, "SendMessageStream", () =>
131131
{
132-
var taskEvents = taskManager.SendMessageStreamAsync(sendParams, cancellationToken);
132+
var taskEvents = taskManager.SendMessageStreamingAsync(sendParams, cancellationToken);
133133

134134
return new A2AEventStreamResult(taskEvents);
135135
}, sendParams.Message.TaskId);

src/A2A.AspNetCore/A2AJsonRpcProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ internal static IResult StreamResponse(ITaskManager taskManager, string? request
184184
return new JsonRpcStreamedResult(taskEvents, requestId);
185185
case A2AMethods.MessageStream:
186186
var taskSendParams = DeserializeAndValidate<MessageSendParams>(parameters.Value);
187-
var sendEvents = taskManager.SendMessageStreamAsync(taskSendParams, cancellationToken);
187+
var sendEvents = taskManager.SendMessageStreamingAsync(taskSendParams, cancellationToken);
188188
return new JsonRpcStreamedResult(sendEvents, requestId);
189189
default:
190190
activity?.SetStatus(ActivityStatusCode.Error, "Invalid method");

src/A2A/Client/A2AClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Task<TaskPushNotificationConfig> GetPushNotificationAsync(GetTaskPushNoti
7777
cancellationToken);
7878

7979
/// <inheritdoc />
80-
public IAsyncEnumerable<SseItem<A2AEvent>> SendMessageStreamAsync(MessageSendParams taskSendParams, CancellationToken cancellationToken = default) =>
80+
public IAsyncEnumerable<SseItem<A2AEvent>> SendMessageStreamingAsync(MessageSendParams taskSendParams, CancellationToken cancellationToken = default) =>
8181
SendRpcSseRequestAsync(
8282
taskSendParams ?? throw new ArgumentNullException(nameof(taskSendParams)),
8383
A2AMethods.MessageStream,

src/A2A/Client/IA2AClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public interface IA2AClient
4040
/// <param name="taskSendParams">The message parameters containing the message and configuration.</param>
4141
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
4242
/// <returns>An async enumerable of server-sent events containing Task, Message, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent.</returns>
43-
IAsyncEnumerable<SseItem<A2AEvent>> SendMessageStreamAsync(MessageSendParams taskSendParams, CancellationToken cancellationToken = default);
43+
IAsyncEnumerable<SseItem<A2AEvent>> SendMessageStreamingAsync(MessageSendParams taskSendParams, CancellationToken cancellationToken = default);
4444

4545
/// <summary>
4646
/// Subscribes to a task's event stream to receive ongoing updates.

src/A2A/Server/ITaskManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public interface ITaskManager
141141
/// <param name="messageSendParams">The message parameters containing the message content and optional task/context IDs.</param>
142142
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
143143
/// <returns>An async enumerable that yields events as they are produced by the agent.</returns>
144-
IAsyncEnumerable<A2AEvent> SendMessageStreamAsync(MessageSendParams messageSendParams, CancellationToken cancellationToken = default);
144+
IAsyncEnumerable<A2AEvent> SendMessageStreamingAsync(MessageSendParams messageSendParams, CancellationToken cancellationToken = default);
145145

146146
/// <summary>
147147
/// Resubscribes to an existing task's event stream to receive ongoing updates.

src/A2A/Server/TaskManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public async Task<AgentTask> CreateTaskAsync(string? contextId = null, string? t
207207
}
208208

209209
/// <inheritdoc />
210-
public async IAsyncEnumerable<A2AEvent> SendMessageStreamAsync(MessageSendParams messageSendParams, [EnumeratorCancellation] CancellationToken cancellationToken = default)
210+
public async IAsyncEnumerable<A2AEvent> SendMessageStreamingAsync(MessageSendParams messageSendParams, [EnumeratorCancellation] CancellationToken cancellationToken = default)
211211
{
212212
cancellationToken.ThrowIfCancellationRequested();
213213

tests/A2A.UnitTests/Client/A2AClientTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public async Task GetPushNotificationAsync_WithPushNotificationConfigId_MapsRequ
398398
}
399399

400400
[Fact]
401-
public async Task SendMessageStreamAsync_MapsRequestParamsCorrectly()
401+
public async Task SendMessageStreamingAsync_MapsRequestParamsCorrectly()
402402
{
403403
// Arrange
404404
HttpRequestMessage? capturedRequest = null;
@@ -428,7 +428,7 @@ public async Task SendMessageStreamAsync_MapsRequestParamsCorrectly()
428428
};
429429

430430
// Act
431-
await foreach (var _ in sut.SendMessageStreamAsync(sendParams))
431+
await foreach (var _ in sut.SendMessageStreamingAsync(sendParams))
432432
{
433433
break; // Only need to trigger the request
434434
}
@@ -459,7 +459,7 @@ public async Task SendMessageStreamAsync_MapsRequestParamsCorrectly()
459459
}
460460

461461
[Fact]
462-
public async Task SendMessageStreamAsync_MapsResponseCorrectly()
462+
public async Task SendMessageStreamingAsync_MapsResponseCorrectly()
463463
{
464464
// Arrange
465465
var expectedMessage = new Message
@@ -483,7 +483,7 @@ public async Task SendMessageStreamAsync_MapsResponseCorrectly()
483483

484484
// Act
485485
SseItem<A2AEvent>? result = null;
486-
await foreach (var item in sut.SendMessageStreamAsync(sendParams))
486+
await foreach (var item in sut.SendMessageStreamingAsync(sendParams))
487487
{
488488
result = item;
489489
break;
@@ -579,7 +579,7 @@ public async Task SubscribeToTaskAsync_MapsResponseCorrectly()
579579
}
580580

581581
[Fact]
582-
public async Task SendMessageStreamAsync_ThrowsOnJsonRpcError()
582+
public async Task SendMessageStreamingAsync_ThrowsOnJsonRpcError()
583583
{
584584
// Arrange
585585
var sut = CreateA2AClient(JsonRpcResponse.InvalidParamsResponse("test-id"), isSse: true);
@@ -589,7 +589,7 @@ public async Task SendMessageStreamAsync_ThrowsOnJsonRpcError()
589589
// Act & Assert
590590
var exception = await Assert.ThrowsAsync<A2AException>(async () =>
591591
{
592-
await foreach (var _ in sut.SendMessageStreamAsync(sendParams))
592+
await foreach (var _ in sut.SendMessageStreamingAsync(sendParams))
593593
{
594594
// Should throw before yielding any items
595595
}

0 commit comments

Comments
 (0)