Chapter 2C
Microsoft Agent Framework
Workshop (Setup) - Microsoft Agent Framework
Microsoft Agent Framework (MAF) is an open-source, code-first framework from Microsoft for building AI agents and multi-agent workflows in .NET and Python.
MAF offers two primary capability areas:
- Agents: individual agents that use LLMs to process inputs, call tools and MCP servers, maintain sessions, and generate responses across providers such as Microsoft Foundry, Azure OpenAI, OpenAI, Anthropic, and Ollama.
- Workflows: graph-based workflows that connect agents and normal functions for multi-step tasks with type-safe routing, checkpointing, and human-in-the-loop support.
The framework also includes model clients, agent sessions for state management, context providers for memory, middleware for intercepting agent actions, and MCP clients for tool integration.
MAF is an orchestration layer between your application experiences and model providers.
Use the two execution styles intentionally:
- Use an agent when the task is open-ended or conversational, needs autonomous tool use and planning, or can be solved by a single LLM call with optional tools.
- Use a workflow when the process has well-defined steps, requires explicit execution order, or coordinates multiple agents and functions.
- If you can write a normal deterministic function to handle the task, prefer that function over an AI agent.
This combination lets you blend flexible agent behavior with deterministic process control in one architecture.
How MAF Builds on Microsoft.Extensions.AI (MEAI)¶
MAF builds on the MEAI ecosystem instead of replacing it. MEAI gives .NET developers unified abstractions for generative AI components, while MAF adds agent and workflow orchestration on top.
- Shared model abstractions: MEAI standardizes provider access through abstractions such as
IChatClient,IEmbeddingGenerator<TInput,TEmbedding>, and the experimentalIImageGenerator. - Provider portability: consuming applications usually reference
Microsoft.Extensions.AIplus one or more provider-specific packages, while libraries can referenceMicrosoft.Extensions.AI.Abstractions. - Middleware composition: MEAI supports familiar dependency injection and middleware patterns for automatic function invocation, telemetry, caching, and other cross-cutting concerns.
- Agent orchestration: MAF uses MEAI-style model clients and middleware patterns, then adds
AIAgent, sessions, tools, MCP integration, context providers, workflows, and hosting support. - Operational observability: MAF runtime events and tracing can fit into the same OpenTelemetry-first operating model commonly used with MEAI.
Typical setup packages and concepts:
- .NET Agent Framework: current Microsoft Learn examples use packages such as
Microsoft.Agents.AI.Foundry --prerelease; other scenarios may add packages such asMicrosoft.Agents.AI,Microsoft.Agents.AI.Workflows, or hosting integrations. - Python Agent Framework: install with
pip install agent-frameworkand use provider integrations such asagent_framework.foundry. - MEAI application code: reference
Microsoft.Extensions.AIplus a concrete provider implementation such as OpenAI, Azure OpenAI, Ollama, Foundry Local, or another compatible client. - Core MAF building blocks:
AIAgent/agent abstractions, sessions, context providers, tools, MCP clients, middleware, and graph workflow routing.
These building blocks make it practical to move from simple agent interactions to enterprise decision orchestration without hard-coding the application to one provider.
Current Microsoft Resources¶
- Microsoft Agent Framework Overview: https://learn.microsoft.com/en-us/agent-framework/overview/
- Get Started with Agent Framework: https://learn.microsoft.com/en-us/agent-framework/get-started/
- Agents Overview: https://learn.microsoft.com/en-us/agent-framework/agents/
- Workflows Overview: https://learn.microsoft.com/en-us/agent-framework/workflows/
- Microsoft.Extensions.AI Libraries Overview: https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai
- Migration Guide from Semantic Kernel: https://learn.microsoft.com/en-us/agent-framework/migration-guide/from-semantic-kernel/
- Migration Guide from AutoGen: https://learn.microsoft.com/en-us/agent-framework/migration-guide/from-autogen/
- GitHub Repo: https://github.com/microsoft/agent-framework (.NET, Python)
- Introducing Microsoft Agent Framework (Microsoft Foundry Blog): https://devblogs.microsoft.com/foundry/introducing-microsoft-agent-framework-the-open-source-engine-for-agentic-ai-apps/
- Introducing Microsoft Agent Framework Preview (.NET Blog): https://devblogs.microsoft.com/dotnet/introducing-microsoft-agent-framework-preview/