On .NET Live - Demystifying Microsoft Agent Framework Middleware
Daniel Costea walks through how he uses ChatClient and Microsoft Agent Framework middleware to turn plain .NET AI agents into production-ready systems with observability, safety, and cost control.
Overview
The session starts from a simple agent that talks directly to an LLM, then steps through common real-world failure modes (for example: cost spikes, privacy leaks, and unsafe tool calls). Costea then layers middleware components to address those issues, mapping the concepts back to the familiar ASP.NET Core middleware pattern so .NET developers can reuse an existing mental model.
Key concepts covered
ChatClient and agent middleware architecture
- How a basic agent setup changes when you introduce middleware layers.
- How middleware can be composed to shape requests/responses and tool/function execution.
Middleware types and composition
- Discussion of three middleware types and how they fit into the pipeline.
- How to mix and order ChatClient middleware types to get the behavior you want.
FunctionCalling middleware and the interceptor-executor pattern
- FunctionCalling middleware is presented using an interceptor-executor pattern.
- Focus on controlling and validating tool/function calls to reduce unsafe behavior.
Visibility and safety boundaries
- What each middleware type can “see” in the pipeline.
- How that visibility affects privacy, safety, and observability decisions.
People featured
- Daniel Costea
- Katie Savage
- Scott Addie
- Frank Boucher
Links
- AgentFrameworkBook repository: https://github.com/dcostea/AgentFrameworkBook