From e6dfdd46f207d86ea79c1e160934b2e6e5d7deba Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
Date: Thu, 16 Apr 2026 12:38:29 +0100
Subject: [PATCH] Move FoundryResponsesHosting to
responses/Hosted-WorkflowHandoff, use GetResponsesClient
---
dotnet/agent-framework-dotnet.slnx | 2 +-
.../Hosted-WorkflowHandoff/.env.example | 4 ++
.../HostedWorkflowHandoff.csproj | 40 +++++++++++++++++++
.../Hosted-WorkflowHandoff}/Pages.cs | 0
.../Hosted-WorkflowHandoff}/Program.cs | 10 +++--
.../ResponseStreamValidator.cs | 2 +-
.../FoundryResponsesHosting.csproj | 27 -------------
7 files changed, 53 insertions(+), 32 deletions(-)
create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/.env.example
create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/HostedWorkflowHandoff.csproj
rename dotnet/samples/04-hosting/{FoundryResponsesHosting => FoundryHostedAgents/responses/Hosted-WorkflowHandoff}/Pages.cs (100%)
rename dotnet/samples/04-hosting/{FoundryResponsesHosting => FoundryHostedAgents/responses/Hosted-WorkflowHandoff}/Program.cs (95%)
rename dotnet/samples/04-hosting/{FoundryResponsesHosting => FoundryHostedAgents/responses/Hosted-WorkflowHandoff}/ResponseStreamValidator.cs (99%)
delete mode 100644 dotnet/samples/04-hosting/FoundryResponsesHosting/FoundryResponsesHosting.csproj
diff --git a/dotnet/agent-framework-dotnet.slnx b/dotnet/agent-framework-dotnet.slnx
index 67f3331b27..d356f212b2 100644
--- a/dotnet/agent-framework-dotnet.slnx
+++ b/dotnet/agent-framework-dotnet.slnx
@@ -294,7 +294,7 @@
-
+
diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/.env.example b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/.env.example
new file mode 100644
index 0000000000..0f711561be
--- /dev/null
+++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/.env.example
@@ -0,0 +1,4 @@
+AZURE_OPENAI_ENDPOINT=https://.openai.azure.com/
+AZURE_OPENAI_DEPLOYMENT=gpt-4o
+ASPNETCORE_URLS=http://+:8088
+ASPNETCORE_ENVIRONMENT=Development
diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/HostedWorkflowHandoff.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/HostedWorkflowHandoff.csproj
new file mode 100644
index 0000000000..3c0df909c9
--- /dev/null
+++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/HostedWorkflowHandoff.csproj
@@ -0,0 +1,40 @@
+
+
+
+ Exe
+ net10.0
+ enable
+ enable
+ HostedWorkflowHandoff
+ HostedWorkflowHandoff
+ false
+ $(NoWarn);NU1903;NU1605;MAAIW001
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dotnet/samples/04-hosting/FoundryResponsesHosting/Pages.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/Pages.cs
similarity index 100%
rename from dotnet/samples/04-hosting/FoundryResponsesHosting/Pages.cs
rename to dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/Pages.cs
diff --git a/dotnet/samples/04-hosting/FoundryResponsesHosting/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/Program.cs
similarity index 95%
rename from dotnet/samples/04-hosting/FoundryResponsesHosting/Program.cs
rename to dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/Program.cs
index 55e462e9a7..6b2eafddfd 100644
--- a/dotnet/samples/04-hosting/FoundryResponsesHosting/Program.cs
+++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/Program.cs
@@ -18,6 +18,7 @@
using System.ComponentModel;
using Azure.AI.OpenAI;
using Azure.Identity;
+using DotNetEnv;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Foundry.Hosting;
using Microsoft.Agents.AI.Hosting;
@@ -25,6 +26,9 @@ using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
using ModelContextProtocol.Client;
+// Load .env file if present (for local development)
+Env.TraversePath().Load();
+
var builder = WebApplication.CreateBuilder(args);
// ---------------------------------------------------------------------------
@@ -34,7 +38,7 @@ var endpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT
var deployment = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT") ?? "gpt-4o";
var azureClient = new AzureOpenAIClient(endpoint, new DefaultAzureCredential());
-IChatClient chatClient = azureClient.GetChatClient(deployment).AsIChatClient();
+IChatClient chatClient = azureClient.GetResponsesClient().AsIChatClient(deployment);
// ---------------------------------------------------------------------------
// 2. DEMO 1: Tool Agent — local tools + Microsoft Learn MCP
@@ -128,9 +132,9 @@ app.MapGet("/workflow-demo", () => Results.Content(Pages.WorkflowDemo, "text/htm
app.MapGet("/js/sse-validator.js", () => Results.Content(Pages.ValidationScript, "application/javascript"));
// Validation endpoint: accepts captured SSE lines and validates them
-app.MapPost("/api/validate", (FoundryResponsesHosting.CapturedSseStream captured) =>
+app.MapPost("/api/validate", (HostedWorkflowHandoff.CapturedSseStream captured) =>
{
- var validator = new FoundryResponsesHosting.ResponseStreamValidator();
+ var validator = new HostedWorkflowHandoff.ResponseStreamValidator();
foreach (var evt in captured.Events)
{
validator.ProcessEvent(evt.EventType, evt.Data);
diff --git a/dotnet/samples/04-hosting/FoundryResponsesHosting/ResponseStreamValidator.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/ResponseStreamValidator.cs
similarity index 99%
rename from dotnet/samples/04-hosting/FoundryResponsesHosting/ResponseStreamValidator.cs
rename to dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/ResponseStreamValidator.cs
index 5dc1b4c791..75822608e5 100644
--- a/dotnet/samples/04-hosting/FoundryResponsesHosting/ResponseStreamValidator.cs
+++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-WorkflowHandoff/ResponseStreamValidator.cs
@@ -3,7 +3,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
-namespace FoundryResponsesHosting;
+namespace HostedWorkflowHandoff;
/// Captured SSE event for validation.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Instantiated by JSON deserialization")]
diff --git a/dotnet/samples/04-hosting/FoundryResponsesHosting/FoundryResponsesHosting.csproj b/dotnet/samples/04-hosting/FoundryResponsesHosting/FoundryResponsesHosting.csproj
deleted file mode 100644
index 269754203d..0000000000
--- a/dotnet/samples/04-hosting/FoundryResponsesHosting/FoundryResponsesHosting.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- Exe
- net10.0
- enable
- enable
- false
- $(NoWarn);NU1903;NU1605;MAAIW001
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-