Skip to content

Adds support for foundry prompt agents - #16353

Merged
Eric Erhardt (eerhardt) merged 46 commits into
microsoft:mainfrom
tommasodotNET:features/foundry-prompt-agents
Apr 28, 2026
Merged

Eric Erhardt (eerhardt) merged 46 commits into
microsoft:mainfrom
tommasodotNET:features/foundry-prompt-agents

Conversation

@tommasodotNET

@tommasodotNET Tommaso Stocchi (tommasodotNET) commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds support for Foundry Prompt Agents — declarative agents defined in the AppHost that are provisioned on Azure AI Foundry with configurable tools. Agents are deployed during both aspire run and aspire publish, and consumer services can invoke them via the Azure.AI.Projects SDK using standard Aspire connection strings.

AzurePromptAgentResource — resource representing a prompt agent (model + instructions + tools) that deploys to Foundry via the data-plane API
PromptAgentDeployer — lifecycle hook (IDistributedApplicationEventingSubscriber) that deploys agents during aspire run after Azure provisioning completes
PromptAgentConfiguration — wraps DeclarativeAgentDefinition / ProjectsAgentVersionCreationOptions from the SDK

As documented in the README and in the playground sample comments, there is currently no way to deploy a Bing resource on Azure via bicep. Therefore, there is a manual step involved that we cannot avoid if using Bing Grounding Tool.

Running the playground project, the resources tools need will be provisioned on azure and configured on foundry. The prompt agents will be provisioned as well and will provide a link to the agent on Foundry and a quick action button to invoke them from the dashboard (like we do for Hosted Agents):
image

I've tested both aspire run and aspire deploy commands.

Fixes #16263

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
  • Does the change require an update in our Aspire docs?

Implement core infrastructure for Foundry prompt agents and tools:

- IFoundryTool interface and FoundryToolResource base class for tool abstraction
- AzurePromptAgentResource with pipeline steps, deploy logic, and connection properties
- PromptAgentConfiguration wrapping SDK's PromptAgentDefinition
- Built-in tool definitions: CodeInterpreter, FileSearch, WebSearch
- AzureAISearchToolResource wrapping AzureSearchResource with project connections
- PromptAgentBuilderExtensions with AddPromptAgent, WithTool, and convenience methods
- Azure AI Search connection overload in ConnectionBuilderExtensions
- OPENAI001 diagnostic suppression for OpenAI.Responses types

Tools use ResponseTool (OpenAI.Responses) as the common type since
PromptAgentDefinition.Tools is IList<ResponseTool>. AgentTool subtypes
(like AzureAISearchAgentTool) have implicit conversion to ResponseTool.

Part of: microsoft#16263

Co-authored-by: Copilot <[email protected]>
Tests cover:
- AddPromptAgent extension method (resource creation, model/instructions, null checks)
- WithCodeInterpreter, WithFileSearch, WithWebSearch (built-in tools)
- AddAzureAISearchTool (resource-backed tool)
- WithTool (adding tools to agents)
- WithReference for connection string injection
- PromptAgentConfiguration (defaults, metadata, ToAgentVersionCreationOptions)
- Interface implementation verification

Co-authored-by: Copilot <[email protected]>
New tools:
- BingGroundingToolResource: Resource-backed tool for Bing Search grounding
- SharePointToolDefinition: Config-only tool for SharePoint data grounding
- FabricToolDefinition: Config-only tool for Microsoft Fabric data agents
- AzureFunctionToolDefinition: Azure Functions with queue-based bindings
- FunctionToolDefinition: OpenAI function calling (application-defined functions)
- ImageGenerationToolDefinition: Image generation (preview, behind [Experimental])
- ComputerToolDefinition: Computer use (preview, behind [Experimental])

Extension methods:
- AddBingGroundingTool, WithSharePoint, WithFabric, WithAzureFunction
- WithFunction, WithImageGeneration, WithComputerUse

Tests: 82 total (all passing), covering all tool types
README: Updated with prompt agent usage and tool reference table

