Skip to content

.NET: AzureAI Package - Skip tool validation when UseProvidedChatClientAsIs is true - #4389

Merged
Roger Barreto (rogerbarreto) merged 5 commits into
microsoft:mainfrom
rogerbarreto:issues/3855-net-bug-tool-calls-do-not-work-without-providing-them-in-tools
Mar 2, 2026
Merged

.NET: AzureAI Package - Skip tool validation when UseProvidedChatClientAsIs is true#4389
Roger Barreto (rogerbarreto) merged 5 commits into
microsoft:mainfrom
rogerbarreto:issues/3855-net-bug-tool-calls-do-not-work-without-providing-them-in-tools

Conversation

@rogerbarreto

@rogerbarreto Roger Barreto (rogerbarreto) commented Mar 2, 2026

Copy link
Copy Markdown
Member

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.

…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>
Copilot AI review requested due to automatic review settings March 2, 2026 15:52
@markwallace-microsoft Mark Wallace (markwallace-microsoft) added the .NET Usage: [Issues, PRs], Target: .Net label Mar 2, 2026
@github-actions github-actions Bot changed the title .Net: AzureAI Package - Skip tool validation when UseProvidedChatClientAsIs is true .NET: AzureAI Package - Skip tool validation when UseProvidedChatClientAsIs is true Mar 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 GetAIAgentAsync to disable requireInvocableTools validation when UseProvidedChatClientAsIs is 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.

Comment thread dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs Outdated
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: Tool calls do not work without providing them in tools array

5 participants