Update Foundry agent builder APIs#17499
Merged
sebastienros merged 7 commits intoMay 26, 2026
Merged
Conversation
Reorder AddPromptAgent parameters so the resource name comes before the model deployment, and rename the hosted-agent publishing extension to WithComputeEnvironment across C#, ATS, docs, samples, and polyglot validation apphosts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17499Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17499" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Aspire Hosting Foundry “agent builder” APIs to better match established AppHost conventions: the prompt-agent builder now takes the resource name before dependent resources, and hosted-agent publishing is renamed to the existing “compute environment” pattern.
Changes:
- Reordered
AddPromptAgentparameters from(model, name, …)to(name, model, …)and updated call sites/tests. - Renamed hosted-agent publishing from
PublishAsHostedAgent(...)/publishAsHostedAgent(...)toWithComputeEnvironment(...)/withComputeEnvironment(...)across C#, ATS, docs, samples, and polyglot validation apphosts. - Updated deployment/E2E tests, Azure deployer tests, and playground samples to use the new API names.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/PolyglotAppHosts/Aspire.Hosting.Foundry/TypeScript/apphost.mts | Updates TS polyglot validation apphost to call withComputeEnvironment. |
| tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Python/apphost.py | Updates Python polyglot validation apphost to call with_compute_environment. |
| tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Java/AppHost.java | Updates Java polyglot validation apphost to call withComputeEnvironment. |
| tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Go/apphost.go | Updates Go polyglot validation apphost to call WithComputeEnvironment. |
| tests/Aspire.Hosting.Foundry.Tests/PromptAgentTests.cs | Updates tests for the new AddPromptAgent(name, model, …) signature. |
| tests/Aspire.Hosting.Foundry.Tests/HostedAgentExtensionTests.cs | Renames tests to match WithComputeEnvironment and adjusts call sites. |
| tests/Aspire.Hosting.Azure.Tests/FoundryExtensionsTests.cs | Updates Azure integration tests to use WithComputeEnvironment for Foundry hosted agents. |
| tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs | Updates deployer tests to use the new hosted-agent method name. |
| tests/Aspire.Deployment.EndToEnd.Tests/FoundryHostedAgentDeploymentTests.cs | Updates E2E deployment test content/comments and call sites for the rename. |
| src/Aspire.Hosting.Foundry/README.md | Updates README usage snippet to WithComputeEnvironment(project). |
| src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentBuilderExtensions.cs | Updates XML docs/example and signature for AddPromptAgent(name, model, …). |
| src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs | Renames the hosted-agent extension to WithComputeEnvironment and updates ATS export name. |
| src/Aspire.Hosting.Foundry/api/Aspire.Hosting.Foundry.ats.txt | Updates ATS surface to export withComputeEnvironmentExecutable. |
| playground/FoundryAgents/FoundryAgents.AppHost/AppHost.cs | Updates playground AppHost to the new Foundry APIs and sample resource names. |
| playground/FoundryAgents/DotNetHostedAgent/Program.cs | Updates env var names/error strings to match new playground project resource name. |
| playground/FoundryAgents/app/main.py | Updates env var lookup to match new playground project resource name. |
| playground/FoundryAgentEnterprise/FoundryAgentEnterprise.AppHost/AppHost.cs | Updates enterprise playground AppHost call site to WithComputeEnvironment. |
Document the run-mode effects of WithComputeEnvironment, update the Foundry public API surface for the hosted-agent rename and prompt-agent parameter order, and restore coverage for omitted project creation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update Foundry validation apphosts to use the new AddPromptAgent name-first parameter order across TypeScript, Java, Go, and Python. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
@sebastienros send changes to @tommasodotNET's branch. We need to get this in today. |
Contributor
|
I need a raise |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sebastienros
approved these changes
May 26, 2026
radical
added a commit
that referenced
this pull request
Jun 6, 2026
Replayed the 161 PRs merged to main between 2026-05-23 and 2026-06-06
through the audit selector. v1 (the prior file) resolved 89/161 PRs to
'selective' and dropped 26/161 to 'fallback_unmatched' (any unmatched
file forces RunAll). After this change all 161 PRs classify cleanly:
18 skip, 32 trigger_all, 111 selective, 0 fallback.
Additions:
* ignorePaths — files that never need a test gate but were forcing
fallback today: .vscode/**, .mcp.json, localhive.{sh,ps1},
.github/{extensions,policies,aw}/**, .agents/** (CLI agent skill
content, consumed only by humans/agents), eng/scripts/debug-*.{sh,ps1}
(developer-loop helpers), eng/scripts/cli-starter-validation*.ps1
(consumed by the always-on cli_starter_validation_windows job, which
isn't conditional-selector-gated).
* sourceToTestMappings — scripts and infra files that have a specific
test home but weren't wired up: eng/Publishing.props,
eng/Signing.props, eng/scripts/{pack,stage,verify,validate}-cli-*
and tools/TypeScriptApiCompat/** all map to Infrastructure.Tests
(its Pipelines/ and PowerShellScripts/ folders test these scripts).
eng/scripts/get-aspire-cli{,-pr}.{sh,ps1}, eng/scripts/verify-cli-archive.ps1,
eng/homebrew/** and eng/winget/** map to Aspire.Acquisition.Tests
(the script-suite that exercises them). eng/scripts/update-aspire-
skills-bundle.ps1 + verify-aspire-skills-bundle.ps1 map to
Aspire.Cli.Tests (AspireSkillsBundleTests). Two self-mappings for
tests directories without a 'tests/Aspire.*.Tests/**' shape:
tests/Infrastructure.Tests/** and
tests/Aspire.Hosting.CodeGeneration.TypeScript.JsTests/**.
* polyglot.triggerPaths — expanded beyond the workflow file itself to
cover the polyglot fixture tree (tests/PolyglotAppHosts/**) and the
per-language Aspire.Hosting.{JavaScript,TypeScript,Python,Go,Java,Rust}
+ CodeGeneration* projects. Without these, polyglot-impacting PRs
(#17545, #17499, #17419, #17400, #17382) all fell into RunAll.
Local verification: 251 TestSelector/PowerShellScripts/ConditionalSelection
tests still pass. The CI-trigger-pattern coverage test (which loads this
file from disk) is unchanged because we only added to ignorePaths and
sourceToTestMappings — no existing entries were removed or narrowed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Foundry agent builder APIs should follow the same AppHost conventions as the rest of Aspire. This updates the prompt-agent API so the resource name comes before dependent resources, and renames hosted-agent publishing to use the existing compute-environment pattern.
User-facing usage
C# AppHost:
TypeScript AppHost:
The hosted-agent implementation still configures the same Foundry deployment behavior; the API name now matches the
WithComputeEnvironment(...)shape used for other deployment targets. Polyglot validation apphosts, the ATS surface, and the public API baseline were updated to use the new hosted-agent method name.Breaking changes
This changes preview Foundry APIs:
AddPromptAgent(model, name, ...)is nowAddPromptAgent(name, model, ...).PublishAsHostedAgent(project, ...)is nowWithComputeEnvironment(project, ...).AsHostedAgent(...)andRunAsHostedAgent(...)preview APIs were removed from the public API surface. They only threwNotImplementedException.Users should update existing AppHost code to the new parameter order and method name.
Validation
dotnet test --project tests/Aspire.Hosting.Foundry.Tests/Aspire.Hosting.Foundry.Tests.csproj --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet test --project tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-class "*.FoundryExtensionsTests" --filter-class "*.AzureDeployerTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"Fixes #16707
Checklist
<remarks />and<code />elements on your triple slash comments?