.NET: Clarify compaction provider and chat reducer choices - #7678
Draft
Ravi Kiran Pagidi (ravikiranpagidi) wants to merge 1 commit into
Draft
.NET: Clarify compaction provider and chat reducer choices#7678Ravi Kiran Pagidi (ravikiranpagidi) wants to merge 1 commit into
Ravi Kiran Pagidi (ravikiranpagidi) wants to merge 1 commit into
Conversation
Ravi Kiran Pagidi (ravikiranpagidi)
deployed
to
github-app-auth
August 15, 2026 14:31 — with
GitHub Actions
Active
Ravi Kiran Pagidi (ravikiranpagidi)
deployed
to
github-app-auth
August 15, 2026 14:31 — with
GitHub Actions
Active
Ravi Kiran Pagidi (ravikiranpagidi)
deployed
to
github-app-auth
August 15, 2026 14:31 — with
GitHub Actions
Active
Ravi Kiran Pagidi (ravikiranpagidi)
deployed
to
github-app-auth
August 15, 2026 14:32 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Step 18 compaction pipeline documentation to clarify where to apply compaction vs. reduction, and refreshes the sample index entry to match the expanded guidance.
Changes:
- Expanded Step 18 README with a comparison of
CompactionProvidervsIChatReducer, including adapter examples and guidance. - Updated the Agents sample index description for the compaction pipeline step to reflect the new guidance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotnet/samples/02-agents/Agents/README.md | Updates the Step 18 row description to mention provider vs reducer integration. |
| dotnet/samples/02-agents/Agents/Agent_Step18_CompactionPipeline/README.md | Adds detailed guidance, a comparison table, and adapter examples for compaction vs reduction. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+21
to
+25
| | Choose | When you need | Effect on stored history | Function-calling loop | | ||
| |---|---|---|---| | ||
| | `CompactionProvider` on `ChatClientBuilder.UseAIContextProviders(...)` | Request-context management that preserves the original conversation | The compacted view is forwarded to the inner chat client; the source history remains unchanged | Runs for each inner chat-client call, including calls made while tools are being invoked | | ||
| | `CompactionProvider` in `ChatClientAgentOptions.AIContextProviders` | Agent-specific compaction without decorating a shared chat client | Runs before chat history is stored, so generated replacement messages can become part of the persisted history | Runs at the agent boundary, not for each call inside the tool loop | | ||
| | `IChatReducer` in `InMemoryChatHistoryProviderOptions.ChatReducer` | Storage management where the reduced list should replace the session's in-memory history | Permanently replaces the provider's stored message list with the reducer output | Runs at the configured history-provider event, not for each call inside the tool loop | |
Comment on lines
+46
to
+50
| InMemoryChatHistoryProvider historyProvider = new(new() | ||
| { | ||
| ChatReducer = strategy.AsChatReducer(), | ||
| ReducerTriggerEvent = InMemoryChatHistoryProviderOptions.ChatReducerTriggerEvent.BeforeMessagesRetrieval | ||
| }); |
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 & Context
CompactionProviderand Microsoft.Extensions.AI'sIChatReducercan both reduce the messages supplied to a model, but they run at different lifecycle points and have different persistence behavior. The existing compaction sample did not give users a clear way to choose between them or explain the two adapters, which led to confusion about whether they should be composed together.This documentation makes that decision explicit and addresses #4608 without changing runtime behavior or public API.
Description & Review Guide
CompactionProviderregistration withIChatReduceronInMemoryChatHistoryProvider; document reducer trigger events; show each supported adapter direction; and update the sample index so the guidance is discoverable.Related Issue
Fixes #4608
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after a language prefix such as.NET:) — workflows keep the label and title prefix in sync automatically.