Report time to first content in chat reducer sample - #14197
Open
ilia-sokolov wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a latency metric to the .NET streaming chat-history reducer sample so users can see how long it takes before the first assistant text becomes available when chat-history reduction is enabled.
Changes:
- Start a per-turn
Stopwatchbefore initiating streaming and print elapsed time on the first non-empty text update. - Preserve existing response assembly and token usage aggregation while streaming.
- Add a fallback message for streams that produce no text content.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The streaming chat-history reducer sample reports aggregate token usage but gives no indication of the latency users experience before the first response content becomes available.
This change addresses #9580 by making that latency visible for the reducer-enabled streaming path. The label explicitly states that chat-history reduction is included, avoiding the misleading implication that the value represents provider-only latency.
Description
The change is confined to
MultipleProviders_ChatHistoryReducer.cs, introduces no dependencies or public APIs, and intentionally avoids timing thresholds because provider latency is nondeterministic.Validation
The exact modified sample source compiled successfully with 0 warnings and 0 errors against the released Semantic Kernel 1.78 packages.
The repository-wide Concepts build and formatter traverse a large connector project graph and did not complete in the available validation window. The modified Semantic Kernel API expressions are unchanged from
main; the added implementation uses onlySystem.Diagnostics.Stopwatchand local control flow.Contribution Checklist