Skip to content

Update Foundry hosted agent builder APIs#17545

Open
tommasodotNET wants to merge 5 commits into
microsoft:mainfrom
tommasodotNET:fix/foundry-apis
Open

Update Foundry hosted agent builder APIs#17545
tommasodotNET wants to merge 5 commits into
microsoft:mainfrom
tommasodotNET:fix/foundry-apis

Conversation

@tommasodotNET
Copy link
Copy Markdown
Contributor

@tommasodotNET tommasodotNET commented May 27, 2026

Description

Updates the Foundry hosted agent builder APIs so run-mode hosted agent endpoint and command configuration can be applied separately from publish-mode compute environment setup.

User-facing usage

Consumers now opt a compute resource into the local run-mode hosted agent experience with AsHostedAgent() and configure the publish-mode Foundry deployment with WithComputeEnvironment(...):

builder.AddProject<Projects.AgentService>("agent")
       .AsHostedAgent()
       .WithComputeEnvironment(project);

WithComputeEnvironment(...) keeps the publish-mode hosted agent deployment wiring focused on Azure Foundry compute environment setup.

Validation:

./restore.sh
dotnet build src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj --no-restore
dotnet test --project tests/Aspire.Hosting.Foundry.Tests/Aspire.Hosting.Foundry.Tests.csproj --no-launch-profile -- --filter-class "*.HostedAgentExtensionTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
dotnet test --project tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
dotnet test --project tests/Infrastructure.Tests/Infrastructure.Tests.csproj --no-launch-profile -- --filter-class "*.TypeScriptApiCompatTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
dotnet build playground/FoundryAgents/FoundryAgents.AppHost/FoundryAgents.AppHost.csproj --no-restore
dotnet build playground/FoundryAgentEnterprise/FoundryAgentEnterprise.AppHost/FoundryAgentEnterprise.AppHost.csproj --no-restore

Focused polyglot validation with the repo CLI:

dotnet run --project src/Aspire.Cli/Aspire.Cli.csproj -- restore --non-interactive --apphost apphost.mts
npx --yes @typescript/native-preview --noEmit --project tsconfig.json

dotnet run --project src/Aspire.Cli/Aspire.Cli.csproj -- restore --non-interactive --apphost apphost.go
go build -buildvcs=false ./...

dotnet run --project src/Aspire.Cli/Aspire.Cli.csproj -- restore --non-interactive --apphost AppHost.java

Java compile validation was not run locally because the available JDK is 17 and the validation script requires javac --source 25.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17545

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17545"

@tommasodotNET tommasodotNET marked this pull request as ready for review May 27, 2026 21:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Splits the Foundry hosted-agent builder API so that run-mode endpoint/command/OTEL wiring is opted into via a new AsHostedAgent() method, while WithComputeEnvironment(...) is reduced to publish-mode Foundry compute environment setup only. Updates polyglot exports, tests, and playgrounds to use the new shape.

Changes:

  • Introduces AsHostedAgent<T>() containing the prior run-mode wiring (HTTP endpoint, Responses URL, Send Message command, OTEL env vars); removes the liveness/readiness probe URLs and WithHttpHealthCheck("/liveness") it previously added.
  • Limits both WithComputeEnvironment<T> overloads to publish-mode behavior only (creates/locates the Foundry project, wires AzureHostedAgentResource + DeploymentTargetAnnotation).
  • Updates API surface (Aspire.Hosting.Foundry.cs, *.ats.txt), polyglot apphosts, playgrounds, deployment E2E test, and unit tests to chain .AsHostedAgent() before .WithComputeEnvironment(...).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs Splits previous combined extension into publish-only WithComputeEnvironment and new run-only AsHostedAgent; drops liveness/readiness URL annotations and health check.
src/Aspire.Hosting.Foundry/api/Aspire.Hosting.Foundry.cs Adds AsHostedAgent<T> to public API ref.
src/Aspire.Hosting.Foundry/api/Aspire.Hosting.Foundry.ats.txt Adds asHostedAgent() and withComputeEnvironmentExecutable(...) polyglot export entries.
tests/Aspire.Hosting.Foundry.Tests/HostedAgentExtensionTests.cs Renames/updates run-mode tests to call AsHostedAgent(); replaces health-check assertion with Send Message command assertion.
tests/Aspire.Deployment.EndToEnd.Tests/FoundryHostedAgentDeploymentTests.cs Chains .AsHostedAgent() before .WithComputeEnvironment(...).
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/TypeScript/apphost.mts Adds await hostedAgent.asHostedAgent(); in the polyglot scenario.
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Java/AppHost.java Adds hostedAgent.asHostedAgent(); call.
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Go/apphost.go Adds hostedAgent.AsHostedAgent() call.
playground/FoundryAgents/FoundryAgents.AppHost/AppHost.cs Inserts .AsHostedAgent() before .WithComputeEnvironment(project) on both hosted agents.
playground/FoundryAgentEnterprise/FoundryAgentEnterprise.AppHost/AppHost.cs Inserts .AsHostedAgent() in the enterprise playground apphost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants