.NET: Add integration test validating OpenAPI tools with AsAIAgent(agentVersion)#4931
Merged
rogerbarreto merged 2 commits intomicrosoft:mainfrom Mar 26, 2026
Conversation
…ion) Validates end-to-end flow creating a Foundry agent with an OpenAPI tool definition via native Azure.AI.Projects SDK types and wrapping it with AsAIAgent(agentVersion). The test confirms the server-side OpenAPI function is invoked correctly through RunAsync. Addresses microsoft#4883 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Azure AI (.NET) integration test to validate that Foundry-hosted agents created via the native Azure.AI.Projects SDK with an OpenAPI tool can be wrapped with AIProjectClient.AsAIAgent(agentVersion) and successfully executed via RunAsync, addressing the scenario discussed in #4883.
Changes:
- Added an integration test that creates an
AgentVersionwith an OpenAPI tool (REST Countries) using native SDK types. - Wrapped the created
AgentVersionviaAsAIAgent(agentVersion)and executedRunAsync, asserting the response includes expected country content.
dotnet/tests/AzureAI.IntegrationTests/AIProjectClientCreateTests.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/AzureAI.IntegrationTests/AIProjectClientCreateTests.cs
Outdated
Show resolved
Hide resolved
- Use RetryFact with Skip for manual testing (flaky due to external API) - Fix agentName -> AgentName to match PascalCase convention in file - Strengthen tool invocation assertion: require >= 3 Eurozone countries - Add comment explaining server-side OpenAPI tools don't surface as FunctionCallContent in the MEAI abstraction Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9bbaeb3 to
b11c867
Compare
westey-m
approved these changes
Mar 26, 2026
SergeyMenshykh
approved these changes
Mar 26, 2026
Merged
This was referenced Apr 3, 2026
This was referenced Apr 6, 2026
Merged
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
Addresses #4883 — OpenAPI tool name/description not loaded from Foundry agent definition.
Investigation summary:
GetAIAgentAsync, the tool'snameanddescriptionwere missing from the loaded tool object.AsAITool()is a thin wrapper aroundResponseTooland doesn't hydrate extra metadata.AsAIAgent(agentVersion), the caller manages agent creation directly via the nativeAIProjectClientSDK. OpenAPI tools are defined server-side in the agent definition and the Responses API handles them — no client-side tool metadata hydration is needed.GetAgentEnabledChatOptions()correctly stripsTools = nullbecause tools are server-managed via theAgentReference, not per-requestChatOptions.Tools.Conclusion: The
AsAIAgent(agentVersion)flow works correctly with OpenAPI tools. Since we no longer supportGetAIAgentAsync/CreateAIAgentAsyncas the primary path (favoring caller-managed creation viaAIProjectClient), this issue can be resolved. Similar to the response given in #4918, the recommended approach is:Azure.AI.ProjectsSDK typesaiProjectClient.AsAIAgent(agentVersion)Description
Adds an integration test that validates the full end-to-end flow for Foundry agents with OpenAPI tool definitions:
Azure.AI.ProjectsSDK types (OpenApiFunctionDefinition,PromptAgentDefinition,AgentTool.CreateOpenApiTool)AgentVersionusingaiProjectClient.AsAIAgent(agentVersion)RunAsyncto trigger the server-side OpenAPI functionThe test passes consistently, confirming that OpenAPI tools work correctly through the
AsAIAgent(agentVersion)path.Contribution Checklist