CompactionStrategy.CompactAsync Method

Definition

Evaluates the Trigger and, when it fires, delegates to CompactCoreAsync(CompactionMessageIndex, ILogger, CancellationToken) and reports compaction metrics.

public System.Threading.Tasks.ValueTask<bool> CompactAsync(Microsoft.Agents.AI.Compaction.CompactionMessageIndex index, Microsoft.Extensions.Logging.ILogger? logger = default, System.Threading.CancellationToken cancellationToken = default);
member this.CompactAsync : Microsoft.Agents.AI.Compaction.CompactionMessageIndex * Microsoft.Extensions.Logging.ILogger * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<bool>
Public Function CompactAsync (index As CompactionMessageIndex, Optional logger As ILogger = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Boolean)

Parameters

index
CompactionMessageIndex

The message index to compact. The strategy mutates this collection in place.

logger
ILogger

An optional ILogger for emitting compaction diagnostics. When null, logging is disabled.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests.

Returns

A task representing the asynchronous operation. The task result is true if compaction occurred, false otherwise.

Applies to