-
Notifications
You must be signed in to change notification settings - Fork 751
Description
Today there is AgentCatalog and WorkflowCatalog which seem like they exist purely to get Agents and Workflows out of DI. However, the catalogs are only added to if you call builder.AddAIAgent(...), builder.Services.AddAIAgent(...), or builder.AddWorkflow(...). If you add an Agent or Workflow to DI yourself, e.g. builder.Services.AddTransient<Workflow>(...), then the Workflow or Agent isn't added to the catalog. So DevUI will fail to find AIAgents and Workflows that are added manually.
I wonder if these types should be deleted and consuming code should just use DI more natively.
For example,
agent-framework/dotnet/src/Microsoft.Agents.AI.DevUI/EntitiesApiExtensions.cs
Lines 52 to 55 in 406a856
| private static async Task<IResult> ListEntitiesAsync( | |
| AgentCatalog? agentCatalog, | |
| WorkflowCatalog? workflowCatalog, | |
| CancellationToken cancellationToken) |
could be changed to
private static async Task<IResult> ListEntitiesAsync(
IEnumerable<AIAgent> agents,
IEnumerable<Workflow> workflows,
IServiceProvider serviceProvider,
CancellationToken cancellationToken)
{
var keyedAgents = serviceProvider.GetKeyedServices<AIAgent>(KeyedService.AnyKey);
var keyedWorkflows = serviceProvider.GetKeyedServices<Workflow>(KeyedService.AnyKey);
}This would remove a seemingly unnecessary type from DI as well as improve DevUI's detection logic.