Skip to content

Usage: Hybrid Tasks and Messages support #275

@DeagleGross

Description

@DeagleGross

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v1.0.0Features for v1

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions