Skip to content

Commit c7186e0

Browse files
Update foundry-toolbox-server-side sample to supported toolbox path (#595)
The sample used AIProjectClient.GetToolboxToolsAsync, an extension that was removed from Microsoft.Agents.AI.Foundry.Hosting. Switch to the supported eager path: register the toolbox with builder.Services.AddFoundryToolboxes, so the hosting layer connects to the toolbox managed MCP proxy at startup and injects its tools into every request. Also bump the Agent Framework dependency to the latest preview and align the Azure SDK it depends on: Microsoft.Agents.AI.Foundry.Hosting 1.3.0-preview.260423.1 -> 1.11.0-preview.260623.1 Azure.AI.Projects 2.1.0-beta.1 -> 2.1.0-beta.3 README and agent.manifest.yaml wording updated to describe the new flow. Verified live on a Foundry hosted agent against a Tao toolbox.
1 parent d268ead commit c7186e0

4 files changed

Lines changed: 26 additions & 22 deletions

File tree

samples/csharp/hosted-agents/agent-framework/foundry-toolbox-server-side/Program.cs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
/*
44
* Foundry Toolbox (Server-Side Tools) — Agent Framework Responses agent for C#
55
*
6-
* Hosted agent that loads a Foundry Toolbox and passes its tools to the agent as
7-
* SERVER-SIDE tools. The Foundry platform handles tool discovery and invocation
8-
* through the Responses API — the agent process does not connect to the toolbox
9-
* MCP proxy or invoke tools locally.
6+
* Hosted agent that consumes a Foundry Toolbox as server-side tools. The Agent
7+
* Framework hosting layer connects to the toolbox's managed MCP proxy at startup,
8+
* discovers its tools, and injects them into every request. Tool calls are brokered
9+
* by the Foundry platform's toolbox proxy, so the agent never hard-codes or locally
10+
* executes the tools.
1011
*
1112
* Required environment variables:
1213
* FOUNDRY_PROJECT_ENDPOINT — Foundry project endpoint (auto-injected in hosted containers)
1314
* AZURE_AI_MODEL_DEPLOYMENT_NAME — Model deployment name (declared in agent.manifest.yaml)
1415
* TOOLBOX_NAME — Name of the Foundry Toolbox to load
1516
*/
1617

17-
#pragma warning disable OPENAI001 // GetToolboxToolsAsync is experimental
18+
#pragma warning disable OPENAI001 // Foundry Toolbox hosting APIs are experimental
1819

1920
using Azure.AI.AgentServer.Core;
2021
using Azure.AI.Projects;
@@ -35,23 +36,26 @@
3536
var toolboxName = Environment.GetEnvironmentVariable("TOOLBOX_NAME")
3637
?? throw new InvalidOperationException("TOOLBOX_NAME environment variable is not set.");
3738

38-
// Fetch the toolbox's tools from Foundry. Omitting the version resolves the toolbox's
39-
// current default version. The returned AITools are passed directly to the agent as
40-
// server-side tools — Foundry will execute them on the agent's behalf.
41-
var projectClient = new AIProjectClient(projectEndpoint, new DefaultAzureCredential());
42-
var tools = await projectClient.GetToolboxToolsAsync(toolboxName);
43-
44-
AIAgent agent = projectClient
39+
// Create the agent. No toolbox tools are wired up here: the hosting layer supplies them
40+
// at request time (see AddFoundryToolboxes below).
41+
AIAgent agent = new AIProjectClient(projectEndpoint, new DefaultAzureCredential())
4542
.AsAIAgent(
4643
model: deployment,
4744
instructions: "You are a helpful assistant with access to Azure AI Foundry toolbox tools. "
4845
+ "Use the available tools to help answer user questions. Be concise.",
4946
name: "foundry-toolbox-server-side",
50-
description: "Agent with Foundry Toolbox integration using server-side tools.",
51-
tools: [.. tools]);
47+
description: "Agent with Foundry Toolbox integration using server-side tools.");
5248

