From 0d052e63ae6825c2af610f4b740eb49084c13e16 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Date: Thu, 12 Mar 2026 09:55:20 +0000 Subject: [PATCH] Fix hosted agent samples Docker build failures due to experimental API warnings Add #pragma warning disable directives to suppress experimental API diagnostics that cause build errors in Docker isolation (where repo-level Directory.Build.props is not inherited): - AgentWithHostedMCP: suppress MEAI001 (HostedMcpServerTool) and OPENAI001 (GetResponsesClient) - FoundrySingleAgent: suppress CA2252 (AIProjectClient preview features) - FoundryMultiAgent: suppress CA2252 (AIProjectClient preview features) Fixes #4365 --- .../05-end-to-end/HostedAgents/AgentWithHostedMCP/Program.cs | 3 +++ .../05-end-to-end/HostedAgents/FoundryMultiAgent/Program.cs | 2 ++ .../05-end-to-end/HostedAgents/FoundrySingleAgent/Program.cs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Program.cs b/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Program.cs index 972205cfe2..b7b610b663 100644 --- a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Program.cs +++ b/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Program.cs @@ -4,6 +4,9 @@ // In this case the OpenAI responses service will invoke any MCP tools as required. MCP tools are not invoked by the Agent Framework. // The sample demonstrates how to use MCP tools with auto approval by setting ApprovalMode to NeverRequire. +#pragma warning disable MEAI001 // HostedMcpServerTool, HostedMcpServerToolApprovalMode are experimental +#pragma warning disable OPENAI001 // GetResponsesClient is experimental + using Azure.AI.AgentServer.AgentFramework.Extensions; using Azure.AI.OpenAI; using Azure.Identity; diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Program.cs b/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Program.cs index 138efb0096..6947c85e3f 100644 --- a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Program.cs +++ b/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Program.cs @@ -3,6 +3,8 @@ // This sample demonstrates a multi-agent workflow with Writer and Reviewer agents // using Azure AI Foundry AIProjectClient and the Agent Framework WorkflowBuilder. +#pragma warning disable CA2252 // AIProjectClient and Agents API require opting into preview features + using Azure.AI.AgentServer.AgentFramework.Extensions; using Azure.AI.Projects; using Azure.Identity; diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Program.cs b/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Program.cs index 759636bcc0..80edf42089 100644 --- a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Program.cs +++ b/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Program.cs @@ -4,6 +4,8 @@ // Uses Microsoft Agent Framework with Azure AI Foundry. // Ready for deployment to Foundry Hosted Agent service. +#pragma warning disable CA2252 // AIProjectClient and Agents API require opting into preview features + using System.ComponentModel; using System.Globalization; using System.Text;