-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Problem Statement
The question raises when trying to configure ITaskManager against my own agent implementation. I have an ability to set 4 different callbacks:
taskManager.OnMessageReceived = ...;
taskManager.OnTaskCreated = ...;
taskManager.OnTaskCancelled = ...;
taskManager.OnTaskUpdated = ...;
but A2A SDK implementation will prioritize calling OnMessageReceived, if assigned:
a2a-dotnet/src/A2A/Server/TaskManager.cs
Lines 174 to 179 in a053349
| if (OnMessageReceived != null) | |
| { | |
| using var createActivity = ActivitySource.StartActivity("OnMessageReceived", ActivityKind.Server); | |
| return await OnMessageReceived(messageSendParams, cancellationToken).ConfigureAwait(false); | |
| } | |
| else |
Usage question
Note: I want to support a generic case of my agent being able to respond with both a Task and a Message depending on the invocation (for example input message).
The question is what callbacks should I assign? OnMessageReceived has a signature to return A2AResponse which may be both a AgentTask and AgentMessage. Does that mean that I should assign OnMessageReceived always, and assigning OnTaskCreated will not have any effect? I still need to assign OnTaskCancelled and OnTaskUpdated to support cancelling and updating tasks, right?
Proposition
I am suggesting to either document this, or ideally even throw an exception for assigning OnTaskCreated if OnMessageReceived is already populated, because it will never be called anyway. We can think of other ways to report this API details to the user as well.
Please let me know if I am just incorrect in understanding the inner implementation.