Skip to content

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

Merged
rogerbarreto merged 5 commits intomicrosoft: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
rogerbarreto merged 5 commits intomicrosoft:mainfrom
rogerbarreto:issues/3855-net-bug-tool-calls-do-not-work-without-providing-them-in-tools

Conversation

@rogerbarreto
Copy link
Member

@rogerbarreto rogerbarreto commented Mar 2, 2026

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>
@rogerbarreto rogerbarreto self-assigned this Mar 2, 2026
Copilot AI review requested due to automatic review settings March 2, 2026 15:52
@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
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 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.

rogerbarreto and others added 2 commits March 2, 2026 16:04
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>
@rogerbarreto rogerbarreto added this pull request to the merge queue Mar 2, 2026
Merged via the queue into microsoft:main with commit a442ee1 Mar 2, 2026
18 checks passed
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: [Bug]: Tool calls do not work without providing them in tools array

5 participants