-
Notifications
You must be signed in to change notification settings - Fork 4.7k
.Net: Add thread retrieval interface to enforce thread retrieval requirement for stateless agents. #11289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
westey-m
wants to merge
13
commits into
microsoft:main
from
westey-m:common-agent-api-threadretrieval
Closed
.Net: Add thread retrieval interface to enforce thread retrieval requirement for stateless agents. #11289
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1108901
Add thread retrieval interface to enforce thread retrieval requiremen…
westey-m 09f7375
Merge branch 'main' into common-agent-api-threadretrieval
westey-m c2caa71
Merge branch 'main' into common-agent-api-threadretrieval
westey-m c18325f
Merge commit.
westey-m d32245c
Merge branch 'main' into common-agent-api-threadretrieval
westey-m 406b400
Fully implement ResponseAgent local thread support and add integratio…
westey-m 16cc193
Remove duplicate experimental
westey-m ddd0775
Rename interface and update xml docs.
westey-m 6e803c1
Fix typo
westey-m 4adb9fa
Merge branch 'main' into common-agent-api-threadretrieval
westey-m 7a085ba
Merge branch 'main' into common-agent-api-threadretrieval
westey-m 1724716
Merge branch 'main' into common-agent-api-threadretrieval
westey-m 55a466a
Merge branch 'main' into common-agent-api-threadretrieval
westey-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
dotnet/src/Agents/Abstractions/IAgentThreadMessageProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Threading; | ||
|
|
||
| namespace Microsoft.SemanticKernel.Agents; | ||
|
|
||
| /// <summary> | ||
| /// Interface for any Semantic Kernel agent thread that allow the messages | ||
| /// contained in it to be passed to an agent. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// <see cref="AgentThread"/> types that implement this interface can | ||
| /// be used with Agents that do not maintain a server-side chat history, e.g. ChatCompletionAgent. | ||
| /// These agents are typically implemented using simple LLMs and therefore | ||
| /// require the entire chat history to be provided to the LLM for each invocation. | ||
| /// </para> | ||
| /// <para> | ||
| /// This is in contrast to agents that maintain a server-side chat history, e.g. AzureAIAgentThread, | ||
| /// where the chat history is stored on the server and managed by the agent service. | ||
| /// </para> | ||
| /// <para> | ||
| /// The set of messages returned may be truncated or processed | ||
| /// by the <see cref="AgentThread"/> as needed before passed to the | ||
| /// agent to achieve a scalable and performant solution. | ||
| /// </para> | ||
| /// <para> | ||
| /// This interface can be used to implement custom agent threads, that store messages | ||
| /// in a database or 3rd party service, instead of in-memory like done by ChatHistoryAgentThread. | ||
| /// </para> | ||
| /// </remarks> | ||
| [Experimental("SKEXP0110")] | ||
| public interface IAgentThreadMessageProvider | ||
| { | ||
| /// <summary> | ||
| /// Asynchronously retrieves all messages to be used for the agent invocation. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Messages are returned in ascending chronological order. | ||
| /// </remarks> | ||
| /// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
| /// <returns>The messages in the thread.</returns> | ||
| /// <exception cref="InvalidOperationException">The thread has been deleted.</exception> | ||
| IAsyncEnumerable<ChatMessageContent> GetMessagesAsync(CancellationToken cancellationToken = default); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.