// Copyright (c) Microsoft. All rights reserved. using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Agents.AI.Compaction; using Microsoft.Extensions.AI; namespace Microsoft.Agents.AI.Abstractions.UnitTests.Compaction.Internal; internal sealed class RemoveFirstMessageStrategy : ChatHistoryCompactionStrategy { public RemoveFirstMessageStrategy() : base(new RemoveFirstReducer()) { } public override string Name => "RemoveFirst"; protected override bool ShouldCompact(ChatHistoryMetric metrics) => metrics.MessageCount > 0; private sealed class RemoveFirstReducer : IChatReducer { public Task> ReduceAsync(IEnumerable messages, CancellationToken cancellationToken = default) { List list = messages.ToList(); if (list.Count > 1) { list.RemoveAt(0); } return Task.FromResult>(list); } } }