Skip to content

Conversation

@DeagleGross
Copy link
Contributor

@DeagleGross DeagleGross commented Oct 9, 2025

Hosting package today has a set of extension APIs which allow registration of custom AIAgents in the dependency injection container. This PR adds similar extenions methods to configure workflows.

AIAgent

Today one could create AIAgent via AddAIAgent() with minimal parameters:

builder.AddAIAgent(
    "pirate",
    instructions: "You are a pirate. Speak like a pirate",
    description: "An agent that speaks like a pirate.",
    chatClientServiceKey: "chat-model");

or with the custom delegate on how AIAgent is configured:

builder.AddAIAgent("knights-and-knaves", (sp, key) =>
{
    .... // configure aiAgent
    return aiAgent;
});

Workflows

In order to enable any custom scenario, I've also added a delegate overload to configure workflow:

builder.AddWorkflow("workflow-name", (sp, key) =>
{
   ... // configure workflow
   return workflow;
});

and a couple overloads to configure concurrent or sequential workflows:

builder.AddConcurrentWorkflow("concurrent-workflow", [agent1, agent2]);
builder.AddSequentialWorkflow("sequential-workflow", [agent1, agent2]);

Workflow to Agent

At the moment we dont have a nice API to launch workflow - one would need InProcessExecution.StreamAsync(workflow) for example. In order to simplify exposure of workflow via AIAgent I've also added the extension method available only on the return type of builder.AddWorkflow(...) such as .AddAsAIAgent() which converts the workflow into AIAgent and registers it in DI (with the same or custom name).

Extension API

In order to be able to build extension methods on top of AIAgent or Workflow registrations, I've added such types:

namespace Microsoft.Agents.AI.Hosting;

+ public interface IHostWorkflowBuilder
+ {
+    string Name { get; }
+    IHostApplicationBuilder HostApplicationBuilder { get; }
+ }

+ public interface IHostAgentBuilder
+ {
+    string Name { get; }
+    IHostApplicationBuilder HostApplicationBuilder { get; }
+ }

Those allow distinction between behavior and using extension specific to agents or workflows

@DeagleGross DeagleGross self-assigned this Oct 9, 2025
@markwallace-microsoft markwallace-microsoft added .NET workflows Related to Workflows in agent-framework labels Oct 9, 2025
@DeagleGross DeagleGross marked this pull request as ready for review October 9, 2025 17:04
@Copilot Copilot AI review requested due to automatic review settings October 9, 2025 17:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces hosting extensions for workflow registration in dependency injection containers, providing similar functionality to existing AIAgent registration APIs. The extensions enable configuration of custom, concurrent, and sequential workflows with an additional capability to expose workflows as AIAgents.

  • Adds workflow registration methods (AddWorkflow, AddConcurrentWorkflow, AddSequentialWorkflow) similar to existing AIAgent registration
  • Creates workflow-to-agent conversion capability through AddAsAIAgent extension method
  • Implements workflow discovery infrastructure with WorkflowCatalog and LocalWorkflowRegistry

Reviewed Changes

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

Show a summary per file
File Description
HostApplicationBuilderWorkflowExtensions.cs Core extension methods for registering workflows in DI container
IHostWorkflowBuilder.cs / IHostAgentBuilder.cs New builder interfaces for extensible workflow/agent configuration
AgentWorkflowBuilder.cs Enhanced with PrepareSequential/PrepareConcurrent methods for workflow composition
WorkflowCatalog.cs / LocalWorkflowCatalog.cs Workflow discovery infrastructure similar to existing agent catalog
HostApplicationBuilderAgentExtensions.cs Modified to return IHostAgentBuilder instead of IHostApplicationBuilder
Program.cs Sample implementation demonstrating the new workflow registration APIs
Test files Comprehensive unit tests for the new workflow extension methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@DeagleGross DeagleGross added this pull request to the merge queue Oct 14, 2025
Merged via the queue into main with commit 0331331 Oct 14, 2025
14 checks passed
@crickman crickman deleted the dmkorolev/workflow-extensions branch October 14, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants