Skip to content

Commit c52866b

Browse files
committed
Checkpoint
1 parent 7a77e71 commit c52866b

31 files changed

+1298
-35
lines changed

dotnet/Directory.Packages.props

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,15 @@
3535
<PackageVersion Include="Grpc.AspNetCore.Server.Reflection" Version="2.70.0" />
3636
<PackageVersion Include="Grpc.AspNetCore.Web" Version="2.70.0" />
3737
<PackageVersion Include="Grpc.Tools" Version="2.71.0" />
38-
<PackageVersion Include="ModelContextProtocol" Version="0.1.0-preview.12" />
39-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.13" />
40-
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.14" />
41-
<PackageVersion Include="Microsoft.ML.Tokenizers.Data.Cl100kBase" Version="1.0.1" />
42-
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />
43-
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="17.12.19" />
4438
<PackageVersion Include="Handlebars.Net.Helpers" Version="2.4.10" />
4539
<PackageVersion Include="Handlebars.Net" Version="2.1.6" />
4640
<PackageVersion Include="HtmlAgilityPack" Version="1.11.72" />
4741
<PackageVersion Include="JsonSchema.Net" Version="5.4.2" />
4842
<PackageVersion Include="Markdig" Version="0.40.0" />
43+
<PackageVersion Include="Microsoft.Agents.CopilotStudio.Client" Version="1.1.107-beta" />
4944
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
45+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.13" />
46+
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.14" />
5047
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
5148
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
5249
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
@@ -62,7 +59,12 @@
6259
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
6360
<PackageVersion Include="Microsoft.Bcl.TimeProvider" Version="8.0.1" />
6461
<PackageVersion Include="Microsoft.Identity.Client" Version="4.67.2" />
62+
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.67.2" />
63+
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />
6564
<PackageVersion Include="Microsoft.ML.OnnxRuntime" Version="1.21.0" />
65+
<PackageVersion Include="Microsoft.ML.Tokenizers.Data.Cl100kBase" Version="1.0.1" />
66+
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="17.12.19" />
67+
<PackageVersion Include="ModelContextProtocol" Version="0.1.0-preview.12" />
6668
<PackageVersion Include="MSTest.TestFramework" Version="3.8.0" />
6769
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
6870
<PackageVersion Include="Npgsql" Version="8.0.6" />
@@ -140,7 +142,6 @@
140142
<PackageVersion Include="DuckDB.NET.Data" Version="1.1.3" />
141143
<PackageVersion Include="MongoDB.Driver" Version="2.30.0" />
142144
<PackageVersion Include="Microsoft.Graph" Version="4.51.0" />
143-
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.67.2" />
144145
<PackageVersion Include="Microsoft.OpenApi" Version="1.6.23" />
145146
<PackageVersion Include="Microsoft.OpenApi.Readers" Version="1.6.23" />
146147
<PackageVersion Include="Microsoft.OpenApi.ApiManifest" Version="0.5.6-preview" />