Co-authored-by: Copilot <[email protected]>
- Convert all tool types from IFoundryTool definitions to FoundryToolResource subclasses
- Tools are now created at the project level with Add*Tool() methods
- Resource-backed tools linked via .WithReference() overloads
- AddPromptAgent takes params IResourceBuilder<FoundryToolResource>[] tools
- Same-project validation: tools must belong to same project as agent
- Keep IFoundryTool as escape hatch via WithCustomTool() on agent
- Update all tests (86 passing) and README for new API

Co-authored-by: Copilot <[email protected]>
The Grounding with Bing Search resource cannot be provisioned via
Bicep/ARM — users must create it in the Azure portal and reference
the resulting Foundry project connection.

Co-authored-by: Copilot <[email protected]>
- Add BingGroundingConnectionProperties with ApiKey auth and
  category 'GroundingWithBingSearch' matching the ARM template
- Add AddBingGroundingConnection() to create connections from
  a Bing resource ID (Microsoft.Bing/accounts)
- Add WithReference(string bingResourceId) overload that auto-creates
  the correctly-typed connection
- Fix duplicate WithRoleAssignments call in AI Search WithReference
  (AddConnection already handles role assignments)
- Update README with simplified Bing examples
- Add 3 new tests (89 total, all passing)

Co-authored-by: Copilot <[email protected]>
- AppHost with two prompt agents: research-agent (Bing + AI Search + code
  interpreter) and joker-agent (code interpreter + file search)
- PromptAgentChat consumer web app using OpenAI Responses API
- Added WithReference(IResourceBuilder<ParameterResource>) overload for
  Bing Grounding tool (supports user secrets for resource ID)
- Added AddBingGroundingConnection parameter overload
- Added to Aspire.slnx solution
- 91 tests passing

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings April 21, 2026 06:47
@github-actions

github-actions Bot commented Apr 21, 2026 •

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 -- 16353

Or

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class Aspire Hosting support for Azure AI Foundry prompt agents (declarative agents + tool catalog), including run-mode deployment via eventing, publish-time deployment via pipeline steps, and a playground sample to demonstrate end-to-end usage.

Changes:

  • Introduces AzurePromptAgentResource, supporting prompt-agent deployment to Foundry and connection-string consumption by services.
  • Adds a set of project-level Foundry tool resources (built-in, config-only, and resource-backed) plus builder extensions (Add*Tool, WithReference, etc.).
  • Updates Foundry project/connection provisioning outputs and bumps Azure AI Projects SDK usage, plus adds tests + a playground sample.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.Foundry.Tests/PromptAgentTests.cs New unit tests covering prompt agent + tool resource creation and reference semantics.
