Files
Ben Thomas 9199c84d42 .NET: Remove Foundry Toolbox server-side tools support (#5753)
* .NET: Remove Foundry Toolbox server-side tools support

Mirrors the Python cleanup in microsoft/agent-framework#5671. Passing
toolbox tools as server-side Responses tools is not the experience we
want to support; the hosted-agent MCP toolbox path (HostedMcpToolboxAITool
+ FoundryToolboxService) remains the supported way to consume Foundry
Toolboxes.

Removed:
- FoundryToolbox static class (GetToolboxVersionAsync / GetToolsAsync /
  ToAITools / SanitizeAndConvert)
- AIProjectClient.GetToolboxToolsAsync extension
- Agent_Step25_ToolboxServerSideTools sample (+ slnx entry)
- FoundryToolboxTests, TestDataUtil, HttpHandlerAssert, and the toolbox
  JSON fixtures only those tests referenced
- ToolboxHostedAgentTests and ToolboxHostedAgentFixture; the "toolbox"
  switch arm + CreateToolboxAgent helper in TestContainer; matching
  README scenario row and bootstrap script entry

Kept (MCP path, unchanged):
- HostedMcpToolboxAITool, FoundryAITool.CreateHostedMcpToolbox,
  FoundryAIToolExtensions.CreateHostedMcpToolbox(ToolboxRecord/Version)
- FoundryToolboxService, AddFoundryToolboxes, marker injection in
  AgentFrameworkResponseHandler, InputConverter.ReadMcpToolboxMarkers
- Hosted-Toolbox sample, McpToolbox* tests, FoundryToolboxServiceTests

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

* .NET: Add Foundry Toolbox MCP sample (Agent_Step25_FoundryToolboxMcp)

Adds a non-hosted-agent equivalent of the Python foundry_chat_client_with_toolbox.py sample. The agent connects to a Foundry Toolbox's MCP endpoint via Streamable HTTP, injects a fresh Azure AI bearer token on every request, and discovers the toolbox's tools at runtime via McpClient.ListToolsAsync.

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

* .NET: Tighten Agent_Step25_FoundryToolboxMcp README/Program comments

Drop 'non-hosted agent' framing from README (this sample isn't related to hosted agents) and remove narrative comparison to server-side tools from the Program.cs header comment.

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

* Drop python sample reference from Agent_Step25 README

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

* Drop incorrect .NET 10 prereq from Agent_Step25 README

Toolboxes don't require .NET 10 (Microsoft.Agents.AI.Foundry targets net8.0+); the parent AgentsWithFoundry README already lists the sample SDK prereq.

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

* Fix Toolsets api-version in Agent_Step25 example endpoint

Use 2025-05-01-preview to match FoundryToolboxOptions.ApiVersion. The placeholder 'v1' is not accepted by the Toolsets endpoint.

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

---------

Co-authored-by: alliscode <bentho@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-11 22:05:14 +00:00

3.8 KiB

Getting started with Foundry Agents

These samples demonstrate how to use Microsoft Foundry with Agent Framework.

Quick start

The simplest way to create a Foundry agent is using the FoundryAgent type directly:

FoundryAgent agent = new(
    new Uri(endpoint),
    new AzureCliCredential(),
    model: "gpt-5.4-mini",
    instructions: "You are good at telling jokes.",
    name: "JokerAgent");

Console.WriteLine(await agent.RunAsync("Tell me a joke about a pirate."));

Or using the AIProjectClient.AsAIAgent(...) extensions:

AIProjectClient aiProjectClient = new(new Uri(endpoint), new DefaultAzureCredential());

FoundryAgent agent = aiProjectClient.AsAIAgent(
    model: deploymentName,
    instructions: "You are good at telling jokes.",
    name: "JokerAgent");

Prerequisites

  • .NET 10 SDK or later
  • Foundry project endpoint
  • Azure CLI installed and authenticated

Set:

$env:AZURE_AI_PROJECT_ENDPOINT="https://your-foundry-service.services.ai.azure.com/api/projects/your-foundry-project"
$env:AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-5.4-mini"

Some samples require extra tool-specific environment variables. See each sample for details.

Samples

Sample Description
FoundryAgent lifecycle Create a FoundryAgent directly with endpoint and credentials
Basics (Responses API) Create and run an agent using AsAIAgent extensions
Multi-turn conversation Multi-turn using sessions and response ID chaining
Multi-turn with server conversations Server-side conversations visible in Foundry UI
Using function tools Function tools
Function tools with approvals Human-in-the-loop approval
Structured output Structured output with JSON schema
Persisted conversations Persisting and resuming conversations
Observability OpenTelemetry observability
Dependency injection DI with a hosted service
Using MCP client as tools MCP client tools
Using images Image multi-modality
Agent as function tool Agent as a function tool for another
Middleware Multiple middleware layers
Plugins Plugins with dependency injection
Code interpreter Code interpreter tool
Computer use Computer use tool
File search File search tool
OpenAPI tools OpenAPI tools
Bing custom search Bing Custom Search tool
SharePoint SharePoint grounding tool
Microsoft Fabric Microsoft Fabric tool
Web search Web search tool
Memory search Memory search tool
Local MCP Local MCP client with HTTP transport
Code interpreter file download Download container files generated by code interpreter
Foundry toolbox via MCP Use a Foundry Toolbox from a non-hosted agent via its MCP endpoint

Running the samples

cd dotnet/samples/02-agents/AgentsWithFoundry
dotnet run --project .\FoundryAgent_Step01