Skip to content

[release/13.4] Update Foundry hosted agent builder APIs#17669

Merged
davidfowl merged 15 commits into
release/13.4from
backport/pr-17545-to-release/13.4
May 29, 2026
Merged

[release/13.4] Update Foundry hosted agent builder APIs#17669
davidfowl merged 15 commits into
release/13.4from
backport/pr-17545-to-release/13.4

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

Backport of #17545 to release/13.4

/cc @tommasodotNET

Customer Impact

Customers using Aspire Foundry hosted agents get the updated project-first API and correct hosted-agent deployment configuration behavior. Local run mode no longer creates an unnecessary default Azure Container Registry resource.

Testing

  • Aspire.Hosting.Foundry.Tests: 92/92 passing on the release/13.4 backport branch.
  • Source PR updated Foundry Azure/deployment/polyglot coverage and generated baselines.

Risk

Low. The changes are localized to Aspire.Hosting.Foundry hosted-agent/project APIs and generated polyglot/API baselines, but they do affect public/generated API surface.

Regression?

No.

tommasodotNET and others added 15 commits May 29, 2026 09:23
Consolidate AsHostedAgent usage, update Foundry icons and command rendering, and refresh playgrounds, samples, and tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Conditionally require/provision Foundry project ACR only for hosted-agent publish or explicit registry override, add regression tests for run/publish paths, and align PromptAgent Send Message icon with ChatSparkle.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid allocating a fresh JsonSerializerOptions per Send Message command
invocation, which also defeats JsonSerializer's per-options metadata cache.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- AsHostedAgent(project, HostedAgentOptions?) is now the polyglot-exported overload
- Action<HostedAgentConfiguration> overload kept as .NET-only for advanced use
- HostedAgentOptions exposes Description, Cpu, Memory, Metadata, EnvironmentVariables
- Polyglot users now get .asHostedAgent(project, { ... }) instead of
  .asHostedAgent({ project, configure: async cfg => ... })
- Updated TypeScript, Go, and Java polyglot apphost fixtures to new shape

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
HostedAgentOptions exists only to give polyglot SDK generators a clean
options-bag shape. .NET callers should keep using the richer
Action<HostedAgentConfiguration> overload, so both the DTO and the
overload that takes it are now internal.

