Skip to content

Commit df149af

Browse files
authored
Merge branch 'main' into hombin/issue-3364
2 parents 11fc522 + 330c260 commit df149af

220 files changed

Lines changed: 14264 additions & 7183 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Here are some general guidelines that apply to all code.
1414

1515
- The top of all *.cs files should have a copyright notice: `// Copyright (c) Microsoft. All rights reserved.`
1616
- All public methods and classes should have XML documentation comments.
17+
- After adding, modifying or deleting code, run `dotnet build`, and then fix any reported build errors.
18+
- After adding or modifying code, run `dotnet format` to automatically fix any formatting errors.
1719

1820
### C# Sample Code Guidelines
1921

File renamed without changes.

docs/decisions/0012-python-get-response-simplification.md renamed to docs/decisions/0013-python-get-response-simplification.md

File renamed without changes.

docs/decisions/0014-feature-collections.md

Lines changed: 423 additions & 0 deletions
Large diffs are not rendered by default.

dotnet/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
<!-- Symbols -->
144144
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
145145
<!-- Toolset -->
146+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
146147
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
147148
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.100" />
148149
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">

dotnet/agent-framework-dotnet.slnx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@
299299
<File Path="../docs/decisions/0007-agent-filtering-middleware.md" />
300300
<File Path="../docs/decisions/0008-python-subpackages.md" />
301301
<File Path="../docs/decisions/0009-support-long-running-operations.md" />
302+
<File Path="../docs/decisions/0010-ag-ui-support.md" />
303+
<File Path="../docs/decisions/0011-create-get-agent-api.md" />
304+
<File Path="../docs/decisions/0012-python-typeddict-options.md" />
305+
<File Path="../docs/decisions/0013-python-get-response-simplification.md" />
306+
<File Path="../docs/decisions/0014-feature-collections.md" />
302307
<File Path="../docs/decisions/adr-short-template.md" />
303308
<File Path="../docs/decisions/adr-template.md" />
304309
<File Path="../docs/decisions/README.md" />
@@ -409,6 +414,7 @@
409414
<Project Path="src/Microsoft.Agents.AI.Workflows.Declarative.AzureAI/Microsoft.Agents.AI.Workflows.Declarative.AzureAI.csproj" />
410415
<Project Path="src/Microsoft.Agents.AI.Workflows.Declarative/Microsoft.Agents.AI.Workflows.Declarative.csproj" />
411416
<Project Path="src/Microsoft.Agents.AI.Workflows/Microsoft.Agents.AI.Workflows.csproj" />
417+
<Project Path="src/Microsoft.Agents.AI.Workflows.Generators/Microsoft.Agents.AI.Workflows.Generators.csproj" />
412418
<Project Path="src/Microsoft.Agents.AI/Microsoft.Agents.AI.csproj" />
413419
</Folder>
414420
<Folder Name="/Tests/" />
@@ -448,6 +454,7 @@
448454
<Project Path="tests/Microsoft.Agents.AI.Purview.UnitTests/Microsoft.Agents.AI.Purview.UnitTests.csproj" />
449455
<Project Path="tests/Microsoft.Agents.AI.UnitTests/Microsoft.Agents.AI.UnitTests.csproj" />
450456
<Project Path="tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj" />
457+
<Project Path="tests/Microsoft.Agents.AI.Workflows.Generators.UnitTests/Microsoft.Agents.AI.Workflows.Generators.UnitTests.csproj" />
451458
<Project Path="tests/Microsoft.Agents.AI.Workflows.UnitTests/Microsoft.Agents.AI.Workflows.UnitTests.csproj" />
452459
</Folder>
453460
</Solution>

dotnet/samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Program.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ protected override async Task<AgentResponse> RunCoreAsync(IEnumerable<ChatMessag
4545
}
4646