5349
var builder = AgentHost.CreateBuilder(args);
5450
builder.Services.AddFoundryResponses(agent);
51+
52+
// Register the Foundry Toolbox. At startup the hosting layer connects to the toolbox's
53+
// managed MCP proxy (derived from FOUNDRY_PROJECT_ENDPOINT), discovers its tools, and
54+
// injects them into every request. Tool calls are brokered by the Foundry platform, so
55+
// the agent process does not hard-code or locally execute the toolbox's tools. Omitting a
56+
// version resolves the toolbox's current default version.
57+
builder.Services.AddFoundryToolboxes(toolboxName);
58+
5559
builder.RegisterProtocol("responses", endpoints => endpoints.MapFoundryResponses());
5660

5761
var app = builder.Build();

samples/csharp/hosted-agents/agent-framework/foundry-toolbox-server-side/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Foundry Toolbox — Server-Side Tools
22

3-
An agent that loads a Foundry Toolbox and passes its tools to the agent as **server-side tools**. The Foundry platform handles tool discovery and invocation through the Responses API — the agent process does not connect to the toolbox MCP proxy or invoke tools locally.
3+
An agent that consumes a Foundry Toolbox as **server-side tools**. The Agent Framework hosting layer connects to the toolbox's managed MCP proxy at startup, discovers its tools, and injects them into every request. Tool calls are brokered by the Foundry platform's toolbox proxy, so the agent never hard-codes or locally executes the tools.
44

5-
`GetToolboxToolsAsync()` fetches the tool definitions from the configured toolbox and they are then passed to `AsAIAgent(..., tools: ...)`. At runtime the Foundry platform invokes those tools server-side on the agent's behalf, so the agent container only needs the control-plane call to fetch the definitions — it does not broker MCP connections.
5+
`AddFoundryToolboxes(toolboxName)` registers the toolbox with the hosting layer. At startup the hosting layer connects to the toolbox's managed MCP proxy (derived from `FOUNDRY_PROJECT_ENDPOINT`), lists its tools, and caches them. Every incoming request then has those tools injected automatically, and the Foundry platform executes the tool calls through the proxy. The agent itself declares no toolbox tools.
66

77
## Creating a Foundry Toolbox
88

samples/csharp/hosted-agents/agent-framework/foundry-toolbox-server-side/agent.manifest.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
name: foundry-toolbox-server-side-dotnet-agent-framework
33
displayName: "Foundry Toolbox — Server-Side Tools (.NET, Agent Framework)"
44
description: >
5-
Agent Framework agent that loads a Foundry Toolbox and passes its tools to the
6-
agent as server-side tools. The Foundry platform executes tool calls through the
7-
Responses API — the agent does not connect to the toolbox MCP proxy locally.
5+
Agent Framework agent that consumes a Foundry Toolbox as server-side tools. The
6+
hosting layer connects to the toolbox's managed MCP proxy at startup and injects its
7+
tools into every request, and the Foundry platform executes the tool calls.
88
metadata:
99
tags:
1010
- AI Agent Hosting

samples/csharp/hosted-agents/agent-framework/foundry-toolbox-server-side/foundry-toolbox-server-side.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
<ItemGroup>
1313
<!-- Agent Framework hosting — provides AgentHost, AddFoundryResponses, MapFoundryResponses,
14-
and the GetToolboxToolsAsync extension on AIProjectClient. -->
15-
<PackageReference Include="Microsoft.Agents.AI.Foundry.Hosting" Version="1.3.0-preview.260423.1" />
14+
and AddFoundryToolboxes for consuming Foundry Toolboxes. -->
15+
<PackageReference Include="Microsoft.Agents.AI.Foundry.Hosting" Version="1.11.0-preview.260623.1" />
1616
<!-- Foundry SDK — provides AIProjectClient and AsAIAgent. -->
17-
<PackageReference Include="Azure.AI.Projects" Version="2.1.0-beta.1" />
17+
<PackageReference Include="Azure.AI.Projects" Version="2.1.0-beta.3" />
1818
<!-- .env file support for local development. -->
1919
<PackageReference Include="DotNetEnv" Version="3.1.1" />
2020
</ItemGroup>

0 commit comments

Comments
 (0)