tests/Aspire.Hosting.Foundry.Tests/PromptAgentConfigurationTests.cs New unit tests validating prompt-agent configuration conversion to SDK options.
tests/Aspire.Hosting.Foundry.Tests/HostedAgentConfigurationTests.cs Updates tests to the renamed hosted-agent options conversion method.
src/Aspire.Hosting.Foundry/README.md Documents prompt-agent usage and available tools (plus examples).
src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentDeployer.cs Run-mode deployer that provisions prompt agents after Azure provisioning completes.
src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentConfiguration.cs Prompt-agent configuration wrapper around ProjectsAgentVersionCreationOptions.
src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentBuilderExtensions.cs Public builder API for adding prompt agents + tool resources and linking references.
src/Aspire.Hosting.Foundry/PromptAgent/IFoundryTool.cs Tool extensibility interface for deploy-time conversion to SDK tool types.
src/Aspire.Hosting.Foundry/PromptAgent/FunctionToolDefinition.cs Tool resource for function-calling tool definitions.
src/Aspire.Hosting.Foundry/PromptAgent/FoundryToolResource.cs Base resource type for project-level Foundry tool resources.
src/Aspire.Hosting.Foundry/PromptAgent/ConfigOnlyToolDefinitions.cs Tool resources for SharePoint/Fabric grounding via existing project connections.
src/Aspire.Hosting.Foundry/PromptAgent/BuiltInToolDefinitions.cs Tool resources for built-in tools (code interpreter, file search, web search, etc.).
src/Aspire.Hosting.Foundry/PromptAgent/BingGroundingToolResource.cs Tool resource for Bing grounding using a Foundry project connection.
src/Aspire.Hosting.Foundry/PromptAgent/AzurePromptAgentResource.cs Core prompt-agent resource + publish/run deployment hooks + connection string projection.
src/Aspire.Hosting.Foundry/PromptAgent/AzureFunctionToolDefinition.cs Tool resource for Azure Function tool definitions (queue bindings).
src/Aspire.Hosting.Foundry/PromptAgent/AzureAISearchToolResource.cs Tool resource for Azure AI Search grounding via provisioned Foundry connection.
src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs Adjusts project provisioning outputs (notably the name output format).
src/Aspire.Hosting.Foundry/Project/ConnectionResource.cs Adds connection properties type for Bing grounding connection category override.
src/Aspire.Hosting.Foundry/Project/ConnectionBuilderExtensions.cs Updates connection outputs/sharing defaults and adds AI Search + Bing grounding connections.
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentConfiguration.cs Migrates hosted-agent configuration to ProjectsAgentVersionCreationOptions SDK surface.
src/Aspire.Hosting.Foundry/HostedAgent/AzureHostedAgentResource.cs Updates hosted-agent deployment path to the new AgentAdministrationClient API shape.
src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj Adds additional warning suppressions needed for new preview/evaluation SDK types.
playground/FoundryPromptAgents/aspire.config.json New playground configuration pointing to the prompt-agent AppHost.
playground/FoundryPromptAgents/PromptAgentChat/PromptAgentChat.csproj New consumer service sample that calls prompt agents via Azure AI Projects/OpenAI APIs.
playground/FoundryPromptAgents/PromptAgentChat/Program.cs Sample HTTP endpoints invoking prompt agents using Aspire-injected connection strings.
playground/FoundryPromptAgents/FoundryPromptAgents.AppHost/appsettings.Production.json Playground AppHost production settings stub.
playground/FoundryPromptAgents/FoundryPromptAgents.AppHost/appsettings.Development.json Playground AppHost dev settings for Azure provisioning.
playground/FoundryPromptAgents/FoundryPromptAgents.AppHost/Properties/launchSettings.json Playground launch profiles for local AppHost runs.
playground/FoundryPromptAgents/FoundryPromptAgents.AppHost/FoundryPromptAgents.AppHost.csproj New AppHost project wiring up Foundry prompt agents + tools + consumer project.
playground/FoundryPromptAgents/FoundryPromptAgents.AppHost/AppHost.cs Full sample demonstrating prompt agents with Bing + AI Search + code interpreter tools.
Directory.Packages.props Updates Azure AI Projects dependency versions and adds Azure.AI.Extensions.OpenAI.
Aspire.slnx Adds the new FoundryPromptAgents playground projects to the solution.
Comments suppressed due to low confidence (1)

playground/FoundryPromptAgents/FoundryPromptAgents.AppHost/appsettings.Development.json:9

  • This playground appsettings.Development.json includes what appear to be real tenant/subscription identifiers and a specific resource group/location. Even if not secrets, committing real tenant/subscription details is typically treated as sensitive and can cause accidental billing/resource conflicts for others running the playground. Replace with placeholders (e.g., {tenantId}, {subscriptionId}) and/or move these values to user-secrets/documentation so the repo doesn’t contain personal/environment-specific Azure identifiers.

Comment thread src/Aspire.Hosting.Foundry/README.md Resolved
@tommasodotNET

Copy link
Copy Markdown
Contributor Author

Sébastien Ros (@sebastienros) need help with internal nuget feed config, once again 😅

@sebastienros

Copy link
Copy Markdown
Contributor

Each new method/property needs to be exercized in a tests/polyglot corresponding apphost (for all languages). The agent can do that.

…tNET/aspire into features/foundry-prompt-agents

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 42 changed files in this pull request and generated 3 comments.

@github-actions

Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@eerhardt Eric Erhardt (eerhardt) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks for the contribution Tommaso Stocchi (@tommasodotNET)