dotnet/SK-dotnet.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.InProcess.UnitTests
550550
EndProject
551551
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectorData.UnitTests", "src\Connectors\VectorData.UnitTests\VectorData.UnitTests.csproj", "{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}"
552552
EndProject
553+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agents.CopilotStudio", "src\Agents\Copilot\Agents.CopilotStudio.csproj", "{84BA9026-E05E-9B6A-C177-C04BDAA1714F}"
554+
EndProject
553555
Global
554556
GlobalSection(SolutionConfigurationPlatforms) = preSolution
555557
Debug|Any CPU = Debug|Any CPU
@@ -1511,6 +1513,12 @@ Global
15111513
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Publish|Any CPU.Build.0 = Debug|Any CPU
15121514
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Release|Any CPU.ActiveCfg = Release|Any CPU
15131515
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Release|Any CPU.Build.0 = Release|Any CPU
1516+
{84BA9026-E05E-9B6A-C177-C04BDAA1714F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1517+
{84BA9026-E05E-9B6A-C177-C04BDAA1714F}.Debug|Any CPU.Build.0 = Debug|Any CPU
1518+
{84BA9026-E05E-9B6A-C177-C04BDAA1714F}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
1519+
{84BA9026-E05E-9B6A-C177-C04BDAA1714F}.Publish|Any CPU.Build.0 = Publish|Any CPU
1520+
{84BA9026-E05E-9B6A-C177-C04BDAA1714F}.Release|Any CPU.ActiveCfg = Release|Any CPU
1521+
{84BA9026-E05E-9B6A-C177-C04BDAA1714F}.Release|Any CPU.Build.0 = Release|Any CPU
15141522
EndGlobalSection
15151523
GlobalSection(SolutionProperties) = preSolution
15161524
HideSolutionNode = FALSE
@@ -1716,6 +1724,7 @@ Global
17161724
{CCC909E4-5269-A31E-0BFD-4863B4B29BBB} = {A70ED5A7-F8E1-4A57-9455-3C05989542DA}
17171725
{DA6B4ED4-ED0B-D25C-889C-9F940E714891} = {A70ED5A7-F8E1-4A57-9455-3C05989542DA}
17181726
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84} = {5A7028A7-4DDF-4E4F-84A9-37CE8F8D7E89}
1727+
{84BA9026-E05E-9B6A-C177-C04BDAA1714F} = {6823CD5E-2ABE-41EB-B865-F86EC13F0CF9}
17191728
EndGlobalSection
17201729
GlobalSection(ExtensibilityGlobals) = postSolution
17211730
SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using Microsoft.Agents.CopilotStudio.Client;
4+
using Microsoft.SemanticKernel;
5+
using Microsoft.SemanticKernel.Agents.Copilot;
6+
using Microsoft.SemanticKernel.ChatCompletion;
7+
8+
namespace GettingStarted.CopilotStudioAgents;
9+
10+
/// <summary>
11+
/// Demonstrates how to use the <see cref="CopilotStudioAgent"/> to interact with a Copilot Agent service.
12+
/// This sample shows how to create a CopilotStudioAgent, send user messages, and display the agent's responses.
13+
/// </summary>
14+
public sealed class Step01_CopilotStudioAgent(ITestOutputHelper output) : BaseAgentsTest(output)
15+
{
16+
[Fact]
17+
public async Task UseCopilotStudioAgent()
18+
{
19+
CopilotStudioConnectionSettings settings = new(TestConfiguration.GetSection(nameof(CopilotStudioAgent)));
20+
CopilotClient client = CopilotStudioAgent.CreateClient(settings);
21+
CopilotStudioAgent agent = new(client);
22+
23+
await InvokeAgentAsync("Why is the sky blue?");
24+
await InvokeAgentAsync("What is the speed of light?");
25+
26+
// Local function to invoke agent and display the response.
27+
async Task InvokeAgentAsync(string input)
28+
{
29+
Console.WriteLine($"\n# {AuthorRole.User}: {input}");
30+
31+
await foreach (ChatMessageContent response in agent.InvokeAsync(input))
32+
{
33+
WriteAgentChatMessage(response);
34+
}
35+
}
36+
}
37+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using Microsoft.Agents.CopilotStudio.Client;
4+
using Microsoft.SemanticKernel;
5+
using Microsoft.SemanticKernel.Agents.Copilot;
6+
using Microsoft.SemanticKernel.ChatCompletion;
7+
8+
namespace GettingStarted.CopilotStudioAgents;
9+
10+
/// <summary>
11+
/// Demonstrates how to use a <see cref="CopilotStudioAgent"/> with a persistent <see cref="CopilotStudioAgentThread"/>
12+
/// to maintain conversation context across multiple user interactions. This sample shows how to send messages to the agent,
13+
/// receive responses, and reset the conversation thread.
14+
/// </summary>
15+
public sealed class Step02_CopilotStudioAgent_Threads(ITestOutputHelper output) : BaseAgentsTest(output)
16+
{
17+
[Fact]
18+
public async Task UseCopilotStudioAgentThread()
19+
{
20+
CopilotStudioConnectionSettings settings = new(TestConfiguration.GetSection(nameof(CopilotStudioAgent)));
21+
CopilotClient client = CopilotStudioAgent.CreateClient(settings);
22+
CopilotStudioAgent agent = new(client);
23+
CopilotStudioAgentThread thread = new(client);
24+
25+
await InvokeAgentAsync("Hello! Who are you? My name is John Doe.");
26+
await InvokeAgentAsync("What is the speed of light?");
27+
await InvokeAgentAsync("What did I just ask?");
28+
await InvokeAgentAsync("What is my name?");
29+
await InvokeAgentAsync("RESET");
30+
await InvokeAgentAsync("Yes");
31+
await InvokeAgentAsync("What is my name?");
32+
33+
// Local function to invoke agent and display the response.
34+
async Task InvokeAgentAsync(string input)
35+
{
36+
Console.WriteLine($"\n# {AuthorRole.User}: {input}");
37+
38+
await foreach (ChatMessageContent response in agent.InvokeAsync(input, thread))
39+
{
40+
WriteAgentChatMessage(response);
41+
}
42+
}
43+
}
44+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using Microsoft.Agents.CopilotStudio.Client;
4+
using Microsoft.SemanticKernel;
5+
using Microsoft.SemanticKernel.Agents.Copilot;
6+
using Microsoft.SemanticKernel.ChatCompletion;
7+
8+
namespace GettingStarted.CopilotStudioAgents;
9+
10+
/// <summary>
11+
/// Demonstrates how to use a Copilot Studio Agent with a persistent conversation thread
12+
/// to perform web search queries and retrieve responses in a .NET test scenario.
13+
/// </summary>
14+
public sealed class Step04_CopilotStudioAgent_WebSearch(ITestOutputHelper output) : BaseAgentsTest(output)
15+
{
16+
[Fact]
17+
public async Task UseCopilotStudioAgentThread()
18+
{
19+
CopilotStudioConnectionSettings settings = new(TestConfiguration.GetSection(nameof(CopilotStudioAgent)));
20+
CopilotClient client = CopilotStudioAgent.CreateClient(settings);
21+
CopilotStudioAgent agent = new(client);
22+
CopilotStudioAgentThread thread = new(client);
23+
24+
await InvokeAgentAsync("Which team won the 2025 NCAA Basketball championship?");
25+
await InvokeAgentAsync("What was the final score?");
26+
27+
// Local function to invoke agent and display the response.
28+
async Task InvokeAgentAsync(string input)
29+
{
30+
Console.WriteLine($"\n# {AuthorRole.User}: {input}");
31+
32+
await foreach (ChatMessageContent response in agent.InvokeAsync(input, thread))
33+
{
34+
WriteAgentChatMessage(response);
35+
}
36+
}
37+
}
38+
}

dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
<IsTestProject>true</IsTestProject>
1010
<RootNamespace></RootNamespace>
1111
<!-- Suppress: "Declare types in namespaces", "Require ConfigureAwait", "Experimental" -->
12-
<NoWarn>$(NoWarn);CS8618,IDE0009,IDE1006,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110,OPENAI001</NoWarn>
12+
<NoWarn>$(NoWarn);NU1008;CS8618,IDE0009,IDE1006,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110,OPENAI001</NoWarn>
1313
<OutputType>Library</OutputType>
1414
<UserSecretsId>5ee045b0-aea3-4f08-8d31-32d1a6f8fed0</UserSecretsId>
1515
</PropertyGroup>
1616

1717
<ItemGroup>
1818
<PackageReference Include="Azure.Identity" />
1919
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" />
20-
<PackageReference Include="Microsoft.Extensions.Configuration" />
21-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
20+
<PackageReference Include="Microsoft.Extensions.Configuration" VersionOverride="9.0.1" />
21+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" VersionOverride="9.0.1" />
2222
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
23-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
24-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
25-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
26-
<PackageReference Include="Microsoft.Extensions.Http" />
27-
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
28-
<PackageReference Include="Microsoft.Extensions.Logging" />
29-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
23+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" VersionOverride="9.0.1" />
24+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" VersionOverride="9.0.1" />
25+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" VersionOverride="9.0.1" />
26+
<PackageReference Include="Microsoft.Extensions.Http" VersionOverride="9.0.1" />
27+
<PackageReference Include="Microsoft.Extensions.Http.Resilience" VersionOverride="9.1.0" />
28+
<PackageReference Include="Microsoft.Extensions.Logging" VersionOverride="9.0.1" />
29+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="9.0.1" />
3030
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
3131
<PackageReference Include="OpenTelemetry.Exporter.Console" />
3232
<PackageReference Include="coverlet.collector" />
@@ -43,9 +43,10 @@
4343

4444
<ItemGroup>
4545
<ProjectReference Include="..\..\src\Agents\AzureAI\Agents.AzureAI.csproj" />
46+
<ProjectReference Include="..\..\src\Agents\Bedrock\Agents.Bedrock.csproj" />
47+
<ProjectReference Include="..\..\src\Agents\Copilot\Agents.CopilotStudio.csproj" />
4648
<ProjectReference Include="..\..\src\Agents\Core\Agents.Core.csproj" />
4749
<ProjectReference Include="..\..\src\Agents\OpenAI\Agents.OpenAI.csproj" />
48-
<ProjectReference Include="..\..\src\Agents\Bedrock\Agents.Bedrock.csproj" />
4950
<ProjectReference Include="..\..\src\Agents\Yaml\Agents.Yaml.csproj" />
5051
<ProjectReference Include="..\..\src\Connectors\Connectors.AzureOpenAI\Connectors.AzureOpenAI.csproj" />
5152
<ProjectReference Include="..\..\src\SemanticKernel.Abstractions\SemanticKernel.Abstractions.csproj" />

dotnet/src/Agents/Abstractions/AgentThread.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected internal virtual async Task CreateAsync(CancellationToken cancellation
4444
return;
4545
}
4646

47-
this.Id = await this.CreateInternalAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
47+
this.Id = await this.CreateInternalAsync(cancellationToken).ConfigureAwait(false);
4848
}
4949

5050
/// <summary>

dotnet/src/Agents/Abstractions/AgentThreadOperationException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Microsoft.SemanticKernel.Agents;
77
/// <summary>
88
/// Defines an exception that's thrown when an operation on an <see cref="AgentThread"/> fails, such as creating or deleting the thread.
99
/// </summary>
10-
public class AgentThreadOperationException : Exception
10+
public class AgentThreadOperationException : KernelException
1111
{
1212
/// <summary>
1313
/// Initializes a new instance of the <see cref="AgentThreadOperationException"/> class.

dotnet/src/Agents/Bedrock/BedrockAgent.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public IAsyncEnumerable<AgentResponseItem<ChatMessageContent>> InvokeAsync(
9494
BedrockAgentInvokeOptions? options = null,
9595
CancellationToken cancellationToken = default)
9696
{
97-
return this.InvokeAsync(messages, thread, options as AgentInvokeOptions, cancellationToken);
97+
return this.InvokeAsync(messages, thread, (AgentInvokeOptions?)options, cancellationToken);
9898
}
9999

100100
/// <inheritdoc/>
@@ -111,14 +111,14 @@ public override async IAsyncEnumerable<AgentResponseItem<ChatMessageContent>> In
111111
}
112112

113113
// Create a thread if needed
114-
var bedrockThread = await this.EnsureThreadExistsWithMessagesAsync(
114+
BedrockAgentThread bedrockThread = await this.EnsureThreadExistsWithMessagesAsync(
115115
messages,
116116
thread,
117117
() => new BedrockAgentThread(this.RuntimeClient),
118118
cancellationToken).ConfigureAwait(false);
119119

120120
// Ensure that the last message provided is a user message
121-
string? message = this.ExtractUserMessage(messages.Last());
121+
string message = this.ExtractUserMessage(messages.Last());
122122

123123
// Build session state with conversation history if needed
124124
SessionState sessionState = this.ExtractSessionState(messages);
@@ -161,7 +161,7 @@ public IAsyncEnumerable<AgentResponseItem<ChatMessageContent>> InvokeAsync(
161161
BedrockAgentInvokeOptions? options = null,
162162
CancellationToken cancellationToken = default)
163163
{
164-
return this.InvokeAsync(invokeAgentRequest, thread, options as AgentInvokeOptions, cancellationToken);
164+
return this.InvokeAsync(invokeAgentRequest, thread, (AgentInvokeOptions?)options, cancellationToken);
165165
}
166166

167167
/// <summary>
@@ -530,6 +530,7 @@ async IAsyncEnumerable<StreamingChatMessageContent> InvokeInternal()
530530
#endregion
531531

532532
#endregion
533+
533534
#endregion
534535

535536
/// <inheritdoc/>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<!-- THIS PROPERTY GROUP MUST COME FIRST -->
5+
<AssemblyName>Microsoft.SemanticKernel.Agents.CopilotStudio</AssemblyName>
6+
<RootNamespace>Microsoft.SemanticKernel.Agents.CopilotStudio</RootNamespace>
7+
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
8+
<NoWarn>$(NoWarn);CA1724;IDE1006;SKEXP0110</NoWarn>
9+
<EnablePackageValidation>false</EnablePackageValidation>
10+
<VersionSuffix>alpha</VersionSuffix>
11+
</PropertyGroup>
12+
13+
<Import Project="$(RepoRoot)/dotnet/nuget/nuget-package.props" />
14+
15+
<PropertyGroup>
16+
<!-- NuGet Package Settings -->
17+
<Title>Semantic Kernel Agents - Copilot Studio</Title>
18+
<Description>Defines a concrete Agent based on the Bedrock Agent Service.</Description>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/src/Diagnostics/*" Link="%(RecursiveDir)Utilities/%(Filename)%(Extension)" />
23+
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/src/System/AppContextSwitchHelper.cs" Link="%(RecursiveDir)Utilities/%(Filename)%(Extension)" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\Abstractions\Agents.Abstractions.csproj" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<PackageReference Include="Microsoft.Agents.CopilotStudio.Client" />
32+
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<InternalsVisibleTo Include="SemanticKernel.Agents.UnitTests" />
37+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
38+
</ItemGroup>
39+
40+
41+
</Project>

0 commit comments

Comments
 (0)