To avoid C# overload ambiguity between '.AsHostedAgent(project)' (which
should bind to the public Action overload) and the internal options
overload, the internal method is renamed to AsHostedAgentForExport. The
polyglot-facing name stays as 'asHostedAgent' via [AspireExport(MethodName)].

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove <remarks> blocks from HostedAgentOptions and AsHostedAgentForExport
that were flowing into the generated TypeScript/Go/Java SDK JSDoc and
including C#-only implementation notes plus broken <see cref> renderings
(e.g. \`AsHostedAgent\`\`1). The polyglot codegen concatenates
<summary>+<remarks>, so any C#-implementation chatter pollutes the
generated SDK docs. Replace with plain // source comments that stay in C#.

Also fix the TypeScript polyglot fixture to match the actual generated
signature: when an extension method takes a single optional DTO parameter,
the codegen wraps it in an options bag, so the call shape is
asHostedAgent(project, { options: { ... } }) — not the flat
asHostedAgent(project, { ... }) shape.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mark HostedAgentOptions as an ATS DTO so polyglot SDK generation treats it as a JSON value object instead of a live exported handle. Update the TypeScript validation fixture to use the generated flat options shape.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update Go and Java Foundry polyglot AppHosts to match the generated HostedAgentOptions DTO and AsHostedAgent optional-parameter shapes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use Double literals for hosted agent CPU and memory options so the generated Java DTO setters compile.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerate the Foundry ATS and API baselines so the release branch backport exposes the hosted-agent options export and drops the stale withComputeEnvironmentExecutable surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 29, 2026 16:43
@davidfowl davidfowl requested a review from sebastienros as a code owner May 29, 2026 16:43
@github-actions
Copy link
Copy Markdown
Contributor

🚀 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 -- 17669

Or

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

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

Backport to release/13.4 of the Foundry hosted-agent API updates in Aspire.Hosting.Foundry, moving to a clearer project-first AsHostedAgent API shape for polyglot SDKs and adjusting deployment behavior so local run mode no longer creates a default Azure Container Registry (ACR) resource.

Changes:

  • Replaces the polyglot-facing WithComputeEnvironment usage with AsHostedAgent across C#/TS/Python/Go/Java fixtures and tests, including a typed HostedAgentOptions DTO for polyglot configuration.
  • Updates Foundry project provisioning logic to only create/provision the default ACR when needed (publish/deploy / hosted-agent scenarios), and updates Azure Bicep snapshots accordingly.
  • Updates Prompt Agent and Hosted Agent dashboard command/icon behavior and adds/adjusts tests to validate the new behavior.
Show a summary per file
File Description
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/TypeScript/apphost.mts Updates TS fixture to call asHostedAgent(project, options) with DTO-style options.
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Python/apphost.py Updates Python fixture to use as_hosted_agent(project=...).
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Java/AppHost.java Updates Java fixture to construct/pass HostedAgentOptions and call asHostedAgent(...).
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Go/apphost.go Updates Go fixture to call AsHostedAgent(...) with options object.
tests/Aspire.Hosting.Foundry.Tests/PromptAgentTests.cs Adds test coverage for the Prompt Agent “Send Message” command annotation configuration.
tests/Aspire.Hosting.Foundry.Tests/ProjectResourceTests.cs Updates tests for “no default ACR in run mode” and validates default ACR removal when no hosted agents exist.
tests/Aspire.Hosting.Foundry.Tests/HostedAgentExtensionTests.cs Updates hosted-agent tests to AsHostedAgent and adds coverage for export options + run-mode behaviors.
tests/Aspire.Hosting.Azure.Tests/Snapshots/FoundryExtensionsTests.AddProject_GeneratesEndpointFromParentFoundryApiEndpoint.verified.bicep Updates snapshot to reflect removal of ACR resources/outputs when not required.
tests/Aspire.Hosting.Azure.Tests/FoundryExtensionsTests.cs Updates Azure Foundry tests to the new hosted-agent API and run-mode ACR behavior.
tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs Updates deploy test to use AsHostedAgent(foundryProject).
tests/Aspire.Deployment.EndToEnd.Tests/FoundryHostedAgentDeploymentTests.cs Updates end-to-end deployment scenario to the new AsHostedAgent(...) API.
src/Aspire.Hosting.Foundry/README.md Updates docs sample to use AsHostedAgent(project).
src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentBuilderExtensions.cs Adjusts Prompt Agent resource/command icon configuration.
src/Aspire.Hosting.Foundry/Project/ProjectResource.cs Adds an annotation used to determine whether default ACR provisioning is required, and removes default registry when not needed.
src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs Creates default ACR only in publish mode; provisions ACR dependencies only when required/overridden.
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentOptions.cs Introduces internal DTO used for polyglot configuration (subset of HostedAgentConfiguration).
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs Implements the project-first hosted-agent API (AsHostedAgent) and improves run-mode dashboard command result handling.
src/Aspire.Hosting.Foundry/FoundryExtensions.cs Adds resource icons for Foundry resources/deployments (dashboard UX).
src/Aspire.Hosting.Foundry/api/Aspire.Hosting.Foundry.cs Updates generated public API surface to reflect the new hosted-agent API shape and other generated deltas.
src/Aspire.Hosting.Foundry/api/Aspire.Hosting.Foundry.ats.txt Updates ATS surface to include HostedAgentOptions and the new exported hosted-agent entrypoint.
playground/FoundryAgents/FoundryAgents.AppHost/AppHost.cs Updates playground AppHost to use AsHostedAgent(project).
playground/FoundryAgentEnterprise/FoundryAgentEnterprise.AppHost/AppHost.cs Updates enterprise playground AppHost to use the new hosted-agent API and removes redundant references.

Copilot's findings

  • Files reviewed: 22/22 changed files
  • Comments generated: 2

Comment on lines 27 to 31
/// <remarks>
/// In run mode, this configures the resource with hosted agent endpoints, health checks,
/// and OpenTelemetry settings. In publish mode, the resource is deployed as a hosted agent
/// in Microsoft Foundry.
/// This method applies in run mode. It configures the resource with the hosted agent responses endpoint,
/// a dashboard command for sending messages to the agent, and OpenTelemetry environment variables expected
/// by the Microsoft Foundry agent server SDK.
/// </remarks>
.AsHostedAgent(project);
```

In run mode, the agent runs locally with health check endpoints and OpenTelemetry instrumentation. In publish mode, the agent is deployed as a hosted agent in Microsoft Foundry.
@github-actions
Copy link
Copy Markdown
Contributor

CLI E2E Tests unknown — 108 passed, 0 failed, 2 unknown (commit 9f9e964)

View all recordings
Status Test Recording Job Artifacts
AddPackageInteractiveWhileAppHostRunningDetached Recording #78547916719 Logs
AddPackageWhileAppHostRunningDetached Recording #78547916719 Logs
AgentCommands_AllHelpOutputs_AreCorrect Recording #78547915722 Logs
AgentInitCommand_DefaultSelection_InstallsDefaultSkills Recording #78547915722 Logs
AgentInitCommand_MigratesDeprecatedConfig Recording #78547915722 Logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp Recording #78547916177 Logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_DevLocalhost Recording #78547916177 Logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_Isolated Recording #78547916177 Logs
AllPublishMethodsBuildDockerImages Recording #78547916226 Logs
AspireAddAndStartWorkAgainstLegacyAppHostTs Recording #78547915635 Logs
AspireAddPackageVersionToDirectoryPackagesProps Recording #78547916240 Logs
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost Recording #78547915614 Logs
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles Recording #78547915713 Logs
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive Recording #78547915713 Logs
AspireStartUpdatesStaleTypeScriptAppHostPath Recording #78547916168 Logs
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps Recording #78547916240 Logs
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent Recording #78547916240 Logs
Banner_DisplayedOnFirstRun Recording #78547916369 Logs
Banner_DisplayedWithExplicitFlag Recording #78547916369 Logs
Banner_NotDisplayedWithNoLogoFlag Recording #78547916369 Logs
CertificatesClean_RemovesCertificates Recording #78547915866 Logs
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate Recording #78547915866 Logs
CertificatesTrust_WithUntrustedCert_TrustsCertificate Recording #78547915866 Logs
ConfigSetGet_CreatesNestedJsonFormat Recording #78547915720 Logs
CreateAndRunAspireStarterProject Recording #78547916104 Logs
CreateAndRunAspireStarterProjectWithBundle Recording #78547915617 Logs
CreateAndRunEmptyAppHostProject Recording #78547915973 Logs
CreateAndRunJavaEmptyAppHostProject Recording #78547916479 Logs
CreateAndRunJsReactProject Recording #78547916636 Logs
CreateAndRunPolyglotAppHostWithDevLocalhostUrls Recording #78547916104 Logs
CreateAndRunPythonReactProject Recording #78547916440 Logs
CreateAndRunTypeScriptEmptyAppHostProject Recording #78547916568 Logs
CreateAndRunTypeScriptStarterProject Recording #78547915863 Logs
CreateJavaAppHostWithViteApp Recording #78547916329 Logs
CreateTypeScriptAppHostWithViteApp_AllowsGuestAppPackageManagerToDiffer Recording #78547916577 Logs
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain Recording #78547916577 Logs
DashboardRunWithAgentMcpListTracesReturnsNoTraces Recording #78547916296 Logs
DashboardRunWithAgentMcpListTracesReturnsNoTraces_DevLocalhost Recording #78547916296 Logs
DashboardRunWithOtelTracesReturnsNoTraces Recording #78547916296 Logs
DashboardRunWithOtelTracesReturnsNoTraces_DevLocalhost Recording #78547916296 Logs
DeployK8sBasicApiService Recording #78547915576 Logs
DeployK8sWithExternalHelmChart Recording #78547916206 Logs
DeployK8sWithGarnet Recording #78547915887 Logs
DeployK8sWithMongoDB Recording #78547915627 Logs
DeployK8sWithMySql Recording #78547916561 Logs
DeployK8sWithPostgres Recording #78547916595 Logs
DeployK8sWithRabbitMQ Recording #78547916307 Logs
DeployK8sWithRedis Recording #78547916297 Logs
DeployK8sWithSqlServer Recording #78547915650 Logs
DeployK8sWithValkey Recording #78547916023 Logs
DeployTypeScriptAppToKubernetes Recording #78547916588 Logs
DescribeCommandResolvesReplicaNames Recording #78547916512 Logs
DescribeCommandShowsRunningResources Recording #78547916512 Logs
DetachFormatJsonProducesValidJson Recording #78547916681 Logs
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance Recording #78547916681 Logs
DoPublishAndDeployListStepsWork Recording #78547916749 Logs
DocsCommand_RendersInteractiveMarkdownFromLocalSource Recording #78547916630 Logs
DoctorCommand_DetectsDeprecatedAgentConfig Recording #78547915722 Logs
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain Recording #78547916696 Logs
DoctorCommand_WithSslCertDir_ShowsTrusted Recording #78547916696 Logs
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted Recording #78547916696 Logs
GatewayWithoutExternalEndpoint_FailsPublishWithGuidance Recording #78547915615 Logs
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain Recording #78547916577 Logs
GlobalMigration_HandlesCommentsAndTrailingCommas Recording #78547915720 Logs
GlobalMigration_HandlesMalformedLegacyJson Recording #78547915720 Logs
GlobalMigration_PreservesAllValueTypes Recording #78547915720 Logs
GlobalMigration_SkipsWhenNewConfigExists Recording #78547915720 Logs
GlobalSettings_MigratedFromLegacyFormat Recording #78547915720 Logs
IngressWithoutExternalEndpoint_FailsPublishWithGuidance Recording #78547915615 Logs
InitTypeScriptAppHost_AugmentsExistingViteRepoInWorkspaceSubdirectory Recording #78547916577 Logs
InteractiveCSharpInitCreatesExpectedFiles Recording #78547915802 Logs
InvalidAppHostPathWithComments_IsHealedOnRun Recording #78547915679 Logs
JavaScriptHostingApisRunFromTypeScriptAppHost Recording #78547916226 Logs
LatestCliCanStartStableChannelAppHost Recording #78547916104 Logs
LatestCliCanStartStableChannelTypeScriptAppHost Recording #78547916104 Logs
LegacySettingsMigration_AdjustsRelativeAppHostPath Recording #78547916168 Logs
LogsCommandShowsResourceLogs Recording #78547916417 Logs
OtelLogsReturnsStructuredLogsFromStarterApp Recording #78547916229 Logs
OtelLogsReturnsStructuredLogsFromStarterAppIsolated Recording #78547916229 Logs
PsCommandListsRunningAppHost Recording #78547916639 Logs
PsFormatJsonOutputsOnlyJsonToStdout Recording #78547916639 Logs
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts Recording #78547916574 Logs
PublishWithConfigureEnvFileUpdatesEnvOutput Recording #78547916574 Logs
PublishWithDockerComposeServiceCallbackSucceeds Recording #78547916574 Logs
PublishWithoutOutputPathUsesAppHostDirectoryDefault Recording #78547916574 Logs
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries Recording #78547916034 Logs
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput Recording #78547916034 Logs
RestoreGeneratesSdkFiles Recording #78547915907 Logs
RestoreGeneratesSdkFiles_WithConfiguredToolchain Recording #78547916236 Logs
RestoreRefreshesGeneratedSdkAfterAddingIntegration Recording #78547916236 Logs
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes Recording #78547916040 Logs
RunFromParentDirectory_UsesExistingConfigNearAppHost Recording #78547915689 Logs
RunReportsSyntaxErrorsForDotNetAppHost Recording #78547916612 Logs
RunReportsSyntaxErrorsForTypeScriptAppHost Recording #78547916612 Logs
SecretCrudOnDotNetAppHost Recording #78547915838 Logs
SecretCrudOnTypeScriptAppHost Recording #78547915592 Logs
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels Recording #78547916401 Logs
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets Recording #78547915770 Logs
StartReportsSyntaxErrorsForDotNetAppHost Recording #78547916612 Logs
StartReportsSyntaxErrorsForTypeScriptAppHost Recording #78547916612 Logs
StopAllAppHostsFromAppHostDirectory Recording #78547915936 Logs
StopJavaPolyglotAppHostUsingApphostDirectory Recording #78547916663 Logs
StopNonInteractiveSingleAppHost Recording #78547915936 Logs
StopTypeScriptPolyglotAppHostUsingApphostDirectory Recording #78547915684 Logs
StopWithNoRunningAppHostExitsSuccessfully Recording #78547916719 Logs
UnAwaitedChainsCompileWithAutoResolvePromises Recording #78547916236 Logs
UpdateProjectChannelToStable_CSharpEmptyAppHost_PreservesAspireConfigChannel Recording #78547916578 Logs
UpdateProjectChannelToStable_CSharpSingleFileInit_PreservesAspireConfigChannel Recording #78547916578 Logs
UpdateProjectChannelToStable_TypeScriptSingleFileInit_PreservesAspireConfigChannel Recording #78547916578 Logs
UpdateProjectChannelToStable_TypeScript_PreviewsStablePackagesAndPreservesChannel Recording #78547916578 Logs

📹 Recordings uploaded automatically from CI run #26649968221

@sebastienros sebastienros added the Servicing-consider Issue for next servicing release review label May 29, 2026
@davidfowl davidfowl merged commit 0cbaf82 into release/13.4 May 29, 2026
313 checks passed
@davidfowl davidfowl deleted the backport/pr-17545-to-release/13.4 branch May 29, 2026 20:20
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 29, 2026
aspire-repo-bot Bot added a commit to microsoft/aspire.dev that referenced this pull request May 29, 2026
…Agent

Documents the API rename from WithComputeEnvironment/PublishAsHostedAgent to
AsHostedAgent introduced in microsoft/aspire#17669. Updates all code examples,
section headings, and prose in the Azure AI Foundry hosting integration docs to
use the new AsHostedAgent method. Also clarifies that the default Azure Container
Registry is only created in publish mode, not local run mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot
Copy link
Copy Markdown
Contributor

Pull request created: #1130

Generated by PR Documentation Check

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1130 targeting release/13.4.

Updated src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx to replace all references to PublishAsHostedAgent / publishAsHostedAgent with the new AsHostedAgent / asHostedAgent API (both C# and TypeScript examples), rename the section heading accordingly, and clarify that the default ACR is only created in publish mode — not local run mode.

Note

This draft PR needs human review before merging.

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

Labels

Servicing-consider Issue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants