From 1584879edd63814cfe95d836ac37727cd1e72893 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Date: Mon, 13 Apr 2026 19:50:11 +0100 Subject: [PATCH] Removing extra using samples --- .../AgentThreadAndHITL.csproj | 24 ---- .../AgentThreadAndHITL/Program.cs | 115 ------------------ .../AgentWithLocalTools.csproj | 24 ---- .../AgentWithLocalTools/Program.cs | 115 ------------------ .../AgentWithTextSearchRag.csproj | 24 ---- .../AgentWithTextSearchRag/Program.cs | 115 ------------------ .../AgentsInWorkflows.csproj | 24 ---- .../AgentsInWorkflows/Program.cs | 115 ------------------ 8 files changed, 556 deletions(-) delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/AgentThreadAndHITL.csproj delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/Program.cs delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/AgentWithLocalTools.csproj delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/Program.cs delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/Program.cs delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/AgentsInWorkflows.csproj delete mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/Program.cs diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/AgentThreadAndHITL.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/AgentThreadAndHITL.csproj deleted file mode 100644 index 69905ed43b..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/AgentThreadAndHITL.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - net10.0 - enable - enable - false - AgentThreadAndHITLClient - agent-thread-hitl-client - $(NoWarn);NU1903;NU1605;OPENAI001 - - - - - - - - - - - - - diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/Program.cs deleted file mode 100644 index 14ddb29fe8..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentThreadAndHITL/Program.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System.ClientModel.Primitives; -using Azure.AI.Extensions.OpenAI; -using Azure.AI.Projects; -using Azure.Identity; -using DotNetEnv; -using Microsoft.Agents.AI; -using Microsoft.Agents.AI.Foundry; - -// Load .env file if present (for local development) -Env.TraversePath().Load(); - -Uri agentEndpoint = new(Environment.GetEnvironmentVariable("AGENT_ENDPOINT") - ?? "http://localhost:8088"); - -var agentName = Environment.GetEnvironmentVariable("AGENT_NAME") - ?? throw new InvalidOperationException("AGENT_NAME is not set."); - -// ── Create an agent-framework agent backed by the remote agent endpoint ────── - -var options = new AIProjectClientOptions(); - -if (agentEndpoint.Scheme == "http") -{ - // For local HTTP dev: tell AIProjectClient the endpoint is HTTPS (to satisfy - // BearerTokenPolicy's TLS check), then swap the scheme back to HTTP right - // before the request hits the wire. - - agentEndpoint = new UriBuilder(agentEndpoint) { Scheme = "https" }.Uri; - options.AddPolicy(new HttpSchemeRewritePolicy(), PipelinePosition.BeforeTransport); -} - -var aiProjectClient = new AIProjectClient(agentEndpoint, new AzureCliCredential(), options); -FoundryAgent agent = aiProjectClient.AsAIAgent(new AgentReference(agentName)); - -AgentSession session = await agent.CreateSessionAsync(); - -// ── REPL ────────────────────────────────────────────────────────────────────── - -Console.ForegroundColor = ConsoleColor.Cyan; -Console.WriteLine($""" - ══════════════════════════════════════════════════════════ - HITL Agent Client - Connected to: {agentEndpoint} - Type a message or 'quit' to exit - ══════════════════════════════════════════════════════════ - """); -Console.ResetColor(); -Console.WriteLine(); - -while (true) -{ - Console.ForegroundColor = ConsoleColor.Green; - Console.Write("You> "); - Console.ResetColor(); - - string? input = Console.ReadLine(); - - if (string.IsNullOrWhiteSpace(input)) { continue; } - if (input.Equals("quit", StringComparison.OrdinalIgnoreCase)) { break; } - - try - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.Write("Agent> "); - Console.ResetColor(); - - await foreach (var update in agent.RunStreamingAsync(input, session)) - { - Console.Write(update); - } - - Console.WriteLine(); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"Error: {ex.Message}"); - Console.ResetColor(); - } - - Console.WriteLine(); -} - -Console.WriteLine("Goodbye!"); - -/// -/// For Local Development Only -/// Rewrites HTTPS URIs to HTTP right before transport, allowing AIProjectClient -/// to target a local HTTP dev server while satisfying BearerTokenPolicy's TLS check. -/// -internal sealed class HttpSchemeRewritePolicy : PipelinePolicy -{ - public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - ProcessNext(message, pipeline, currentIndex); - } - - public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - await ProcessNextAsync(message, pipeline, currentIndex).ConfigureAwait(false); - } - - private static void RewriteScheme(PipelineMessage message) - { - var uri = message.Request.Uri!; - if (uri.Scheme == Uri.UriSchemeHttps) - { - message.Request.Uri = new UriBuilder(uri) { Scheme = "http" }.Uri; - } - } -} diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/AgentWithLocalTools.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/AgentWithLocalTools.csproj deleted file mode 100644 index 0742994449..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/AgentWithLocalTools.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - net10.0 - enable - enable - false - AgentWithLocalToolsClient - agent-with-local-tools-client - $(NoWarn);NU1903;NU1605;OPENAI001 - - - - - - - - - - - - - diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/Program.cs deleted file mode 100644 index 0caa06c36b..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithLocalTools/Program.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System.ClientModel.Primitives; -using Azure.AI.Extensions.OpenAI; -using Azure.AI.Projects; -using Azure.Identity; -using DotNetEnv; -using Microsoft.Agents.AI; -using Microsoft.Agents.AI.Foundry; - -// Load .env file if present (for local development) -Env.TraversePath().Load(); - -Uri agentEndpoint = new(Environment.GetEnvironmentVariable("AGENT_ENDPOINT") - ?? "http://localhost:8088"); - -var agentName = Environment.GetEnvironmentVariable("AGENT_NAME") - ?? throw new InvalidOperationException("AGENT_NAME is not set."); - -// ── Create an agent-framework agent backed by the remote agent endpoint ────── - -var options = new AIProjectClientOptions(); - -if (agentEndpoint.Scheme == "http") -{ - // For local HTTP dev: tell AIProjectClient the endpoint is HTTPS (to satisfy - // BearerTokenPolicy's TLS check), then swap the scheme back to HTTP right - // before the request hits the wire. - - agentEndpoint = new UriBuilder(agentEndpoint) { Scheme = "https" }.Uri; - options.AddPolicy(new HttpSchemeRewritePolicy(), PipelinePosition.BeforeTransport); -} - -var aiProjectClient = new AIProjectClient(agentEndpoint, new AzureCliCredential(), options); -FoundryAgent agent = aiProjectClient.AsAIAgent(new AgentReference(agentName)); - -AgentSession session = await agent.CreateSessionAsync(); - -// ── REPL ────────────────────────────────────────────────────────────────────── - -Console.ForegroundColor = ConsoleColor.Cyan; -Console.WriteLine($""" - ══════════════════════════════════════════════════════════ - Hotel Agent Client - Connected to: {agentEndpoint} - Type a message or 'quit' to exit - ══════════════════════════════════════════════════════════ - """); -Console.ResetColor(); -Console.WriteLine(); - -while (true) -{ - Console.ForegroundColor = ConsoleColor.Green; - Console.Write("You> "); - Console.ResetColor(); - - string? input = Console.ReadLine(); - - if (string.IsNullOrWhiteSpace(input)) { continue; } - if (input.Equals("quit", StringComparison.OrdinalIgnoreCase)) { break; } - - try - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.Write("Agent> "); - Console.ResetColor(); - - await foreach (var update in agent.RunStreamingAsync(input, session)) - { - Console.Write(update); - } - - Console.WriteLine(); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"Error: {ex.Message}"); - Console.ResetColor(); - } - - Console.WriteLine(); -} - -Console.WriteLine("Goodbye!"); - -/// -/// For Local Development Only -/// Rewrites HTTPS URIs to HTTP right before transport, allowing AIProjectClient -/// to target a local HTTP dev server while satisfying BearerTokenPolicy's TLS check. -/// -internal sealed class HttpSchemeRewritePolicy : PipelinePolicy -{ - public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - ProcessNext(message, pipeline, currentIndex); - } - - public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - await ProcessNextAsync(message, pipeline, currentIndex).ConfigureAwait(false); - } - - private static void RewriteScheme(PipelineMessage message) - { - var uri = message.Request.Uri!; - if (uri.Scheme == Uri.UriSchemeHttps) - { - message.Request.Uri = new UriBuilder(uri) { Scheme = "http" }.Uri; - } - } -} diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj deleted file mode 100644 index 028977d0aa..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - net10.0 - enable - enable - false - AgentWithTextSearchRagClient - agent-with-rag-client - $(NoWarn);NU1903;NU1605;OPENAI001 - - - - - - - - - - - - - diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/Program.cs deleted file mode 100644 index efc6c1d982..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentWithTextSearchRag/Program.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System.ClientModel.Primitives; -using Azure.AI.Extensions.OpenAI; -using Azure.AI.Projects; -using Azure.Identity; -using DotNetEnv; -using Microsoft.Agents.AI; -using Microsoft.Agents.AI.Foundry; - -// Load .env file if present (for local development) -Env.TraversePath().Load(); - -Uri agentEndpoint = new(Environment.GetEnvironmentVariable("AGENT_ENDPOINT") - ?? "http://localhost:8088"); - -var agentName = Environment.GetEnvironmentVariable("AGENT_NAME") - ?? throw new InvalidOperationException("AGENT_NAME is not set."); - -// ── Create an agent-framework agent backed by the remote agent endpoint ────── - -var options = new AIProjectClientOptions(); - -if (agentEndpoint.Scheme == "http") -{ - // For local HTTP dev: tell AIProjectClient the endpoint is HTTPS (to satisfy - // BearerTokenPolicy's TLS check), then swap the scheme back to HTTP right - // before the request hits the wire. - - agentEndpoint = new UriBuilder(agentEndpoint) { Scheme = "https" }.Uri; - options.AddPolicy(new HttpSchemeRewritePolicy(), PipelinePosition.BeforeTransport); -} - -var aiProjectClient = new AIProjectClient(agentEndpoint, new AzureCliCredential(), options); -FoundryAgent agent = aiProjectClient.AsAIAgent(new AgentReference(agentName)); - -AgentSession session = await agent.CreateSessionAsync(); - -// ── REPL ────────────────────────────────────────────────────────────────────── - -Console.ForegroundColor = ConsoleColor.Cyan; -Console.WriteLine($""" - ══════════════════════════════════════════════════════════ - RAG Agent Client - Connected to: {agentEndpoint} - Type a message or 'quit' to exit - ══════════════════════════════════════════════════════════ - """); -Console.ResetColor(); -Console.WriteLine(); - -while (true) -{ - Console.ForegroundColor = ConsoleColor.Green; - Console.Write("You> "); - Console.ResetColor(); - - string? input = Console.ReadLine(); - - if (string.IsNullOrWhiteSpace(input)) { continue; } - if (input.Equals("quit", StringComparison.OrdinalIgnoreCase)) { break; } - - try - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.Write("Agent> "); - Console.ResetColor(); - - await foreach (var update in agent.RunStreamingAsync(input, session)) - { - Console.Write(update); - } - - Console.WriteLine(); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"Error: {ex.Message}"); - Console.ResetColor(); - } - - Console.WriteLine(); -} - -Console.WriteLine("Goodbye!"); - -/// -/// For Local Development Only -/// Rewrites HTTPS URIs to HTTP right before transport, allowing AIProjectClient -/// to target a local HTTP dev server while satisfying BearerTokenPolicy's TLS check. -/// -internal sealed class HttpSchemeRewritePolicy : PipelinePolicy -{ - public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - ProcessNext(message, pipeline, currentIndex); - } - - public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - await ProcessNextAsync(message, pipeline, currentIndex).ConfigureAwait(false); - } - - private static void RewriteScheme(PipelineMessage message) - { - var uri = message.Request.Uri!; - if (uri.Scheme == Uri.UriSchemeHttps) - { - message.Request.Uri = new UriBuilder(uri) { Scheme = "http" }.Uri; - } - } -} diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/AgentsInWorkflows.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/AgentsInWorkflows.csproj deleted file mode 100644 index 27e2da3908..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/AgentsInWorkflows.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - net10.0 - enable - enable - false - AgentsInWorkflowsClient - agents-in-workflows-client - $(NoWarn);NU1903;NU1605;OPENAI001 - - - - - - - - - - - - - diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/Program.cs deleted file mode 100644 index 33e4765fb9..0000000000 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Using-Samples/AgentsInWorkflows/Program.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System.ClientModel.Primitives; -using Azure.AI.Extensions.OpenAI; -using Azure.AI.Projects; -using Azure.Identity; -using DotNetEnv; -using Microsoft.Agents.AI; -using Microsoft.Agents.AI.Foundry; - -// Load .env file if present (for local development) -Env.TraversePath().Load(); - -Uri agentEndpoint = new(Environment.GetEnvironmentVariable("AGENT_ENDPOINT") - ?? "http://localhost:8088"); - -var agentName = Environment.GetEnvironmentVariable("AGENT_NAME") - ?? throw new InvalidOperationException("AGENT_NAME is not set."); - -// ── Create an agent-framework agent backed by the remote agent endpoint ────── - -var options = new AIProjectClientOptions(); - -if (agentEndpoint.Scheme == "http") -{ - // For local HTTP dev: tell AIProjectClient the endpoint is HTTPS (to satisfy - // BearerTokenPolicy's TLS check), then swap the scheme back to HTTP right - // before the request hits the wire. - - agentEndpoint = new UriBuilder(agentEndpoint) { Scheme = "https" }.Uri; - options.AddPolicy(new HttpSchemeRewritePolicy(), PipelinePosition.BeforeTransport); -} - -var aiProjectClient = new AIProjectClient(agentEndpoint, new AzureCliCredential(), options); -FoundryAgent agent = aiProjectClient.AsAIAgent(new AgentReference(agentName)); - -AgentSession session = await agent.CreateSessionAsync(); - -// ── REPL ────────────────────────────────────────────────────────────────────── - -Console.ForegroundColor = ConsoleColor.Cyan; -Console.WriteLine($""" - ══════════════════════════════════════════════════════════ - Translation Workflow Agent Client - Connected to: {agentEndpoint} - Type a message or 'quit' to exit - ══════════════════════════════════════════════════════════ - """); -Console.ResetColor(); -Console.WriteLine(); - -while (true) -{ - Console.ForegroundColor = ConsoleColor.Green; - Console.Write("You> "); - Console.ResetColor(); - - string? input = Console.ReadLine(); - - if (string.IsNullOrWhiteSpace(input)) { continue; } - if (input.Equals("quit", StringComparison.OrdinalIgnoreCase)) { break; } - - try - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.Write("Agent> "); - Console.ResetColor(); - - await foreach (var update in agent.RunStreamingAsync(input, session)) - { - Console.Write(update); - } - - Console.WriteLine(); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"Error: {ex.Message}"); - Console.ResetColor(); - } - - Console.WriteLine(); -} - -Console.WriteLine("Goodbye!"); - -/// -/// For Local Development Only -/// Rewrites HTTPS URIs to HTTP right before transport, allowing AIProjectClient -/// to target a local HTTP dev server while satisfying BearerTokenPolicy's TLS check. -/// -internal sealed class HttpSchemeRewritePolicy : PipelinePolicy -{ - public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - ProcessNext(message, pipeline, currentIndex); - } - - public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) - { - RewriteScheme(message); - await ProcessNextAsync(message, pipeline, currentIndex).ConfigureAwait(false); - } - - private static void RewriteScheme(PipelineMessage message) - { - var uri = message.Request.Uri!; - if (uri.Scheme == Uri.UriSchemeHttps) - { - message.Request.Uri = new UriBuilder(uri) { Scheme = "http" }.Uri; - } - } -}