Add agent resource support#17757
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17757Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17757" |
There was a problem hiding this comment.
Pull request overview
Adds generic agent-resource support to Aspire Hosting so endpoint-backed compute resources can be marked as A2A/OpenAI Responses agents, surfaced in the dashboard, and referenced by consumers via agent-card environment variables.
Changes:
- Adds
Aspire.Hosting.Agentspublic APIs for agent protocols, invocation mode, annotations, andAsAgent(...)extensions. - Extends
WithReference(...)to inject A2A agent-card URLs into consumers. - Adds tests, code-generation coverage, and a new
playground/AspireAgentssample.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Aspire.Hosting/Agents/AgentResourceBuilderExtensions.cs |
Adds agent configuration, dashboard commands, URLs, and request preparation helpers. |
src/Aspire.Hosting/Agents/AgentResourceAnnotation.cs |
Adds metadata annotation for agent protocols and paths. |
src/Aspire.Hosting/Agents/AgentProtocol.cs |
Adds supported agent protocol enum. |
src/Aspire.Hosting/Agents/A2AInvocationMode.cs |
Adds A2A dashboard invocation mode enum. |
src/Aspire.Hosting/ResourceBuilderExtensions.cs |
Adds A2A agent-card env-var injection during references. |
src/Aspire.Hosting/api/Aspire.Hosting.cs |
Updates public API surface for new agent APIs. |
tests/Aspire.Hosting.Tests/AgentResourceBuilderExtensionsTests.cs |
Adds hosting tests for annotations, commands, and reference injection. |
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs |
Adds ATS capability and enum coverage for TypeScript. |
tests/Aspire.Hosting.CodeGeneration.Python.Tests/AtsPythonCodeGeneratorTests.cs |
Adds ATS capability coverage for Python. |
tests/Aspire.Hosting.CodeGeneration.Java.Tests/AtsJavaCodeGeneratorTests.cs |
Adds ATS capability coverage for Java. |
tests/Aspire.Hosting.CodeGeneration.Go.Tests/AtsGoCodeGeneratorTests.cs |
Adds ATS capability coverage for Go. |
playground/AspireAgents/AspireAgents.AppHost/AppHost.cs |
Adds sample AppHost wiring for A2A and Responses agents. |
playground/AspireAgents/AspireAgents.AppHost/AspireAgents.AppHost.csproj |
Adds sample AppHost project configuration. |
playground/AspireAgents/AspireAgents.AppHost/Properties/launchSettings.json |
Pins local dashboard/resource-service endpoints for the sample. |
playground/AspireAgents/ResponsesAgent/ResponsesAgent.csproj |
Adds Responses agent project dependencies. |
playground/AspireAgents/ResponsesAgent/Program.cs |
Implements sample OpenAI Responses weather agent. |
playground/AspireAgents/weather-agent-python/weather_agent_python/main.py |
Implements sample Python A2A weather agent. |
playground/AspireAgents/weather-agent-python/weather_agent_python/__init__.py |
Adds Python package marker/docstring. |
playground/AspireAgents/weather-agent-python/pyproject.toml |
Adds Python sample package metadata and dependencies. |
playground/AspireAgents/weather-agent-python/.python-version |
Pins Python version for the sample. |
playground/AspireAgents/aspire.config.json |
Points Aspire CLI/config tooling at the sample AppHost. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Definitely don’t want this in Aspire.Hosting. Also this needs to be proven across more than just MAF since it’s a general abstraction. Make this PR a draft until we do more research |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit b0c4ce1.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit 3ef6a28.
PR Testing ReportPR Information
Overall Result✅ PR VERIFIED — all tested scenarios passed. The PR dogfood CLI matches the PR head, CI is green, the AspireAgents-style AppHost starts successfully with the existing Foundry resources, A2A agent-card reference injection works, and the agent custom commands were invoked successfully from the dashboard. CI Status
CLI Version Verification
Test App Setup
Resource StartupStatus: ✅ Passed. All target resources reached Final resource/command state: A2A agent-card reference injection was present in the consumer environment: Agent Custom Command ValidationStatus: ✅ Passed.
Representative successful log excerpts: Notes
Artifacts
|
a35f288 to
f1579fc
Compare
Use the command argument model for agent invocation messages instead of prompting directly from command callbacks. This lets dashboard, CLI, and API callers supply the same required message argument shape introduced by the HTTP command argument support. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR Testing ReportPR Information
CLI Version Verification
Changes AnalyzedChange Categories
Test Scenarios ExecutedScenario 1: Invoke an agent resource via Aspire CLI custom commandObjective: Verify that a resource marked as an agent exposes a custom command through Steps:
Evidence:
Observations:
Scenario 2: Missing required agent command argumentObjective: Verify non-interactive CLI invocation fails safely when the required agent command argument is omitted. Steps:
Expected Unhappy-Path Outcome: Non-zero exit and a clear validation error for the missing required Observations:
Notes
Summary
Overall ResultPASS - PR verified for CLI invocation of agent custom commands |
MCP custom command updateWe updated the MCP resource command behavior after testing it against the Aspire Agents playground. What changed:
Validation performed:
|
Keep the dashboard MCP command interactive while exposing an API-visible command that accepts tool name and JSON arguments for CLI/non-interactive callers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Adds generic agent awareness for Aspire resources so endpoint-backed compute resources can be marked as agents and surfaced consistently in the dashboard. This enables A2A, OpenAI Responses, AG-UI, and ACP agents to expose protocol-specific URLs and highlighted send-message commands, while MCP server tooling is surfaced through
WithMcpServer()instead of being modeled as an agent protocol.Fixes #17752
User-facing usage
C# AppHost:
Each
AsAgent(...)call configures one protocol/path pair. A resource can expose multiple protocols by callingAsAgent(...)multiple times, which creates multiple agent annotations on the same resource.The A2A reference injects an agent card URL such as
A2A_JSONRPC_AGENT_AGENTCARD_URLinto consumers. A2A supports JSON-RPC, HTTP+JSON, and gRPC protocol variants; dashboard send-message commands are added for the HTTP-capable variants. A2A invocation defaults to non-streaming and can opt into streaming withA2AInvocationMode.Streaming.Protocol mapping SDKs used in the playground
a2a, froma2a-sdk) for the agent card and JSON-RPC routes, withagent-framework-a2aas the adapter from the in-process agent to A2A.Microsoft.Agents.AI.Hosting.OpenAIforAddOpenAIResponses()andMapOpenAIResponses().agent-framework-ag-uiforadd_agent_framework_fastapi_endpoint(...).acp-sdkfor the ACP server and FastAPI app mapping.ModelContextProtocol.AspNetCoreforAddMcpServer(),WithHttpTransport(), andMapMcp(...).Playground
This adds
playground/AspireAgentswith Foundry-backed sample agents:a2a-jsonrpc-agent: Python A2A JSON-RPC agent.responses-agent: .NET OpenAI Responses agent, also exposed as an MCP server throughWithMcpServer().mcp-agent: .NET MCP server with a model-backedanswer_questiontool.agui-acp-agent: one Python app exposing both AG-UI and ACP protocols from the same Aspire resource.agent-env-dump: dummy executable resource for checking A2A environment variable injection.Checklist
<remarks />and<code />elements on your triple slash comments?