Skip to content

Support multiple response streams within a message handler #489

Description

@rkukura

Bug Description

If a message handler needs to stream part of the response, then show an AdaptiveCard, then stream more of the response, there is no supported SDK API to manage stream lifecycle when interleaving content types. Calling ctx.stream.close() and then ctx._activity_sender.create_stream(ctx.conversation_ref) to create a new stream works, but requires accessing the private _activity_sender property of ctx. A public method on ctx to create a new stream would avoid the need to access the private property.

Steps to Reproduce

No error, but code potentially breaks if private details of the SDK change in a future version.

Expected Behavior

A public API such as ctx.new_stream() would close the old stream if it hasn't already been closed and open a new stream.

Actual Behavior

Application must call ctx._activity_sender.create_stream(ctx.conversation_ref) which involves accessing a private property.

SDK Version

2.0.12

Python Version

3.12.12

Additional Context

This pattern is essential for conversational AI workflows where a bot needs to display structured data (e.g., an AdaptiveCard) to confirm a user selection or approve usage of a tool while streaming a long-form text response.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions