mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Bump Azure.AI.Projects to 2.1.0-alpha; add ToolboxRecord/ToolboxVersion factory overloads + tests
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<PackageVersion Include="Azure.AI.AgentServer.Core" Version="1.0.0-beta.21" />
|
||||
<PackageVersion Include="Azure.AI.AgentServer.Invocations" Version="1.0.0-beta.1" />
|
||||
<PackageVersion Include="Azure.AI.AgentServer.Responses" Version="1.0.0-beta.1" />
|
||||
<PackageVersion Include="Azure.AI.Projects" Version="2.0.0" />
|
||||
<PackageVersion Include="Azure.AI.Projects" Version="2.1.0-alpha.20260417.1" />
|
||||
<PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.10" />
|
||||
<PackageVersion Include="Azure.AI.OpenAI" Version="2.9.0-beta.1" />
|
||||
<PackageVersion Include="Azure.Core" Version="1.53.0" />
|
||||
|
||||
@@ -3,10 +3,16 @@
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="azure-sdk-dev" value="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageSourceMapping>
|
||||
<packageSource key="nuget.org">
|
||||
<package pattern="*" />
|
||||
</packageSource>
|
||||
<packageSource key="azure-sdk-dev">
|
||||
<package pattern="Azure.AI.Projects*" />
|
||||
<package pattern="Azure.AI.AgentServer*" />
|
||||
<package pattern="Azure.AI.Extensions.OpenAI*" />
|
||||
</packageSource>
|
||||
</packageSourceMapping>
|
||||
</configuration>
|
||||
@@ -119,17 +119,43 @@ public static class FoundryAITool
|
||||
/// <param name="toolboxName">The Foundry toolbox name.</param>
|
||||
/// <param name="version">Optional pinned toolbox version. When <see langword="null"/>, the project's default version is used.</param>
|
||||
/// <returns>An <see cref="AITool"/> marker backed by <see cref="HostedMcpToolboxAITool"/>.</returns>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Consumers who already hold a <c>ToolboxRecord</c> or <c>ToolboxVersion</c> from
|
||||
/// <c>Azure.AI.Projects.Agents</c> can pass <c>record.Name</c> together with
|
||||
/// <c>record.DefaultVersion</c> (or <c>version.Name</c>/<c>version.Version</c>) to this
|
||||
/// factory.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
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>
|
||||
|
||||
@@ -93,4 +93,71 @@ public class HostedMcpToolboxAIToolTests
|
||||
Assert.Equal("my-toolbox", marker.ToolboxName);
|
||||
Assert.Equal("v1", marker.Version);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundryAITool_CreateHostedMcpToolbox_FromToolboxRecord_UsesNameAndDefaultVersion()
|
||||
{
|
||||
var record = Azure.AI.Projects.Agents.ProjectsAgentsModelFactory.ToolboxRecord(
|
||||
id: "tbx-123",
|
||||
name: "calendar-tools",
|
||||
defaultVersion: "v2");
|
||||
|
||||
var tool = FoundryAITool.CreateHostedMcpToolbox(record);
|
||||
|
||||
var marker = Assert.IsType<HostedMcpToolboxAITool>(tool);
|
||||
Assert.Equal("calendar-tools", marker.ToolboxName);
|
||||
Assert.Equal("v2", marker.Version);
|
||||
Assert.Equal("foundry-toolbox://calendar-tools?version=v2", marker.ServerAddress);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundryAITool_CreateHostedMcpToolbox_FromToolboxRecord_NullDefaultVersionOmitsQuery()
|
||||
{
|
||||
var record = Azure.AI.Projects.Agents.ProjectsAgentsModelFactory.ToolboxRecord(
|
||||
id: "tbx-abc",
|
||||
name: "finance-tools",
|
||||
defaultVersion: null);
|
||||
|
||||
var tool = FoundryAITool.CreateHostedMcpToolbox(record);
|
||||
|
||||
var marker = Assert.IsType<HostedMcpToolboxAITool>(tool);
|
||||
Assert.Equal("finance-tools", marker.ToolboxName);
|
||||
Assert.Null(marker.Version);
|
||||
Assert.Equal("foundry-toolbox://finance-tools", marker.ServerAddress);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundryAITool_CreateHostedMcpToolbox_FromToolboxRecord_Null_Throws()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => FoundryAITool.CreateHostedMcpToolbox((Azure.AI.Projects.Agents.ToolboxRecord)null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundryAITool_CreateHostedMcpToolbox_FromToolboxVersion_UsesNameAndVersion()
|
||||
{
|
||||
var version = Azure.AI.Projects.Agents.ProjectsAgentsModelFactory.ToolboxVersion(
|
||||
metadata: null,
|
||||
id: "ver-1",
|
||||
name: "hr-tools",
|
||||
version: "2025-09-01",
|
||||
description: "HR toolbox",
|
||||
createdAt: DateTimeOffset.UtcNow,
|
||||
tools: null,
|
||||
policies: null);
|
||||
|
||||
var tool = FoundryAITool.CreateHostedMcpToolbox(version);
|
||||
|
||||
var marker = Assert.IsType<HostedMcpToolboxAITool>(tool);
|
||||
Assert.Equal("hr-tools", marker.ToolboxName);
|
||||
Assert.Equal("2025-09-01", marker.Version);
|
||||
Assert.Equal("foundry-toolbox://hr-tools?version=2025-09-01", marker.ServerAddress);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FoundryAITool_CreateHostedMcpToolbox_FromToolboxVersion_Null_Throws()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => FoundryAITool.CreateHostedMcpToolbox((Azure.AI.Projects.Agents.ToolboxVersion)null!));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user