Skip to content

.Net: Add additional Hosted Agent Samples#4325

Open
rogerbarreto wants to merge 7 commits intomicrosoft:mainfrom
rogerbarreto:samples/hosted-agents
Open

.Net: Add additional Hosted Agent Samples#4325
rogerbarreto wants to merge 7 commits intomicrosoft:mainfrom
rogerbarreto:samples/hosted-agents

Conversation

@rogerbarreto
Copy link
Member

Add 3 new Hosted Agent samples + documentation restructure

This PR brings three missing hosted agent samples from microsoft-foundry/foundry-samples into the agent-framework repository, adapted to follow our conventions (net10.0, AzureCliCredential, CPM-disabled csproj pattern).

New Samples

Sample Description
AgentWithTools Demonstrates Foundry tools (UseFoundryTools) with MCP and code interpreter. Connects to Microsoft Learn's public MCP endpoint for documentation search.
AgentWithLocalTools Local C# function tool execution using AIProjectClient. Simulates a Seattle hotel search with availability, pricing, and ratings.
AgentThreadAndHITL Human-in-the-loop approval flow using ApprovalRequiredAIFunction with thread persistence via InMemoryAgentThreadRepository.

Documentation

  • Root HostedAgents/README.md — New shared documentation with common prerequisites, Azure AI Foundry setup (role assignment, MCP connection), running/deploying instructions, and troubleshooting guide.
  • Individual sample READMEs — Trimmed to sample-specific information only, with a pointer to the root README for common setup.
  • .http files — All samples now include run-requests.http for testing with VS Code REST Client (replaced test_requests.py in AgentThreadAndHITL).

All three samples have been tested end-to-end

  • ✅ AgentWithTools — MCP microsoft_docs_search tool invocation
  • ✅ AgentWithLocalTools — Local C# GetAvailableHotels function execution
  • ✅ AgentThreadAndHITL — Full HITL approval/rejection flow with thread persistence

rogerbarreto and others added 2 commits February 26, 2026 15:47
…AgentThreadAndHITL

- AgentWithTools: Foundry tools (MCP + code interpreter) via UseFoundryTools
- AgentWithLocalTools: Local C# function tool (Seattle hotel search) with AIProjectClient
- AgentThreadAndHITL: Human-in-the-loop with ApprovalRequiredAIFunction and thread persistence

All samples follow agent-framework conventions (net10.0, AzureCliCredential, CPM disabled).
AgentWithTools includes comprehensive README with setup guide and troubleshooting.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…date sample READMEs

- Create root README.md with shared prerequisites, Azure AI Foundry setup,
  troubleshooting, and samples index
- Replace test_requests.py with run-requests.http in AgentThreadAndHITL
- Add pointer to root README in all 6 sample READMEs
- Trim AgentWithTools README to concise style

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 26, 2026 16:20
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Feb 26, 2026
@rogerbarreto rogerbarreto changed the title Samples/hosted agents .Net: Add additional Hosted Agent Samples Feb 26, 2026
@github-actions github-actions bot changed the title .Net: Add additional Hosted Agent Samples .NET: Samples/hosted agents Feb 26, 2026
@rogerbarreto rogerbarreto changed the title .NET: Samples/hosted agents .Net: Add additional Hosted Agent Samples Feb 26, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds three new hosted agent samples to the agent-framework repository, demonstrating different capabilities of the Azure AI AgentServer SDK. The samples follow the repository's conventions for Docker-based deployment with Central Package Management (CPM) disabled, .NET 10 targeting, and AzureCliCredential authentication.

Changes:

  • Added three new hosted agent samples: AgentWithTools (Foundry tools with MCP and code interpreter), AgentWithLocalTools (local C# function tools with hotel search), and AgentThreadAndHITL (human-in-the-loop approval with thread persistence)
  • Created a comprehensive shared README at HostedAgents/README.md consolidating common setup, prerequisites, Azure AI Foundry configuration, and troubleshooting guidance
  • Updated existing sample READMEs to reference the shared documentation and added .http test files for all samples

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
dotnet/samples/05-end-to-end/HostedAgents/README.md New comprehensive shared documentation covering prerequisites, Azure AI Foundry setup, environment variables, deployment, and troubleshooting
dotnet/samples/05-end-to-end/HostedAgents/AgentWithTools/* New sample demonstrating Foundry MCP tools and code interpreter with UseFoundryTools extension
dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/* New sample demonstrating local C# function execution with hotel search tool using AIProjectClient
dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/* New sample demonstrating human-in-the-loop approval workflow with ApprovalRequiredAIFunction and thread persistence
dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/README.md Added reference to shared README for common setup instructions
dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/README.md Added reference to shared README for common setup instructions
dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/README.md Added reference to shared README for common setup instructions

- Add UTF-8 BOM (CHARSET)
- Sort System.ClientModel.Primitives import alphabetically (IMPORTS)
- Use target-typed new for AIProjectClient (IDE0090)
- Add internal accessibility modifier to Hotel record (IDE0040)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Change default model from gpt-4.1-mini to gpt-4o-mini in AgentWithLocalTools
  (Program.cs, agent.yaml, README.md) to match existing samples
- Change README example from gpt-5.2 to gpt-4o-mini in AgentWithTools and root README
- Align AgentWithLocalTools package versions with other samples:
  Azure.AI.AgentServer.AgentFramework beta.6 -> beta.8
  Azure.AI.OpenAI 2.8.0-beta.1 -> 2.7.0-beta.2
  Microsoft.Extensions.AI.OpenAI 10.2.0-preview -> 10.1.1-preview

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rogerbarreto and others added 2 commits February 26, 2026 16:56
- Azure.AI.OpenAI: 2.7.0-beta.2 -> 2.8.0-beta.1
- Microsoft.Extensions.AI.OpenAI: 10.1.1-preview -> 10.3.0

Aligns with AgentWithHostedMCP which uses the latest versions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure.AI.AgentServer.AgentFramework beta.8 was compiled against
Microsoft.Extensions.AI.Abstractions with the single-param
FunctionApprovalRequestContent.CreateResponse(bool). Version 10.3.0
changed the signature to include an optional reason parameter, causing
a binary incompatibility at runtime. Pin to 10.1.1 until the framework
is recompiled against the newer abstractions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

4 participants