4747
// Get existing messages from the store
48-
var invokingContext = new ChatMessageStore.InvokingContext(messages);
49-
var storeMessages = await typedThread.MessageStore.InvokingAsync(invokingContext, cancellationToken);
48+
var invokingContext = new ChatHistoryProvider.InvokingContext(messages);
49+
var storeMessages = await typedThread.ChatHistoryProvider.InvokingAsync(invokingContext, cancellationToken);
5050

5151
// Clone the input messages and turn them into response messages with upper case text.
5252
List<ChatMessage> responseMessages = CloneAndToUpperCase(messages, this.Name).ToList();
5353

5454
// Notify the thread of the input and output messages.
55-
var invokedContext = new ChatMessageStore.InvokedContext(messages, storeMessages)
55+
var invokedContext = new ChatHistoryProvider.InvokedContext(messages, storeMessages)
5656
{
5757
ResponseMessages = responseMessages
5858
};
59-
await typedThread.MessageStore.InvokedAsync(invokedContext, cancellationToken);
59+
await typedThread.ChatHistoryProvider.InvokedAsync(invokedContext, cancellationToken);
6060

6161
return new AgentResponse
6262
{
@@ -77,18 +77,18 @@ protected override async IAsyncEnumerable<AgentResponseUpdate> RunCoreStreamingA
7777
}
7878

7979
// Get existing messages from the store
80-
var invokingContext = new ChatMessageStore.InvokingContext(messages);
81-
var storeMessages = await typedThread.MessageStore.InvokingAsync(invokingContext, cancellationToken);
80+
var invokingContext = new ChatHistoryProvider.InvokingContext(messages);
81+
var storeMessages = await typedThread.ChatHistoryProvider.InvokingAsync(invokingContext, cancellationToken);
8282

8383
// Clone the input messages and turn them into response messages with upper case text.
8484
List<ChatMessage> responseMessages = CloneAndToUpperCase(messages, this.Name).ToList();
8585

8686
// Notify the thread of the input and output messages.
87-
var invokedContext = new ChatMessageStore.InvokedContext(messages, storeMessages)
87+
var invokedContext = new ChatHistoryProvider.InvokedContext(messages, storeMessages)
8888
{
8989
ResponseMessages = responseMessages
9090
};
91-
await typedThread.MessageStore.InvokedAsync(invokedContext, cancellationToken);
91+
await typedThread.ChatHistoryProvider.InvokedAsync(invokedContext, cancellationToken);
9292

9393
foreach (var message in responseMessages)
9494
{

dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
// Since we are using ChatCompletion which stores chat history locally, we can also add a message removal policy
6767
// that removes messages produced by the TextSearchProvider before they are added to the chat history, so that
6868
// we don't bloat chat history with all the search result messages.
69-
ChatMessageStoreFactory = (ctx, ct) => new ValueTask<ChatMessageStore>(new InMemoryChatMessageStore(ctx.SerializedState, ctx.JsonSerializerOptions)
69+
ChatHistoryProviderFactory = (ctx, ct) => new ValueTask<ChatHistoryProvider>(new InMemoryChatHistoryProvider(ctx.SerializedState, ctx.JsonSerializerOptions)
7070
.WithAIContextProviderMessageRemoval()),
7171
});
7272

dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131
{
3232
ChatOptions = new() { Instructions = "You are good at telling jokes." },
3333
Name = "Joker",
34-
ChatMessageStoreFactory = (ctx, ct) => new ValueTask<ChatMessageStore>(
35-
// Create a new chat message store for this agent that stores the messages in a vector store.
36-
// Each thread must get its own copy of the VectorChatMessageStore, since the store
37-
// also contains the id that the thread is stored under.
38-
new VectorChatMessageStore(vectorStore, ctx.SerializedState, ctx.JsonSerializerOptions))
34+
ChatHistoryProviderFactory = (ctx, ct) => new ValueTask<ChatHistoryProvider>(
35+
// Create a new ChatHistoryProvider for this agent that stores chat history in a vector store.
36+
// Each thread must get its own copy of the VectorChatHistoryProvider, since the provider
37+
// also contains the id that the chat history is stored under.
38+
new VectorChatHistoryProvider(vectorStore, ctx.SerializedState, ctx.JsonSerializerOptions))
3939
});
4040

