Skip to content

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

Open
ilia-sokolov wants to merge 3 commits into
microsoft:mainfrom
ilia-sokolov:contrib/9580-chat-reducer-ttfc
Open

Report time to first content in chat reducer sample#14197
ilia-sokolov wants to merge 3 commits into
microsoft:mainfrom
ilia-sokolov:contrib/9580-chat-reducer-ttfc

Conversation

@ilia-sokolov

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 marked this pull request as ready for review July 28, 2026 06:25
@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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants