Skip to content

Commit aad20c2

Browse files
authored
.NET: Bump Azure.AI.Projects to 2.1.0-beta.2 and add agent-endpoint AsAIAgent path (microsoft#5899)
* .NET: Bump Azure.AI.Projects to 2.1.0-beta.2 and add agent-endpoint AsAIAgent path Bumps Azure.AI.Projects to 2.1.0-beta.2 with the matching transitive pins (Azure.Core 1.55.0, System.ClientModel 1.11.0). Foundry agent endpoint plumbing: * FoundryAgent now routes the agent-endpoint constructor through the new GetProjectResponsesClientForAgentEndpoint helper. * Adds an internal FoundryAgent ctor that takes an existing AIProjectClient plus a parsed agent endpoint so the public extension does not need to construct a second project client. * Adds public AIProjectClient.AsAIAgent(Uri agentEndpoint, ...) extension. This is the path consumer samples are expected to use for hosted agents because version selection happens server-side. * Trims the dangling "If you want to construct a FoundryAgent against a project endpoint..." sentence from ParseAgentEndpoint. Unit tests: * Four new tests in AzureAIProjectChatClientExtensionsTests cover the AIProjectClient.AsAIAgent(Uri agentEndpoint, ...) overload. 263/263 pass. Consumer samples (Using-Samples): * SimpleAgent and SessionFilesClient now read AZURE_AI_PROJECT_ENDPOINT and AZURE_AI_AGENT_NAME (both required, throw on missing), derive the agent endpoint with new Uri($"{projectEndpoint}/agents/{agentName}/endpoint/protocols/openai"), then call aiProjectClient.AsAIAgent(agentEndpoint, ...). * SessionFilesClient README updated. Contributor samples (responses/*): * New HostedContributorRouteExtensions.MapDevTemporaryLocalAgentEndpoint() wildcard route extension so localhost contributor servers accept the per-agent OpenAI endpoint shape the production Hosted runtime exposes. * All 11 contributor Program.cs files call MapDevTemporaryLocalAgentEndpoint() with a contributor-only warning comment. * Hosted-Files and Hosted-AzureSearchRag were importing Hosted_Shared_Contributor_Setup but never calling AddDevTemporaryLocalContributorSetup(). Both now call it so HostedSessionIsolationKeyProvider resolves correctly in dev. * Hosted-AzureSearchRag, Hosted-Files, Hosted-MemoryAgent csprojs drop stale VersionOverride="2.1.0-beta.1" pins. * Hosted-AzureSearchRag and Hosted-Files csprojs add ProjectReference to Hosted_Shared_Contributor_Setup. * Hosted-Observability/.dockerignore removed the out/ exclusion that was blocking COPY out/ . in Dockerfile.contributor. Verified: * Full solution-scoped build of changed projects: green. * Scoped CI-parity dotnet format via WSL2 + Docker (mcr.microsoft.com/dotnet/sdk:10.0) over every changed csproj: clean. * Foundry unit tests: 263/263. * Contributor docker smoke for 8 hosted samples (publish + docker build + docker run + curl POST to the wildcard route): HTTP 200 / 500 with route matched. * End-to-end smoke against the real Azure Foundry project with a fresh bearer token: Hosted-Files contributor container served HTTP 200, the agent invoked ListBundledFiles, and returned the expected file name. * Address PR review: forward pipeline settings; add UTs - CreateProjectClientOptions also carries RetryPolicy, NetworkTimeout, ClientLoggingOptions, MessageLoggingPolicy (was Transport+UserAgentApplicationId only). - Make CreateProjectClientOptions internal so tests can verify the copy directly. - Add AsAIAgent(Uri) UTs covering tools forwarding to inner ChatOptions and null tools handling. - Add CreateProjectClientOptions UTs covering null caller and full pipeline-settings copy.
1 parent dff23a9 commit aad20c2

25 files changed

Lines changed: 469 additions & 198 deletions

File tree

‎dotnet/Directory.Packages.props‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
<PackageVersion Include="Azure.AI.AgentServer.Invocations" Version="1.0.0-beta.3" />
2727
<PackageVersion Include="Azure.AI.AgentServer.Responses" Version="1.0.0-beta.4" />
2828
<PackageVersion Include="Azure.Search.Documents" Version="12.0.0" />
29-
<PackageVersion Include="Azure.AI.Projects" Version="2.1.0-beta.1" />
29+
<PackageVersion Include="Azure.AI.Projects" Version="2.1.0-beta.2" />
3030
<PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.10" />
3131
<PackageVersion Include="Azure.AI.OpenAI" Version="2.9.0-beta.1" />
32-
<PackageVersion Include="Azure.Core" Version="1.53.0" />
32+
<PackageVersion Include="Azure.Core" Version="1.55.0" />
3333
<PackageVersion Include="Azure.Identity" Version="1.21.0" />
3434
<PackageVersion Include="DotNetEnv" Version="3.1.1" />
3535
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.5.0" />
@@ -44,7 +44,7 @@
4444
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.6" />
4545
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
4646
<PackageVersion Include="Microsoft.Bcl.Memory" Version="10.0.5" />
47-
<PackageVersion Include="System.ClientModel" Version="1.10.0" />
47+
<PackageVersion Include="System.ClientModel" Version="1.11.0" />
4848
<PackageVersion Include="System.CodeDom" Version="10.0.0" />
4949
<PackageVersion Include="System.Collections.Immutable" Version="10.0.1" />
5050
<PackageVersion Include="System.CommandLine" Version="2.0.0-rc.2.25502.107" />

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csproj‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Azure.AI.Projects" VersionOverride="2.1.0-beta.1" />
14+
<PackageReference Include="Azure.AI.Projects" />
1515
<PackageReference Include="Azure.Identity" />
1616
<PackageReference Include="Azure.Search.Documents" />
1717
<PackageReference Include="DotNetEnv" />
@@ -22,6 +22,7 @@
2222
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.Foundry\Microsoft.Agents.AI.Foundry.csproj" />
2323
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.Foundry.Hosting\Microsoft.Agents.AI.Foundry.Hosting.csproj" />
2424
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.OpenAI\Microsoft.Agents.AI.OpenAI.csproj" />
25+
<ProjectReference Include="..\Hosted_Shared_Contributor_Setup\Hosted_Shared_Contributor_Setup.csproj" />
2526
</ItemGroup>
2627

2728
<!-- For end-users: uncomment the PackageReference below and remove the ProjectReferences above

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/Program.cs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Azure.Search.Documents;
1515
using Azure.Search.Documents.Models;
1616
using DotNetEnv;
17+
using Hosted_Shared_Contributor_Setup;
1718
using Microsoft.Agents.AI;
1819
using Microsoft.Agents.AI.Foundry.Hosting;
1920
using Microsoft.Extensions.AI;
@@ -66,14 +67,15 @@
6667
// Host the agent as a Foundry Hosted Agent using the Responses API.
6768
var builder = WebApplication.CreateBuilder(args);
6869
builder.Services.AddFoundryResponses(agent);
70+
builder.Services.AddDevTemporaryLocalContributorSetup(); // Local Docker debugging only - must not be used in production.
6971

7072
var app = builder.Build();
7173
app.MapFoundryResponses();
7274

73-
if (app.Environment.IsDevelopment())
74-
{
75-
app.MapFoundryResponses("openai/v1");
76-
}
75+
// Contributor-only: in Development, also map the per-agent OpenAI route shape that live Foundry uses
76+
// so a local REPL client can target this server via AIProjectClient.AsAIAgent(Uri agentEndpoint).
77+
// Do not use this in production. Hosted Foundry agents only support the agent-endpoint path.
78+
app.MapDevTemporaryLocalAgentEndpoint();
7779

7880
app.Run();
7981

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/Program.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ You are a helpful AI assistant hosted as a Foundry Hosted Agent.
4646
var app = builder.Build();
4747
app.MapFoundryResponses();
4848

49-
// In Development, also map the OpenAI-compatible route that AIProjectClient uses.
50-
if (app.Environment.IsDevelopment())
51-
{
52-
app.MapFoundryResponses("openai/v1");
53-
}
49+
// Contributor-only: in Development, also map the per-agent OpenAI route shape that live Foundry uses
50+
// so a local REPL client can target this server via AIProjectClient.AsAIAgent(Uri agentEndpoint).
51+
// Do not use this in production. Hosted Foundry agents only support the agent-endpoint path.
52+
app.MapDevTemporaryLocalAgentEndpoint();
5453

5554
app.Run();

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/HostedFiles.csproj‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFrameworks>net10.0</TargetFrameworks>
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Azure.AI.Projects" VersionOverride="2.1.0-beta.1" />
14+
<PackageReference Include="Azure.AI.Projects" />
1515
<PackageReference Include="Azure.Identity" />
1616
<PackageReference Include="DotNetEnv" />
1717
</ItemGroup>
@@ -28,6 +28,7 @@
2828
<ItemGroup>
2929
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.Foundry\Microsoft.Agents.AI.Foundry.csproj" />
3030
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.Foundry.Hosting\Microsoft.Agents.AI.Foundry.Hosting.csproj" />
31+
<ProjectReference Include="..\Hosted_Shared_Contributor_Setup\Hosted_Shared_Contributor_Setup.csproj" />
3132
</ItemGroup>
3233

3334
<!-- For end-users: uncomment the PackageReference below and remove the ProjectReference above

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/Program.cs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
using Azure.Core;
3636
using Azure.Identity;
3737
using DotNetEnv;
38+
using Hosted_Shared_Contributor_Setup;
3839
using Microsoft.Agents.AI;
3940
using Microsoft.Agents.AI.Foundry.Hosting;
4041
using Microsoft.Extensions.AI;
@@ -175,14 +176,15 @@ numbers and figures verbatim from the file.
175176

176177
var builder = WebApplication.CreateBuilder(args);
177178
builder.Services.AddFoundryResponses(agent);
179+
builder.Services.AddDevTemporaryLocalContributorSetup(); // Local Docker debugging only - must not be used in production.
178180

179181
var app = builder.Build();
180182
app.MapFoundryResponses();
181183

182-
if (app.Environment.IsDevelopment())
183-
{
184-
app.MapFoundryResponses("openai/v1");
185-
}
184+
// Contributor-only: in Development, also map the per-agent OpenAI route shape that live Foundry uses
185+
// so a local REPL client can target this server via AIProjectClient.AsAIAgent(Uri agentEndpoint).
186+
// Do not use this in production. Hosted Foundry agents only support the agent-endpoint path.
187+
app.MapDevTemporaryLocalAgentEndpoint();
186188

187189
app.Run();
188190

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/Program.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@
3939
var app = builder.Build();
4040
app.MapFoundryResponses();
4141

42-
// In Development, also map the OpenAI-compatible route that AIProjectClient uses.
43-
if (app.Environment.IsDevelopment())
44-
{
45-
app.MapFoundryResponses("openai/v1");
46-
}
42+
// Contributor-only: in Development, also map the per-agent OpenAI route shape that live Foundry uses
43+
// so a local REPL client can target this server via AIProjectClient.AsAIAgent(Uri agentEndpoint).
44+
// Do not use this in production. Hosted Foundry agents only support the agent-endpoint path.
45+
app.MapDevTemporaryLocalAgentEndpoint();
4746

4847
app.Run();

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/Program.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ politely let them know you specialize in Seattle hotel recommendations.
118118
var app = builder.Build();
119119
app.MapFoundryResponses();
120120

121-
if (app.Environment.IsDevelopment())
122-
{
123-
app.MapFoundryResponses("openai/v1");
124-
}
121+
// Contributor-only: in Development, also map the per-agent OpenAI route shape that live Foundry uses
122+
// so a local REPL client can target this server via AIProjectClient.AsAIAgent(Uri agentEndpoint).
123+
// Do not use this in production. Hosted Foundry agents only support the agent-endpoint path.
124+
app.MapDevTemporaryLocalAgentEndpoint();
125125

126126
app.Run();
127127

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/Program.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ Be concise and provide direct answers with relevant links.
8787
var app = builder.Build();
8888
app.MapFoundryResponses();
8989

90-
// In Development, also map the OpenAI-compatible route that AIProjectClient uses.
91-
if (app.Environment.IsDevelopment())
92-
{
93-
app.MapFoundryResponses("openai/v1");
94-
}
90+
// Contributor-only: in Development, also map the per-agent OpenAI route shape that live Foundry uses
91+
// so a local REPL client can target this server via AIProjectClient.AsAIAgent(Uri agentEndpoint).
92+
// Do not use this in production. Hosted Foundry agents only support the agent-endpoint path.
93+
app.MapDevTemporaryLocalAgentEndpoint();
9594

9695
app.Run();

‎dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-MemoryAgent/HostedMemoryAgent.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Azure.AI.Projects" VersionOverride="2.1.0-beta.1" />
14+
<PackageReference Include="Azure.AI.Projects" />
1515
<PackageReference Include="Azure.Identity" />
1616
<PackageReference Include="DotNetEnv" />
1717
</ItemGroup>

0 commit comments

Comments
 (0)