Skip to content

[Feat]: Send Streaming Message returns Task or Message as an initial response #965

Closed

Description

@sokoliva

Is your feature request related to a problem? Please describe.

Send Streaming Message
Stream Response object containing:
Initial response: Task object OR Message object

Currently this is not enforced:
While modifying hello_world client sample to expect Task or Message object as an initial response

async def _handle_stream(
    stream: Any, current_task_id: str | None
) -> str | None:
    async for event in stream:
        print(event)
        if event.HasField('message'):
            print(f'Message: {get_message_text(event.message, delimiter=" ")}')
            continue
        if not current_task_id:
            if not event.HasField('task'):
                raise RuntimeError(
                    'Expected first streaming event to be a Task or Message, '
                )
            current_task_id = event.task.id
            print(f'Task created with id: {current_task_id}')
        if not current_task_id:
            current_task_id = event.task.id

it returned an error:
Expected first streaming event to be a Task or Message.

Describe the solution you'd like

Enforce first streaming event to be Task or Message object by modifying on_message_send_stream method in DefaultRequestHandlerV2. It should check if the current event is the first event and construct a new_task if it is not neither Task nor Message.

Describe alternatives you've considered

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. self-assigned this
    on Apr 13, 2026
  2. added theissue type on Apr 13, 2026
  3. changed the title [-][Feat]: Send Streaming Message returns `Task` or Message` as an initial response[/-] [+][Feat]: Send Streaming Message returns `Task` or `Message` as an initial response[/+] on Apr 13, 2026
  4. ishymko commented on Apr 20, 2026

    @ishymko
    Member

    Fixed by #979.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions