From 6dc16b6fc405db9900dc77b7247b1221b457a1df Mon Sep 17 00:00:00 2001 From: zhiyongli Date: Wed, 28 Jan 2026 23:21:49 +0800 Subject: [PATCH 1/3] Add test case for list custom agent --- dotnet/test/McpAndAgentsTests.cs | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/dotnet/test/McpAndAgentsTests.cs b/dotnet/test/McpAndAgentsTests.cs index d216032a..1376313d 100644 --- a/dotnet/test/McpAndAgentsTests.cs +++ b/dotnet/test/McpAndAgentsTests.cs @@ -2,7 +2,9 @@ * Copyright (c) Microsoft Corporation. All rights reserved. *--------------------------------------------------------------------------------------------*/ +using System.ComponentModel; using GitHub.Copilot.SDK.Test.Harness; +using Microsoft.Extensions.AI; using Xunit; using Xunit.Abstractions; @@ -196,6 +198,73 @@ public async Task Should_Handle_Custom_Agent_With_Tools_Configuration() await session.DisposeAsync(); } + [Fact] + public async Task Should_Custom_Agent_Availability() + { + var customAgents = new List + { + new CustomAgentConfig + { + Name = "dd-agent", + DisplayName = "dd Agent", + Description = "An dd agent", + Prompt = "You are an dd agent", + Infer = true + } + }; + + var session = await Client.CreateSessionAsync(new SessionConfig + { + CustomAgents = customAgents + }); + + Assert.Matches(@"^[a-f0-9-]+$", session.SessionId); + + await session.SendAsync(new MessageOptions { Prompt = "List All Custom Agents" }); + + var message = await TestHelper.GetFinalAssistantMessageAsync(session); + Assert.NotNull(message); + Assert.Contains("dd-agent", message!.Data.Content); + + await session.DisposeAsync(); + } + + [Fact] + public async Task Should_Custom_Agent_Availability_With_AI_Tools() + { + var customAgents = new List + { + new CustomAgentConfig + { + Name = "dd-agent", + DisplayName = "dd Agent", + Description = "An dd agent", + Prompt = "You are an dd agent", + Infer = true + } + }; + + var session = await Client.CreateSessionAsync(new SessionConfig + { + CustomAgents = customAgents, + Tools = [AIFunctionFactory.Create(EncryptString, "encrypt_string")], + }); + + Assert.Matches(@"^[a-f0-9-]+$", session.SessionId); + + await session.SendAsync(new MessageOptions { Prompt = "List All Custom Agents" }); + + var message = await TestHelper.GetFinalAssistantMessageAsync(session); + Assert.NotNull(message); + Assert.Contains("dd-agent", message!.Data.Content); + + await session.DisposeAsync(); + + [Description("Encrypts a string")] + static string EncryptString([Description("String to encrypt")] string input) + => input.ToUpperInvariant(); + } + [Fact] public async Task Should_Handle_Custom_Agent_With_MCP_Servers() { From 234e13a0ef9fadd88f5681fc0c4392db6952e9a1 Mon Sep 17 00:00:00 2001 From: Patrick Nikoletich Date: Wed, 28 Jan 2026 11:31:02 -0800 Subject: [PATCH 2/3] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- dotnet/test/McpAndAgentsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/test/McpAndAgentsTests.cs b/dotnet/test/McpAndAgentsTests.cs index 1376313d..acc48ee6 100644 --- a/dotnet/test/McpAndAgentsTests.cs +++ b/dotnet/test/McpAndAgentsTests.cs @@ -199,7 +199,7 @@ public async Task Should_Handle_Custom_Agent_With_Tools_Configuration() } [Fact] - public async Task Should_Custom_Agent_Availability() + public async Task Should_List_Custom_Agent_In_Session_Response() { var customAgents = new List { From f42ac88b89ee33de0fec2a54147bfc82f9446a9d Mon Sep 17 00:00:00 2001 From: Patrick Nikoletich Date: Wed, 28 Jan 2026 11:31:50 -0800 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- dotnet/test/McpAndAgentsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/test/McpAndAgentsTests.cs b/dotnet/test/McpAndAgentsTests.cs index acc48ee6..32522f98 100644 --- a/dotnet/test/McpAndAgentsTests.cs +++ b/dotnet/test/McpAndAgentsTests.cs @@ -230,7 +230,7 @@ public async Task Should_List_Custom_Agent_In_Session_Response() } [Fact] - public async Task Should_Custom_Agent_Availability_With_AI_Tools() + public async Task Should_Verify_Custom_Agent_Availability_With_AI_Tools() { var customAgents = new List {