diff --git a/dotnet/src/Microsoft.Agents.Abstractions/IMessagesRetrievableThread.cs b/dotnet/src/Microsoft.Agents.Abstractions/IMessagesRetrievableThread.cs new file mode 100644 index 0000000000..ed0688794c --- /dev/null +++ b/dotnet/src/Microsoft.Agents.Abstractions/IMessagesRetrievableThread.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System; +using System.Collections.Generic; +using System.Threading; +using Microsoft.Extensions.AI; + +namespace Microsoft.Agents; + +/// +/// An interface for agent threads that allow retrieval of messages in the thread for agent invocation. +/// +/// +/// +/// Some agents need to be invoked with all relevant chat history messages in order to produce a result, while some must be invoked +/// with the id of a server side thread that contains the chat history. +/// +/// +/// This interface can be implemented by all thread types that support the case where the agent is invoked with the chat history. +/// Implementations must consider the size of the messages provided, so that they do not exceed the maximum size of the context window +/// of the agent they are used with. Where appropriate, implementations should truncate or summarize messages so that the size of messages +/// are constrained. +/// +/// +public interface IMessagesRetrievableThread +{ + /// + /// Asynchronously retrieves all messages to be used for the agent invocation. + /// + /// + /// Messages are returned in ascending chronological order. + /// + /// The to monitor for cancellation requests. The default is . + /// The messages in the thread. + /// The thread has been deleted. + IAsyncEnumerable GetMessagesAsync(CancellationToken cancellationToken = default); +}