CompactionStrategy.CompactCoreAsync Method

Definition

Applies the strategy-specific compaction logic to the specified message index.

protected abstract System.Threading.Tasks.ValueTask<bool> CompactCoreAsync(Microsoft.Agents.AI.Compaction.CompactionMessageIndex index, Microsoft.Extensions.Logging.ILogger logger, System.Threading.CancellationToken cancellationToken);
abstract member CompactCoreAsync : Microsoft.Agents.AI.Compaction.CompactionMessageIndex * Microsoft.Extensions.Logging.ILogger * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<bool>
Protected MustOverride Function CompactCoreAsync (index As CompactionMessageIndex, logger As ILogger, cancellationToken As CancellationToken) As ValueTask(Of Boolean)

Parameters

index
CompactionMessageIndex

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

logger
ILogger

The ILogger for emitting compaction diagnostics.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests.

Returns

A task whose result is true if any compaction was performed, false otherwise.

Remarks

This method is called by CompactAsync(CompactionMessageIndex, ILogger, CancellationToken) only when the Trigger returns true. Implementations do not need to evaluate the trigger or report metrics — the base class handles both. Implementations should use Target to determine when to stop compacting incrementally.

Applies to