CompactionProvider.CompactAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Applies compaction strategy to the provided message list and returns the compacted messages. This can be used for ad-hoc compaction outside of the provider pipeline.
public static System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>> CompactAsync(Microsoft.Agents.AI.Compaction.CompactionStrategy compactionStrategy, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, Microsoft.Extensions.Logging.ILogger? logger = default, System.Threading.CancellationToken cancellationToken = default);
static member CompactAsync : Microsoft.Agents.AI.Compaction.CompactionStrategy * seq<Microsoft.Extensions.AI.ChatMessage> * Microsoft.Extensions.Logging.ILogger * System.Threading.CancellationToken -> System.Threading.Tasks.Task<seq<Microsoft.Extensions.AI.ChatMessage>>
Public Shared Function CompactAsync (compactionStrategy As CompactionStrategy, messages As IEnumerable(Of ChatMessage), Optional logger As ILogger = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IEnumerable(Of ChatMessage))
Parameters
- compactionStrategy
- CompactionStrategy
The compaction strategy to apply before each invocation.
- messages
- IEnumerable<ChatMessage>
The messages to compact
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests.
Returns
An enumeration of the compacted ChatMessage instances.