Skip to content

FoundryDevUIServiceCollectionExtensions

NexusLabs.Foundry.MicrosoftAgentFramework.DevUI

FoundryDevUIServiceCollectionExtensions Class

Extension methods for bridging Foundry's NexusLabs.Foundry.MicrosoftAgentFramework.FoundryAgentAttribute-declared agents into MAF DevUI's entity discovery.

public static class FoundryDevUIServiceCollectionExtensions

Inheritance System.Object 🡒 FoundryDevUIServiceCollectionExtensions

Remarks

MAF DevUI discovers agents via keyed AIAgent DI services. This bridge reads the source-generated agent registry and uses MAF's AddAIAgent hosting API to register each NexusLabs.Foundry.MicrosoftAgentFramework.FoundryAgentAttribute-declared agent so DevUI's /v1/entities endpoint lists them.

This package deliberately isolates the preview-only DevUI and Hosting package dependencies from the stable NexusLabs.Foundry.MicrosoftAgentFramework package.

Methods

FoundryDevUIServiceCollectionExtensions.AddFoundryDevUI(this IServiceCollection) Method

Registers all NexusLabs.Foundry.MicrosoftAgentFramework.FoundryAgentAttribute-declared agents with MAF's hosting infrastructure so they appear in DevUI's entity discovery at /v1/entities.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddFoundryDevUI(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The service collection to register agents into.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The service collection for chaining.

Example

var builder = WebApplication.CreateBuilder(args);

// Bridge Foundry agents -> DevUI
builder.Services.AddFoundryDevUI();

// MAF hosting + DevUI
builder.Services.AddOpenAIResponses();
builder.Services.AddOpenAIConversations();

var app = builder.Build();
app.MapOpenAIResponses();
app.MapOpenAIConversations();
app.MapDevUI();
app.Run();

Remarks

The method reads agent types from the static NexusLabs.Foundry.MicrosoftAgentFramework.AgentFrameworkGeneratedBootstrap registry (populated by the source-generated [ModuleInitializer]) and registers each using MAF's AddAIAgent(name, instructions) hosting API. The agent's NexusLabs.Foundry.MicrosoftAgentFramework.FoundryAgentAttribute.Instructions and NexusLabs.Foundry.MicrosoftAgentFramework.FoundryAgentAttribute.Description are read from the attribute.

Agents are registered with instructions from the attribute. Their IChatClient is resolved from DI at runtime when DevUI invokes them — register an IChatClient in DI to enable interactive use.