Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions dotnet/test/McpAndAgentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -196,6 +198,73 @@ public async Task Should_Handle_Custom_Agent_With_Tools_Configuration()
await session.DisposeAsync();
}

[Fact]
public async Task Should_List_Custom_Agent_In_Session_Response()
{
var customAgents = new List<CustomAgentConfig>
{
new CustomAgentConfig
{
Name = "dd-agent",
DisplayName = "dd Agent",
Description = "An dd agent",
Prompt = "You are an dd agent",
Comment on lines +210 to +211
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The grammatical error "An dd agent" should be corrected to "A dd agent" (assuming "dd" is an acronym or abbreviation). If "dd" stands for something specific like "Data Dump" or similar, consider spelling it out for clarity in the description.

Suggested change
Description = "An dd agent",
Prompt = "You are an dd agent",
Description = "A dd agent",
Prompt = "You are a dd agent",

Copilot uses AI. Check for mistakes.
Comment on lines +210 to +211
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The grammatical error "You are an dd agent" should be corrected to "You are a dd agent" (assuming "dd" is an acronym or abbreviation). Consider also providing more context about what the "dd" agent is meant to do in the prompt.

Suggested change
Description = "An dd agent",
Prompt = "You are an dd agent",
Description = "A dd agent",
Prompt = "You are a dd agent",

Copilot uses AI. Check for mistakes.
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_Verify_Custom_Agent_Availability_With_AI_Tools()
{
var customAgents = new List<CustomAgentConfig>
{
new CustomAgentConfig
{
Name = "dd-agent",
DisplayName = "dd Agent",
Description = "An dd agent",
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The grammatical error "An dd agent" should be corrected to "A dd agent" (assuming "dd" is an acronym or abbreviation). If "dd" stands for something specific, consider spelling it out for clarity in the description.

Copilot uses AI. Check for mistakes.
Prompt = "You are an dd agent",
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The grammatical error "You are an dd agent" should be corrected to "You are a dd agent" (assuming "dd" is an acronym or abbreviation). Consider also providing more context about what the "dd" agent is meant to do in the prompt.

Copilot uses AI. Check for mistakes.
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);
Comment on lines +235 to +259
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

There is significant duplication between this test and Should_Custom_Agent_Availability. Both tests create the same custom agent configuration and perform identical assertions. Consider extracting the common custom agent configuration into a helper method or private field, or consolidate these tests if they're meant to verify the same behavior.

Copilot uses AI. Check for mistakes.

await session.DisposeAsync();

[Description("Encrypts a string")]
static string EncryptString([Description("String to encrypt")] string input)
=> input.ToUpperInvariant();
Comment on lines +250 to +265
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The encrypt_string tool is defined but never invoked in the test. The test only verifies that the custom agent is available, similar to the first test. Consider either: 1) Removing the tool since it's not needed to verify agent availability, or 2) Adding an assertion to verify the tool can be invoked alongside the custom agent (e.g., prompting "Use encrypt_string to encrypt 'hello' and list all custom agents").

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task Should_Handle_Custom_Agent_With_MCP_Servers()
{
Expand Down