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 - - - - - - - - - - - - - - - - - -