From 3ea9c5fa5dbbb860995eead85acd40dd66f39914 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Date: Thu, 19 Feb 2026 10:40:27 +0000 Subject: [PATCH] .NET: Fixes AgentWithHostedMCP chat fails: ErrorHTTP 404 (: 404) Resource not found (#3856) * Update packages * Fix run-request.http format --- .../AgentWithHostedMCP/AgentWithHostedMCP.csproj | 7 +++---- dotnet/samples/HostedAgents/AgentWithHostedMCP/Program.cs | 2 +- .../HostedAgents/AgentWithHostedMCP/run-requests.http | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dotnet/samples/HostedAgents/AgentWithHostedMCP/AgentWithHostedMCP.csproj b/dotnet/samples/HostedAgents/AgentWithHostedMCP/AgentWithHostedMCP.csproj index b00e4a48de..361848c27d 100644 --- a/dotnet/samples/HostedAgents/AgentWithHostedMCP/AgentWithHostedMCP.csproj +++ b/dotnet/samples/HostedAgents/AgentWithHostedMCP/AgentWithHostedMCP.csproj @@ -35,11 +35,10 @@ - - + + - - + diff --git a/dotnet/samples/HostedAgents/AgentWithHostedMCP/Program.cs b/dotnet/samples/HostedAgents/AgentWithHostedMCP/Program.cs index 827b161052..0898bc0252 100644 --- a/dotnet/samples/HostedAgents/AgentWithHostedMCP/Program.cs +++ b/dotnet/samples/HostedAgents/AgentWithHostedMCP/Program.cs @@ -9,7 +9,6 @@ using Azure.AI.OpenAI; using Azure.Identity; using Microsoft.Agents.AI; using Microsoft.Extensions.AI; -using OpenAI.Responses; var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set."); var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini"; @@ -29,6 +28,7 @@ AIAgent agent = new AzureOpenAIClient( new Uri(endpoint), new DefaultAzureCredential()) .GetResponsesClient(deploymentName) + .AsIChatClient() .CreateAIAgent( instructions: "You answer questions by searching the Microsoft Learn content only.", name: "MicrosoftLearnAgent", diff --git a/dotnet/samples/HostedAgents/AgentWithHostedMCP/run-requests.http b/dotnet/samples/HostedAgents/AgentWithHostedMCP/run-requests.http index cc26f43b90..b7c0b35efd 100644 --- a/dotnet/samples/HostedAgents/AgentWithHostedMCP/run-requests.http +++ b/dotnet/samples/HostedAgents/AgentWithHostedMCP/run-requests.http @@ -7,6 +7,7 @@ GET {{host}}/readiness ### Simple string input - Ask about MCP Tools POST {{endpoint}} Content-Type: application/json + { "input": "Please summarize the Azure AI Agent documentation related to MCP Tool calling?" } @@ -14,6 +15,7 @@ Content-Type: application/json ### Explicit input - Ask about Agent Framework POST {{endpoint}} Content-Type: application/json + { "input": [ {