@eerhardt
Eric Erhardt (eerhardt) enabled auto-merge (squash) April 28, 2026 21:43
@eerhardt
Eric Erhardt (eerhardt) merged commit 777610a into microsoft:main Apr 28, 2026
285 checks passed
@tommasodotNET
Tommaso Stocchi (tommasodotNET) deleted the features/foundry-prompt-agents branch April 28, 2026 22:08
@github-actions github-actions Bot added this to the 13.3 milestone Apr 28, 2026
Nell Shamrell-Harrington (nellshamrell) pushed a commit to nellshamrell/aspire that referenced this pull request May 18, 2026
* Add prompt agent and tool infrastructure for Foundry

Implement core infrastructure for Foundry prompt agents and tools:

- IFoundryTool interface and FoundryToolResource base class for tool abstraction
- AzurePromptAgentResource with pipeline steps, deploy logic, and connection properties
- PromptAgentConfiguration wrapping SDK's PromptAgentDefinition
- Built-in tool definitions: CodeInterpreter, FileSearch, WebSearch
- AzureAISearchToolResource wrapping AzureSearchResource with project connections
- PromptAgentBuilderExtensions with AddPromptAgent, WithTool, and convenience methods
- Azure AI Search connection overload in ConnectionBuilderExtensions
- OPENAI001 diagnostic suppression for OpenAI.Responses types

Tools use ResponseTool (OpenAI.Responses) as the common type since
PromptAgentDefinition.Tools is IList<ResponseTool>. AgentTool subtypes
(like AzureAISearchAgentTool) have implicit conversion to ResponseTool.

Part of: microsoft#16263

Co-authored-by: Copilot <[email protected]>

* Add unit tests for prompt agent resources and configuration

Tests cover:
- AddPromptAgent extension method (resource creation, model/instructions, null checks)
- WithCodeInterpreter, WithFileSearch, WithWebSearch (built-in tools)
- AddAzureAISearchTool (resource-backed tool)
- WithTool (adding tools to agents)
- WithReference for connection string injection
- PromptAgentConfiguration (defaults, metadata, ToAgentVersionCreationOptions)
- Interface implementation verification

Co-authored-by: Copilot <[email protected]>

* Add all tool types and update README

New tools:
- BingGroundingToolResource: Resource-backed tool for Bing Search grounding
- SharePointToolDefinition: Config-only tool for SharePoint data grounding
- FabricToolDefinition: Config-only tool for Microsoft Fabric data agents
- AzureFunctionToolDefinition: Azure Functions with queue-based bindings
- FunctionToolDefinition: OpenAI function calling (application-defined functions)
- ImageGenerationToolDefinition: Image generation (preview, behind [Experimental])
- ComputerToolDefinition: Computer use (preview, behind [Experimental])

Extension methods:
- AddBingGroundingTool, WithSharePoint, WithFabric, WithAzureFunction
- WithFunction, WithImageGeneration, WithComputerUse

Tests: 82 total (all passing), covering all tool types
README: Updated with prompt agent usage and tool reference table

Co-authored-by: Copilot <[email protected]>

* Refactor tools to project-level resources with reusable API

- Convert all tool types from IFoundryTool definitions to FoundryToolResource subclasses
- Tools are now created at the project level with Add*Tool() methods
- Resource-backed tools linked via .WithReference() overloads
- AddPromptAgent takes params IResourceBuilder<FoundryToolResource>[] tools
- Same-project validation: tools must belong to same project as agent
- Keep IFoundryTool as escape hatch via WithCustomTool() on agent
- Update all tests (86 passing) and README for new API

Co-authored-by: Copilot <[email protected]>

* Document that Bing Grounding requires manual portal creation

The Grounding with Bing Search resource cannot be provisioned via
Bicep/ARM — users must create it in the Azure portal and reference
the resulting Foundry project connection.

Co-authored-by: Copilot <[email protected]>

* Fix Bing Grounding UX and duplicate AI Search role assignments

- Add BingGroundingConnectionProperties with ApiKey auth and
  category 'GroundingWithBingSearch' matching the ARM template
- Add AddBingGroundingConnection() to create connections from
  a Bing resource ID (Microsoft.Bing/accounts)
- Add WithReference(string bingResourceId) overload that auto-creates
  the correctly-typed connection
