Skip to content

.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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

westey-m
Copy link
Contributor

Motivation and Context

We need to have a standard way to retrieve chat history from a thread for agents that require
chat history at invocation time. This also allows these agents to check that the thread is
compatible before processing.

Description

  • Add an interface to decorate compatible threads with.
  • Update ChatHistoryAgentThread to implement the new interface.
  • Update ChatCompletionAgent to use the new interface

Contribution Checklist

@westey-m westey-m requested a review from a team as a code owner March 31, 2025 16:37
@markwallace-microsoft markwallace-microsoft added the .NET Issue or Pull requests regarding .NET code label Mar 31, 2025
@github-actions github-actions bot changed the title Add thread retrieval interface to enforce thread retrieval requirement for stateless agents. .Net: Add thread retrieval interface to enforce thread retrieval requirement for stateless agents. Mar 31, 2025
/// </para>
/// </remarks>
[Experimental("SKEXP0110")]
public interface IAgentThreadRetrievable

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps IAgentContextProvider

@@ -266,20 +266,22 @@ public abstract IAsyncEnumerable<AgentResponseItem<StreamingChatMessageContent>>

private ILogger? _logger;

#pragma warning disable SKEXP0110 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically if our existing non-experimental API's have dependency on experimental behavior those should be experimental as well, unless we have a dedicated PR that uses the new experimental behavior marked as Experimental as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior here isn't experimental as such, it's really only the thread interface. E.g. the ChatHistoryAgentThread already supports retrieving messages without the new interface. However, where folks are building their own threads, and use the new interface, that's where it should show up as experimental, because using that interface on their own thread as well as all usage of that thread is then experimental.

@westey-m
Copy link
Contributor Author

westey-m commented Apr 2, 2025

Parking this until after GA

@westey-m westey-m closed this Apr 2, 2025
@westey-m westey-m reopened this May 7, 2025
@moonbox3 moonbox3 added the kernel Issues or pull requests impacting the core kernel label Jul 17, 2025
/// <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>
[Experimental("SKEXP0110")]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Experimental at the interface level should be sufficient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants