.NET: AzureAI Package - Skip tool validation when UseProvidedChatClientAsIs is true#4389
Merged
rogerbarreto merged 5 commits intomicrosoft:mainfrom Mar 2, 2026
Conversation
…t#3855) When GetAIAgentAsync is called with ChatClientAgentOptions.UseProvidedChatClientAsIs = true, skip requireInvocableTools validation so users can handle function calls manually via custom ChatClient middleware without needing to provide matching AIFunction tools. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the AzureAI .NET agent creation flow so that when GetAIAgentAsync is called with ChatClientAgentOptions.UseProvidedChatClientAsIs = true, the extension skips invocable-tool validation, enabling manual tool handling via custom IChatClient middleware.
Changes:
- Update
GetAIAgentAsyncto disablerequireInvocableToolsvalidation whenUseProvidedChatClientAsIsis enabled. - Add a unit test asserting no exception is thrown in this mode when server function tools exist but no matching invocable tools are provided.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs | Gates requireInvocableTools based on UseProvidedChatClientAsIs for GetAIAgentAsync. |
| dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs | Adds test coverage for skipping tool validation when UseProvidedChatClientAsIs=true. |
dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs
Show resolved
Hide resolved
UseProvidedChatClientAsIs is a non-nullable bool, so use ! operator instead of != true for clarity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…microsoft#3855) Always match provided AIFunctions to server-side function definitions regardless of requireInvocableTools flag. Only throw when validation is required and no match is found. This ensures UseProvidedChatClientAsIs still preserves user-provided AIFunction tools instead of falling back to the broken ResponseToolAITool wrapper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SergeyMenshykh
approved these changes
Mar 2, 2026
westey-m
approved these changes
Mar 2, 2026
…ithout-providing-them-in-tools
…ithout-providing-them-in-tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
When GetAIAgentAsync is called with ChatClientAgentOptions.UseProvidedChatClientAsIs = true, skip requireInvocableTools validation so users can handle function calls manually via custom ChatClient middleware without needing to provide matching AIFunction tools.