- Fix duplicate WithRoleAssignments call in AI Search WithReference
  (AddConnection already handles role assignments)
- Update README with simplified Bing examples
- Add 3 new tests (89 total, all passing)

Co-authored-by: Copilot <[email protected]>

* Add FoundryPromptAgents playground sample

- AppHost with two prompt agents: research-agent (Bing + AI Search + code
  interpreter) and joker-agent (code interpreter + file search)
- PromptAgentChat consumer web app using OpenAI Responses API
- Added WithReference(IResourceBuilder<ParameterResource>) overload for
  Bing Grounding tool (supports user secrets for resource ID)
- Added AddBingGroundingConnection parameter overload
- Added to Aspire.slnx solution
- 91 tests passing

Co-authored-by: Copilot <[email protected]>

* fixes bing and azure ai search tools

* -fix

* addresses copilot review

* dashboard improvements

* address code review

* avoid using big endian

* refactor: update Azure connection methods to use AspireExport with descriptions

* refactor: remove unnecessary AspireExport attributes from PromptAgentConfiguration

* refactor: update prompt agent tool parameters and remove unnecessary properties

* refactor: update prompt agent tool attachment syntax for consistency across implementations

* refactor: add missing AspireExport attribute to FoundryToolResource class

* refactor: add AspireExport attribute to multiple tool resource classes

* Fix Java wrapper inheritance

Add Java codegen inheritance handling for exported base types and cover it with a targeted regression test.\n\nCo-authored-by: Copilot <[email protected]>

* fix: use separate BingGroundingTool instances per reference type in polyglot tests

The three WithReference overloads (connection, resource ID, parameter) are
mutually exclusive. The polyglot tests were calling all three on the same
bingTool instance, which is incorrect. Each reference type now uses its own
tool instance.

Co-authored-by: Copilot <[email protected]>

* refactor: unify Bing WithReference overloads using AspireUnion

Replace three separate WithReference methods (withBingConnectionReference,
withBingResourceIdReference, withBingParameterReference) with a single
WithReference method using [AspireUnion] to accept connection, string, or
parameter types. This gives polyglot hosts a single unified withReference
method matching the Aspire convention.

Co-authored-by: Copilot <[email protected]>

* feat: add BingGroundingConnectionResource for compile-time type safety

Introduce a dedicated BingGroundingConnectionResource type that extends
AzureCognitiveServicesProjectConnectionResource. This narrows the
WithReference union to only accept Bing-specific connections, preventing
callers from accidentally passing a non-Bing connection (e.g., an AI Search
connection) to the Bing Grounding tool. The mistake is now caught at compile
time rather than surfacing at deployment/runtime.

Co-authored-by: Copilot <[email protected]>

* feat: add BingGroundingConnectionResource for compile-time type safety

Introduce a dedicated BingGroundingConnectionResource type that extends
AzureCognitiveServicesProjectConnectionResource. This narrows the
WithReference union to only accept Bing-specific connections, preventing
callers from accidentally passing a non-Bing connection (e.g., an AI Search
connection) to the Bing Grounding tool. The mistake is now caught at compile
time rather than surfacing at deployment/runtime.

Co-authored-by: Copilot <[email protected]>

* docs: update documentation for WithReference overloads in BingGroundingToolResource

* refactor: remove redundant WithReference overloads for Bing Grounding tool

* Fix Bing withReference export

Co-authored-by: Copilot <[email protected]>

* Update playground/FoundryPromptAgents/PromptAgentChat/Program.cs

Co-authored-by: Eric Erhardt <[email protected]>

* Update src/Aspire.Hosting.Foundry/PromptAgent/AzurePromptAgentResource.cs

Co-authored-by: Eric Erhardt <[email protected]>

* address code review

* merge foundry playground samples

* Refactor CosmosDB and Storage connection exports for ATS compatibility

* fixes python test

* Address prompt agent review feedback

Co-authored-by: Copilot <[email protected]>

* fixes prompt agent wait for foundry creation

* bing fix

* removes bing from playground

* PR feedback

* Remove unnecessary class

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Sebastien Ros <[email protected]>
Co-authored-by: Eric Erhardt <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Foundry Prompt Agents Provisioning

4 participants