Skip to content

.Net: Report time to first content in chat reducer sample - #14197

Open
Ilia Sokolov (ilia-sokolov) wants to merge 7 commits into
microsoft:mainfrom
ilia-sokolov:contrib/9580-chat-reducer-ttfc
Open

Ilia Sokolov (ilia-sokolov) wants to merge 7 commits into
microsoft:mainfrom
ilia-sokolov:contrib/9580-chat-reducer-ttfc

Conversation

@ilia-sokolov

@ilia-sokolov Ilia Sokolov (ilia-sokolov) commented Jul 26, 2026 •

Copy link
Copy Markdown

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

  • start a per-turn stopwatch immediately before requesting the streaming response
  • stop and report it once, on the first non-empty textual update
  • preserve the existing response assembly and token accounting
  • report a truthful fallback when a stream returns no text, such as a metadata-only or tool-only stream

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 only System.Diagnostics.Stopwatch and local control flow.

Contribution Checklist

  • The complete repository build finishes without any errors or warnings
  • The repository-wide pre-submission formatting script raises no violations
  • All repository unit tests pass
  • The focused sample change compiles cleanly and preserves existing behavior
  • I didn't break anyone 😄

@ilia-sokolov
Ilia Sokolov (ilia-sokolov) marked this pull request as ready for review July 28, 2026 06:25
@ilia-sokolov
Ilia Sokolov (ilia-sokolov) requested a review from a team as a code owner July 28, 2026 06:25
Copilot AI review requested due to automatic review settings July 28, 2026 06:25

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 5 | Confidence: 92% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by ilia-sokolov's agents

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Stopwatch before 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.

@semantic-kernel-automation semantic-kernel-automation Bot added the .NET Issue or Pull requests regarding .NET code label Oct 29, 2026
@github-actions github-actions Bot changed the title Report time to first content in chat reducer sample .Net: Report time to first content in chat reducer sample Oct 29, 2026
@ilia-sokolov

Copy link
Copy Markdown
Author

Hi @microsoft/octo-semantickernel-pr-dotnet, could someone review this focused .NET sample change when you have a chance? It addresses #9580 by reporting reducer-inclusive time to first non-empty text, and reports stream-completion time separately for textless responses. The earlier Copilot feedback has been addressed. Please let me know whether this is still the desired scope or if any adjustments or additional validation would help. Thanks!

This branch was successfully deployed

1 active deployment
github-app-auth — 14c5b757 Deployed Oct 29, 2026 by ilia-sokolov via add_label #29483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants