Skip to content
Docs Try Aspire
Docs Try

AgentFrameworkBuilderExtensions Methods

Class Methods 2 members
Provides extension methods for adding Agent Framework DevUI resources to the application model.
AddDevUI(IDistributedApplicationBuilder, string, int?) Section titled AddDevUI(IDistributedApplicationBuilder, string, int?) extension IResourceBuilder<DevUIResource>
Adds a DevUI resource for testing AI agents in a distributed application.
public static class AgentFrameworkBuilderExtensions
{
public static IResourceBuilder<DevUIResource> AddDevUI(
this IDistributedApplicationBuilder builder,
string name,
int? port = null)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name to give the resource.
port int? optional The host port for the DevUI web interface. If not specified, a random port will be assigned.
IResourceBuilder<DevUIResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.

DevUI is a web-based interface for testing and debugging AI agents using the OpenAI Responses protocol. When configured with AgentFrameworkBuilderExtensions.WithAgentService, it aggregates agents from multiple backend services and provides a unified testing interface.

The aggregator runs as an in-process reverse proxy within the AppHost, requiring no external container image. It serves the DevUI frontend from embedded resources in Microsoft.Agents.AI.DevUI when available, and falls back to proxying from the first configured backend. It aggregates entity listings from all backends.

This resource is excluded from the deployment manifest as it is intended for development use only.

var devui = builder.AddDevUI("devui")
.WithAgentService(dotnetAgent)
.WithAgentService(pythonAgent);
WithAgentService(IResourceBuilder<DevUIResource>, IResourceBuilder<TSource>, IReadOnlyList<AgentEntityInfo>, string?) Section titled WithAgentService(IResourceBuilder<DevUIResource>, IResourceBuilder<TSource>, IReadOnlyList<AgentEntityInfo>, string?) extension IResourceBuilder<DevUIResource>
Configures DevUI to connect to an agent service backend.
public static class AgentFrameworkBuilderExtensions
{
public static IResourceBuilder<DevUIResource> WithAgentService<TSource>(
this IResourceBuilder<DevUIResource> builder,
IResourceBuilder<TSource> agentService,
IReadOnlyList<AgentEntityInfo>? agents = null,
string? entityIdPrefix = null)
{
// ...
}
}
builder IResourceBuilder<DevUIResource> The DevUI resource builder.
agentService IResourceBuilder<TSource> The agent service resource to connect to.
agents IReadOnlyList<AgentEntityInfo> optional Optional list of agents declared by this backend. When provided, the aggregator uses these declarations directly. When not provided, defaults to a single agent named after the agentService resource. The backend doesn't need to expose a /v1/entities endpoint in either case.
entityIdPrefix string? optional An optional prefix to add to entity IDs from this backend. If not specified, the resource name will be used as the prefix.
IResourceBuilder<DevUIResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.

Each agent service should expose the OpenAI Responses and Conversations API endpoints (via MapOpenAIResponses and MapOpenAIConversations).

When agents is provided, the aggregator builds the entity listing from these declarations without querying the backend. When not provided, a single agent named after the service resource is assumed. Agent services don't need a /v1/entities endpoint.

var writerAgent = builder.AddProject<Projects.WriterAgent>("writer-agent");
var editorAgent = builder.AddProject<Projects.EditorAgent>("editor-agent");
builder.AddDevUI("devui")
.WithAgentService(writerAgent, agents: [new("writer", "Writes short stories")])
.WithAgentService(editorAgent, agents: [new("editor", "Edits and formats stories")])
.WaitFor(writerAgent)
.WaitFor(editorAgent);