-
Notifications
You must be signed in to change notification settings - Fork 682
Add test case for list custom agent #243
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds two new test cases to verify that custom agents can be listed and accessed correctly in the McpAndAgentsTests suite. The tests focus on ensuring custom agent availability both with and without AI tool configuration.
Changes:
- Added two new test methods to verify custom agent availability and listing functionality
- Added required imports (
System.ComponentModelandMicrosoft.Extensions.AI) to support AI tool integration
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Description = "An dd agent", | ||
| Prompt = "You are an dd agent", |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
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.
| Description = "An dd agent", | |
| Prompt = "You are an dd agent", | |
| Description = "A dd agent", | |
| Prompt = "You are a dd agent", |
| { | ||
| Name = "dd-agent", | ||
| DisplayName = "dd Agent", | ||
| Description = "An dd agent", |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
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.
| 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(); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
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").
| Description = "An dd agent", | ||
| Prompt = "You are an dd agent", |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
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.
| Description = "An dd agent", | |
| Prompt = "You are an dd agent", | |
| Description = "A dd agent", | |
| Prompt = "You are a dd agent", |
| Name = "dd-agent", | ||
| DisplayName = "dd Agent", | ||
| Description = "An dd agent", | ||
| Prompt = "You are an dd agent", |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
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.
| var customAgents = new List<CustomAgentConfig> | ||
| { | ||
| 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); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request adds new tests to ensure custom agent availability and their interaction with AI tools in the
McpAndAgentsTestssuite. The main focus is on verifying that custom agents can be listed and accessed correctly, both with and without additional AI tool configuration.Custom agent availability and AI tools integration:
Should_Custom_Agent_Availabilitytest to verify that a custom agent can be created and is correctly listed in the session response.Should_Custom_Agent_Availability_With_AI_Toolstest to ensure that custom agents are available and function properly when AI tools (such as anencrypt_stringfunction) are configured in the session.Test infrastructure updates:
System.ComponentModelandMicrosoft.Extensions.AInamespaces to support new test scenarios and AI tool integration.