In the previous blog posts we ported a Python implementation of an agentic application to C# and Microsoft Agent Framework. We used interfaces, but we did not use Dependency Injection (DI). It is pretty easy to add.

Agents, tools, executors and workflows all depend on interfaces, and DI depends on registering the relationship between these interfaces and the concrete class that implements them.
For example, here is how you create a workflow
services.AddSingleton<Workflow>(sp =>
{
var blogger = sp.GetRequiredService<BloggerExecutor>();
var researcher = sp.GetRequiredService<ResearcherExecutor>();
var author = sp.GetRequiredService<AuthorExecutor>();
var reviewer = sp.GetRequiredService<ReviewerExecutor>();
return new WorkflowBuilder(blogger)
.AddEdge(blogger, researcher)
.AddEdge(researcher, author)
.AddEdge(author, reviewer)
.AddEdge<ResearchState>(reviewer, author, s => s?.NeedsRevision == true)
.WithOutputFrom(reviewer)
.Build();
});
Continue reading












































