Skip to content

.NET: Add integration test validating OpenAPI tools with AsAIAgent(agentVersion)#4931

Merged
rogerbarreto merged 2 commits intomicrosoft:mainfrom
rogerbarreto:issues/4883-bug-openapi-tool-name-description-not-loaded-from-foundry-agent
Mar 26, 2026
Merged

.NET: Add integration test validating OpenAPI tools with AsAIAgent(agentVersion)#4931
rogerbarreto merged 2 commits intomicrosoft:mainfrom
rogerbarreto:issues/4883-bug-openapi-tool-name-description-not-loaded-from-foundry-agent

Conversation

@rogerbarreto
Copy link
Copy Markdown
Member

Motivation and Context

Addresses #4883 — OpenAPI tool name/description not loaded from Foundry agent definition.

Investigation summary:

  • The original issue reported that when loading a Foundry agent with an OpenAPI tool via GetAIAgentAsync, the tool's name and description were missing from the loaded tool object.
  • The reporter traced this to MEAI (dotnet/extensions#7424), which was closed — AsAITool() is a thin wrapper around ResponseTool and doesn't hydrate extra metadata.
  • With the recommended path of AsAIAgent(agentVersion), the caller manages agent creation directly via the native AIProjectClient SDK. 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 strips Tools = null because tools are server-managed via the AgentReference, not per-request ChatOptions.Tools.

Conclusion: The AsAIAgent(agentVersion) flow works correctly with OpenAPI tools. Since we no longer support GetAIAgentAsync/CreateAIAgentAsync as the primary path (favoring caller-managed creation via AIProjectClient), this issue can be resolved. Similar to the response given in #4918, the recommended approach is:

  1. Create agent version with OpenAPI tools using native Azure.AI.Projects SDK types
  2. Wrap with aiProjectClient.AsAIAgent(agentVersion)

Description

Adds an integration test that validates the full end-to-end flow for Foundry agents with OpenAPI tool definitions:

  1. Creates an agent version with an OpenAPI tool (REST Countries API) using native Azure.AI.Projects SDK types (OpenApiFunctionDefinition, PromptAgentDefinition, AgentTool.CreateOpenApiTool)
  2. Wraps the AgentVersion using aiProjectClient.AsAIAgent(agentVersion)
  3. Invokes RunAsync to trigger the server-side OpenAPI function
  4. Validates the response contains expected country data from the REST Countries API

The test passes consistently, confirming that OpenAPI tools work correctly through the AsAIAgent(agentVersion) path.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? No — this is a test addition only.

…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>
Copy link
Copy Markdown
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

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 AgentVersion with an OpenAPI tool (REST Countries) using native SDK types.
  • Wrapped the created AgentVersion via AsAIAgent(agentVersion) and executed RunAsync, asserting the response includes expected country content.

- 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>
@rogerbarreto rogerbarreto force-pushed the issues/4883-bug-openapi-tool-name-description-not-loaded-from-foundry-agent branch from 9bbaeb3 to b11c867 Compare March 26, 2026 15:13
@rogerbarreto rogerbarreto enabled auto-merge March 26, 2026 15:35
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.

5 participants