mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
5fe8941ff9
* dotnet: Add server-side Foundry Toolbox support and fix SDK beta.4 breaking changes Add FoundryToolbox and AIProjectClient extensions to Microsoft.Agents.AI.Foundry.Hosting for server-side toolbox tool integration matching Python's FoundryChatClient.get_toolbox() pattern. Tools are fetched from the Foundry project SDK and passed as server-side tools in the Responses API request. New files: - FoundryToolbox.cs: Core implementation using AgentAdministrationClient SDK - AIProjectClientToolboxExtensions.cs: Extension methods on AIProjectClient - Agent_Step25_ToolboxServerSideTools sample with create helper and combine flow - 19 unit tests covering param validation, conversion, sanitization, and extensions SDK breaking changes (Azure.AI.AgentServer.Responses beta.3 -> beta.4): - FunctionToolCallOutputResource renamed to OutputItemFunctionToolCallOutput - AzureAIAgentServerResponsesModelFactory made internal, replaced with direct constructors - ResponseUsage constructor now requires non-null token details parameters Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: reuse endpoint variable in CreateSampleToolboxAsync Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: pass endpoint through static local functions to avoid capture Static local functions cannot capture top-level variables. Thread the endpoint parameter through Main, CombineToolboxes, and CreateSampleToolboxAsync. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: remove unused projectClient param from CreateSampleToolboxAsync Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step25_ToolboxServerSideTools/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step25_ToolboxServerSideTools/Program.cs Co-authored-by: westey <164392973+westey-m@users.noreply.github.com> * Update dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step25_ToolboxServerSideTools/Program.cs Co-authored-by: westey <164392973+westey-m@users.noreply.github.com> * Removing GetToolbocVersion. * Removing tests for GetToolboxVersion * fix: map cached/reasoning token counts in ConvertUsage instead of hardcoding zeros Extract InputTokenDetails.CachedTokenCount and OutputTokenDetails.ReasoningTokenCount from UsageDetails.AdditionalCounts, matching the pattern in AgentResponseExtensions. Also accumulate detail counts when merging with existing usage. 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> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
5fe8941ff9
·
2026-04-23 18:52:03 +00:00
History
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 |
Running the samples
cd dotnet/samples/02-agents/AgentsWithFoundry
dotnet run --project .\FoundryAgent_Step01