4141
// Start a new thread for the agent conversation.
4242
AgentThread thread = await agent.GetNewThreadAsync();
4343

44-
// Run the agent with the thread that stores conversation history in the vector store.
44+
// Run the agent with the thread that stores chat history in the vector store.
4545
Console.WriteLine(await agent.RunAsync("Tell me a joke about a pirate.", thread));
4646

4747
// Serialize the thread state, so it can be stored for later use.
@@ -58,30 +58,30 @@
5858
// Deserialize the thread state after loading from storage.
5959
AgentThread resumedThread = await agent.DeserializeThreadAsync(serializedThread);
6060

61-
// Run the agent with the thread that stores conversation history in the vector store a second time.
61+
// Run the agent with the thread that stores chat history in the vector store a second time.
6262
Console.WriteLine(await agent.RunAsync("Now tell the same joke in the voice of a pirate, and add some emojis to the joke.", resumedThread));
6363

64-
// We can access the VectorChatMessageStore via the thread's GetService method if we need to read the key under which threads are stored.
65-
var messageStore = resumedThread.GetService<VectorChatMessageStore>()!;
66-
Console.WriteLine($"\nThread is stored in vector store under key: {messageStore.ThreadDbKey}");
64+
// We can access the VectorChatHistoryProvider via the thread's GetService method if we need to read the key under which chat history is stored.
65+
var chatHistoryProvider = resumedThread.GetService<VectorChatHistoryProvider>()!;
66+
Console.WriteLine($"\nThread is stored in vector store under key: {chatHistoryProvider.ThreadDbKey}");
6767

6868
namespace SampleApp
6969
{
7070
/// <summary>
71-
/// A sample implementation of <see cref="ChatMessageStore"/> that stores chat messages in a vector store.
71+
/// A sample implementation of <see cref="ChatHistoryProvider"/> that stores chat history in a vector store.
7272
/// </summary>
73-
internal sealed class VectorChatMessageStore : ChatMessageStore
73+
internal sealed class VectorChatHistoryProvider : ChatHistoryProvider
7474
{
7575
private readonly VectorStore _vectorStore;
7676

77-
public VectorChatMessageStore(VectorStore vectorStore, JsonElement serializedStoreState, JsonSerializerOptions? jsonSerializerOptions = null)
77+
public VectorChatHistoryProvider(VectorStore vectorStore, JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null)
7878
{
7979
this._vectorStore = vectorStore ?? throw new ArgumentNullException(nameof(vectorStore));
8080

81-
if (serializedStoreState.ValueKind is JsonValueKind.String)
81+
if (serializedState.ValueKind is JsonValueKind.String)
8282
{
8383
// Here we can deserialize the thread id so that we can access the same messages as before the suspension.
84-
this.ThreadDbKey = serializedStoreState.Deserialize<string>();
84+
this.ThreadDbKey = serializedState.Deserialize<string>();
8585
}
8686
}
8787

dotnet/samples/GettingStarted/Agents/Agent_Step16_ChatReduction/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
ChatOptions = new() { Instructions = "You are good at telling jokes." },
2626
Name = "Joker",
27-
ChatMessageStoreFactory = (ctx, ct) => new ValueTask<ChatMessageStore>(new InMemoryChatMessageStore(new MessageCountingChatReducer(2), ctx.SerializedState, ctx.JsonSerializerOptions))
27+
ChatHistoryProviderFactory = (ctx, ct) => new ValueTask<ChatHistoryProvider>(new InMemoryChatHistoryProvider(new MessageCountingChatReducer(2), ctx.SerializedState, ctx.JsonSerializerOptions))
2828
});
2929

3030
AgentThread thread = await agent.GetNewThreadAsync();

0 commit comments

Comments
 (0)