Split Foundry into stable V1 and preview Hosting package

Extract hosted agent functionality from Microsoft.Agents.AI.Foundry into a
new Microsoft.Agents.AI.Foundry.Hosting preview package. This resolves NU5104
build errors caused by the stable Foundry package depending on prerelease
Azure SDK packages (Azure.AI.AgentServer.Responses, Azure.AI.Projects beta).

Changes:
- Create Microsoft.Agents.AI.Foundry.Hosting with VersionSuffix=preview,
  targeting .NET Core only (net8.0/9.0/10.0)
- Move all Hosting/ source files to the new project
- Move ToolboxRecord/ToolboxVersion overloads to FoundryAIToolExtensions
- Revert Azure.AI.Projects to 2.0.0 in Directory.Packages.props;
  Hosting uses VersionOverride for 2.1.0-beta.1
- Clean V1 Foundry csproj: remove beta deps, ASP.NET Core ref, hosting conditionals
- Update 8 hosted agent sample projects to reference Foundry.Hosting
- Split unit tests: ToolboxRecord/ToolboxVersion tests moved to Hosting/
- Add Foundry.Hosting to solution file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
alliscode
2026-04-21 11:56:41 -07:00
Unverified
parent a828f3463c
commit a01e3f14b2
28 changed files with 208 additions and 131 deletions
@@ -0,0 +1,48 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using Azure.AI.Projects.Agents;
using Microsoft.Extensions.AI;
namespace Microsoft.Agents.AI.Foundry.Hosting;
/// <summary>
/// Extension methods for <see cref="FoundryAITool"/> that require Azure.AI.Projects 2.1.0-beta.1+
/// types (e.g. <see cref="ToolboxRecord"/>, <see cref="ToolboxVersion"/>).
/// </summary>
public static class FoundryAIToolExtensions
{
/// <summary>
/// Creates an <see cref="AITool"/> marker from a <see cref="ToolboxRecord"/> retrieved
/// from <c>AIProjectClient</c>. Uses <see cref="ToolboxRecord.Name"/> and
/// <see cref="ToolboxRecord.DefaultVersion"/>.
/// </summary>
/// <param name="toolbox">The toolbox record.</param>
/// <returns>An <see cref="AITool"/> marker backed by <see cref="HostedMcpToolboxAITool"/>.</returns>
public static AITool CreateHostedMcpToolbox(ToolboxRecord toolbox)
{
if (toolbox is null)
{
throw new ArgumentNullException(nameof(toolbox));
}
return new HostedMcpToolboxAITool(toolbox.Name, toolbox.DefaultVersion);
}
/// <summary>
/// Creates an <see cref="AITool"/> marker from a specific <see cref="ToolboxVersion"/>
/// retrieved from <c>AIProjectClient</c>. Uses <see cref="ToolboxVersion.Name"/> and
/// <see cref="ToolboxVersion.Version"/>.
/// </summary>
/// <param name="toolboxVersion">The toolbox version.</param>
/// <returns>An <see cref="AITool"/> marker backed by <see cref="HostedMcpToolboxAITool"/>.</returns>
public static AITool CreateHostedMcpToolbox(ToolboxVersion toolboxVersion)
{
if (toolboxVersion is null)
{
throw new ArgumentNullException(nameof(toolboxVersion));
}
return new HostedMcpToolboxAITool(toolboxVersion.Name, toolboxVersion.Version);
}
}
@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TargetFrameworksCore)</TargetFrameworks>
<RootNamespace>Microsoft.Agents.AI.Foundry.Hosting</RootNamespace>
<VersionSuffix>preview</VersionSuffix>
<Title>Microsoft Agent Framework for Foundry Hosted Agents</Title>
<Description>Provides Microsoft Agent Framework support for hosting Foundry Agents with the Azure AI Agent Service.</Description>
</PropertyGroup>
<PropertyGroup>
<InjectSharedThrow>true</InjectSharedThrow>
<InjectSharedDiagnosticIds>true</InjectSharedDiagnosticIds>
<InjectExperimentalAttributeOnLegacy>true</InjectExperimentalAttributeOnLegacy>
<InjectSharedRedaction>true</InjectSharedRedaction>
<NoWarn>$(NoWarn);OPENAI001;MEAI001;NU1903</NoWarn> <!-- NU1903: Microsoft.Bcl.Memory 9.0.4 transitive vulnerability via Azure SDK; awaiting upstream fix -->
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<Import Project="$(RepoRoot)/dotnet/nuget/nuget-package.props" />
<!-- Disable package validation baseline until the first release -->
<PropertyGroup>
<PackageValidationBaselineVersion />
<EnablePackageValidation>false</EnablePackageValidation>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.AI.AgentServer.Responses" />
<PackageReference Include="Azure.AI.Projects" VersionOverride="2.1.0-beta.1" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="ModelContextProtocol" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Agents.AI.Foundry\Microsoft.Agents.AI.Foundry.csproj" />
<ProjectReference Include="..\Microsoft.Agents.AI.Abstractions\Microsoft.Agents.AI.Abstractions.csproj" />
<ProjectReference Include="..\Microsoft.Agents.AI.Workflows\Microsoft.Agents.AI.Workflows.csproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.Agents.AI.Foundry.UnitTests" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>
</Project>
@@ -122,40 +122,6 @@ public static class FoundryAITool
public static AITool CreateHostedMcpToolbox(string toolboxName, string? version = null)
=> new HostedMcpToolboxAITool(toolboxName, version);
/// <summary>
/// Creates an <see cref="AITool"/> marker from a <see cref="ToolboxRecord"/> retrieved
/// from <c>AIProjectClient</c>. Uses <see cref="ToolboxRecord.Name"/> and
/// <see cref="ToolboxRecord.DefaultVersion"/>.
/// </summary>
/// <param name="toolbox">The toolbox record.</param>
/// <returns>An <see cref="AITool"/> marker backed by <see cref="HostedMcpToolboxAITool"/>.</returns>
public static AITool CreateHostedMcpToolbox(ToolboxRecord toolbox)
{
if (toolbox is null)
{
throw new ArgumentNullException(nameof(toolbox));
}
return new HostedMcpToolboxAITool(toolbox.Name, toolbox.DefaultVersion);
}
/// <summary>
/// Creates an <see cref="AITool"/> marker from a specific <see cref="ToolboxVersion"/>
/// retrieved from <c>AIProjectClient</c>. Uses <see cref="ToolboxVersion.Name"/> and
/// <see cref="ToolboxVersion.Version"/>.
/// </summary>
/// <param name="toolboxVersion">The toolbox version.</param>
/// <returns>An <see cref="AITool"/> marker backed by <see cref="HostedMcpToolboxAITool"/>.</returns>
public static AITool CreateHostedMcpToolbox(ToolboxVersion toolboxVersion)
{
if (toolboxVersion is null)
{
throw new ArgumentNullException(nameof(toolboxVersion));
}
return new HostedMcpToolboxAITool(toolboxVersion.Name, toolboxVersion.Version);
}
// --- OpenAI SDK ResponseTool factories ---
/// <summary>
@@ -3,8 +3,7 @@
<PropertyGroup>
<IsReleased>true</IsReleased>
<InjectSharedThrow>true</InjectSharedThrow>
<NoWarn>$(NoWarn);OPENAI001;MEAI001;NU1903</NoWarn> <!-- NU1903: Microsoft.Bcl.Memory 9.0.4 transitive vulnerability via Azure SDK; awaiting upstream fix -->
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
<NoWarn>$(NoWarn);OPENAI001;MEAI001</NoWarn>
</PropertyGroup>
<Import Project="$(RepoRoot)/dotnet/nuget/nuget-package.props" />
@@ -21,10 +20,6 @@
<InjectSharedRedaction>true</InjectSharedRedaction>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.AI.Projects" />
<PackageReference Include="Microsoft.Extensions.AI" />
@@ -34,12 +29,6 @@
<PackageReference Include="OpenAI" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<PackageReference Include="Azure.AI.AgentServer.Responses" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="ModelContextProtocol" />
</ItemGroup>
<!-- Evaluation support requires net8.0+ (MEAI.Evaluation does not support legacy TFMs) -->
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<PackageReference Include="Microsoft.Extensions.AI.Evaluation" />
@@ -56,11 +45,6 @@
<ProjectReference Include="..\Microsoft.Agents.AI\Microsoft.Agents.AI.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<ProjectReference Include="..\Microsoft.Agents.AI.Abstractions\Microsoft.Agents.AI.Abstractions.csproj" />
<ProjectReference Include="..\Microsoft.Agents.AI.Workflows\Microsoft.Agents.AI.Workflows.csproj" />
</ItemGroup>
<PropertyGroup>
<!-- NuGet Package Settings -->
<Title>Microsoft Agent Framework for Foundry Agents</Title>
@@ -72,9 +56,4 @@
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<!-- Hosting code requires .NET Core (ASP.NET Core + Azure.AI.AgentServer.Responses) -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<Compile Remove="Hosting\**" />
</ItemGroup>
</Project>