Skip to content

Consider adding support to streaming to OnMessageReceived in TaskManager #159

@sucaritas

Description

@sucaritas

The issue comes from the fact that the SendMessageStreamingAsync method in TaskManager checks for OnMessageReceived, and if it is found, there is no way to support streaming.

if (OnMessageReceived != null)

Since receiving messages is one of the most common actions to override, this prevents people from either streaming or being able to receive messages, just so streaming can work.

Suggestions:

1.- Make the streaming be bases on the UpdateStatusAsync method. streaming should subscribe to events from the UpdateStatusAsync
2.- Add an OnMessageReceivedStreaming method that returns an IAsyncEnumerable.
3.- Add the TaskUpdateEventEnumerator object to the signature of OnMessageReceived, so that events can be pumped out as they are processed.

Pros & Cons

For #1
Pro: No major signature changes, just after creating the AgentTask imedeatly subscribe to it and pass along the enumerator.

For #2
pro: The implementation is semantically good
Con: The implementore will have to implement two methods to receive messages

For #3
Pro: The implementation is straight forward. Semantically it might be ok, not sure. i think i should as the non-streaminmg processing should be able to push notifications.

#1 Is the one i would prefer as it would allow me to use the UpdateStatusAsync naturally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions