Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

  • Analyze current code coverage and identify non-covered paths
  • Run existing tests to ensure they pass (25 tests passing initially)
  • Add tests for AsAIAgent overload with ChatOptions
    • Test null client handling
    • Test null response handling
    • Test null persistentAgent handling
    • Test instructions from agent metadata when chatOptions is null
    • Test instructions from agent metadata when chatOptions.Instructions is null
    • Test instructions NOT overridden when chatOptions has explicit instructions
    • Test clientFactory application with ChatOptions
  • Add tests for ConvertAIToolsToToolDefinitions private method via CreateAIAgentAsync
    • Test HostedCodeInterpreterTool handling
    • Test HostedCodeInterpreterTool with HostedFileContent inputs
    • Test HostedFileSearchTool handling
    • Test HostedFileSearchTool with HostedVectorStoreContent inputs
    • Test HostedWebSearchTool handling with connectionId
    • Test HostedWebSearchTool without connectionId (falls to default)
    • Test default fallback for unknown/function tools
    • Test mixed tools scenario
  • Add tests for GetAIAgentAsync and CreateAIAgentAsync with options
    • Test null options handling
    • Test clientFactory with options
    • Test services with options
  • Verify all tests pass (50 tests total - all passing)
  • Coverage improved from 59.2% to 97.9% line rate and 97.45% branch rate
  • Fix redundant cast error IDE0004
Original prompt

This section details on the original issue you should resolve

<issue_title>.NET: Improve unit test coverage for Microsoft.Agents.AI.AzureAI.Persistent</issue_title>
<issue_description>Required level is 85%

Image</issue_description>

<agent_instructions>Please analyze the Cobertura Coverage information related to the Microsoft.Agents.AI.AzureAI.Persistent and lets improve its coverage on non-covered paths.

Please keep the same patterns used for UnitTests existing into the Microsoft.Agents.AI.AzureAI.Persistent.UnitTests.

Use our repository guidelines regarding UnitTests code as well as use our existing File approach for the UnitTests generation, only creating new ones if the file being covered have not being covered yet.

Ensure the coverage only covers non-covered paths without duplicating paths that are already covered.

Ensure all existing tests are working on top of the new added ones. This change should only be focused in UnitTests not changing any functionality.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…rsistent

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve unit test coverage for Microsoft.Agents.AI.AzureAI.Persistent Improve unit test coverage for Microsoft.Agents.AI.AzureAI.Persistent Jan 22, 2026
Copilot AI requested a review from rogerbarreto January 22, 2026 18:16
@github-actions github-actions bot changed the title Improve unit test coverage for Microsoft.Agents.AI.AzureAI.Persistent .NET: Improve unit test coverage for Microsoft.Agents.AI.AzureAI.Persistent Jan 23, 2026
@rogerbarreto
Copy link
Member

@copilot

Format issues happening below.

/app/dotnet/tests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests/Extensions/PersistentAgentsClientExtensionsTests.cs(584,30): error IDE0004: Cast is redundant. [/app/dotnet/tests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests/Extensions/PersistentAgentsClientExtensionsTests.cs(584,30): error IDE0004: Cast is redundant. [/app/dotnet/tests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests.csproj]

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot

Format issues happening below.
...

Fixed in 41240ef by removing the redundant cast and using the named parameter persistentAgentResponse: null! instead.

@rogerbarreto rogerbarreto marked this pull request as ready for review January 23, 2026 12:55
Copilot AI review requested due to automatic review settings January 23, 2026 12:55
Copy link
Contributor

Copilot AI left a 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 significantly improves unit test coverage for the Microsoft.Agents.AI.AzureAI.Persistent namespace, targeting the PersistentAgentsClientExtensions class. The PR successfully increases coverage from 59.2% to 97.9% line rate and 97.45% branch rate by adding comprehensive tests for previously uncovered code paths.

Changes:

  • Added 25 new test methods covering various overloads of AsAIAgent, GetAIAgentAsync, and CreateAIAgentAsync methods
  • Added comprehensive tests for the ConvertAIToolsToToolDefinitions private method by testing CreateAIAgentAsync with different tool types
  • Added tests for null parameter validation, instructions handling, clientFactory application, and services propagation

@rogerbarreto rogerbarreto added this pull request to the merge queue Jan 23, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Improve unit test coverage for Microsoft.Agents.AI.AzureAI.Persistent

5 participants