Skip to content

Conversation

@tracyboehrer
Copy link
Member

@tracyboehrer tracyboehrer commented Oct 17, 2025

Fixes #466

For discussion:

  • Instead of throwing from EndStreamAsync, which would introduce new and unexpected behavior, EndStream will return a result.
public enum StreamingResponseResult
{
    Success,
    NotStarted,
    AlreadyEnded,
    UserCancelled,
    Timeout,
    Error
};

@github-actions github-actions bot added ML: Core Tags changes to core libraries ML: Tests Tags changes to tests labels Oct 17, 2025
@tracyboehrer tracyboehrer marked this pull request as ready for review October 22, 2025 19:02
@tracyboehrer tracyboehrer requested a review from a team as a code owner October 22, 2025 19:02
Copilot AI review requested due to automatic review settings October 22, 2025 19:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR changes the EndStreamAsync method to return a StreamingResponseResult enum instead of throwing exceptions, providing callers with explicit feedback about the streaming operation outcome.

Key Changes:

  • Introduced StreamingResponseResult enum with values: Success, NotStarted, AlreadyEnded, UserCancelled, Timeout, and Error
  • Modified EndStreamAsync to return Task<StreamingResponseResult> instead of Task
  • Added comprehensive test coverage for various streaming scenarios including success, cancellation, fallback, and duplicate end calls

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
IStreamingResponse.cs Added StreamingResponseResult enum and updated EndStreamAsync signature to return result
StreamingResponse.cs Implemented result-based error handling in EndStreamAsync, added _userCanceled field, and improved error categorization logic
StreamingResponseTests.cs Added new test file with comprehensive coverage of streaming scenarios including success cases, user cancellation, fallback behavior, and duplicate calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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

Labels

HOLD ML: Core Tags changes to core libraries ML: Tests Tags changes to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

turncontext.StreamingResponse.EndStreamAsync() doesn't handle timeouts properly

2 participants