.NET [WIP]: introduce Hosting extensions for Workflows (#1359)

* skeleton

* wip

* rename + fix tests

* implement workflow tests

* fix comments

* Update dotnet/src/Microsoft.Agents.AI.Hosting/HostApplicationBuilderWorkflowExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fixes

* fix worfklow build logic

* rollback + new overload on workflow builder

* address PR comments

* :)

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Korolev Dmitry
2025-10-14 19:44:58 +00:00
committed by GitHub
co-authored by Copilot
parent f42a3ee6b9
commit 0331331dbc
18 changed files with 678 additions and 107 deletions
@@ -66,6 +66,25 @@ builder.AddAIAgent("knights-and-knaves", (sp, key) =>
#pragma warning restore VSTHRD002
});
// Workflow consisting of multiple specialized agents
var chemistryAgent = builder.AddAIAgent("chemist",
instructions: "You are a chemistry expert. Answer thinking from the chemistry perspective",
description: "An agent that helps with chemistry.",
chatClientServiceKey: "chat-model");
var mathsAgent = builder.AddAIAgent("mathematician",
instructions: "You are a mathematics expert. Answer thinking from the maths perspective",
description: "An agent that helps with mathematics.",
chatClientServiceKey: "chat-model");
var literatureAgent = builder.AddAIAgent("literator",
instructions: "You are a literature expert. Answer thinking from the literature perspective",
description: "An agent that helps with literature.",
chatClientServiceKey: "chat-model");
builder.AddSequentialWorkflow("science-sequential-workflow", [chemistryAgent, mathsAgent, literatureAgent]).AddAsAIAgent();
builder.AddConcurrentWorkflow("science-concurrent-workflow", [chemistryAgent, mathsAgent, literatureAgent]).AddAsAIAgent();
var app = builder.Build();
app.MapOpenApi();
@@ -92,6 +111,10 @@ app.MapOpenAIResponses("knights-and-knaves");
app.MapOpenAIChatCompletions("pirate");
app.MapOpenAIChatCompletions("knights-and-knaves");
// workflow-agents
app.MapOpenAIResponses("science-sequential-workflow");
app.MapOpenAIResponses("science-concurrent-workflow");
// Map the agents HTTP endpoints
app.MapAgentDiscovery("/agents");