NashTech Blog

Microsoft Agent Framework – A Practical Introduction To Building Agents And Agent Workflows

Table of Contents

AI applications are moving beyond single prompt-and-response interactions. Teams now want assistants that can use tools, remember context, coordinate multiple steps, call business systems, and recover when something fails.

Microsoft Agent Framework is Microsoft?s developer framework for building that kind of agentic application. It brings together ideas from Semantic Kernel and AutoGen into a unified framework for agents, workflows, state management, tool integration, middleware, and telemetry. This article explains what Microsoft Agent Framework is, how it works, what you should know before using it, and how to start with a practical first project

What Is Microsoft Agent Framework?

Microsoft Agent Framework is an open-source development framework for building AI agents and agent workflows. It gives developers abstractions for creating agents that use large language models, process user input, call tools, use MCP servers, maintain session state, and generate responses.

The framework offers two primary categories of capability: agents and workflows.

  • Agents: Individual AI components that use a model to process input, reason, call tools, and produce responses. They are useful for open-ended, conversational, or tool-using tasks.
  • Workflows: Graph-based orchestration structures that connect agents and functions for multi-step tasks. They are useful when the process needs explicit routing, checkpointing, branching, human-in-the-loop support, or type-safe coordination.

Microsoft describes Agent Framework as the next generation of both Semantic Kernel and AutoGen. It combines AutoGen-style simple agent abstractions with Semantic Kernel-style enterprise features such as session-based state management, type safety, middleware, filters, telemetry, and broad model support.

Why Microsoft Agent Framework Matters

A direct model call is useful for simple tasks, but many real applications require more than one response. They need repeated interaction, tool use, state, routing, and verification.

For example, a support assistant may need to classify the issue, search knowledge, call a ticketing system, draft a response, ask for human approval, and then update the ticket. That is not just a prompt. It is a workflow with tools, decisions, state, and guardrails.

Microsoft Agent Framework matters because it gives developers a structured way to build these agentic systems while still keeping normal software engineering control over code, types, state, telemetry, and integration boundaries.

How Microsoft Agent Framework Works

The framework is built around a few core concepts: model clients, agents, sessions, tools, context providers, middleware, MCP clients, and workflows. Together, these pieces let a developer move from a simple assistant to a coordinated agent application.

1. Model Clients

Model clients connect the framework to the model provider. Microsoft Agent Framework supports providers such as Microsoft Foundry, Azure OpenAI, OpenAI, Anthropic, Ollama, and others. This gives developers flexibility to choose the model backend that fits their cost, latency, privacy, and capability needs.

Model clients can support chat completions, responses-style APIs, streaming, structured output, and tool calling depending on the provider and implementation.

2. Agents

An agent is the unit that receives input, uses a model, follows instructions, optionally calls tools, and returns a response. A basic agent can behave like a focused assistant. A more advanced agent can use tools, maintain conversation state, and participate in larger workflows.

Agents are best when the task is open-ended, conversational, or requires some autonomous tool use. For example, an agent may help a user investigate a customer issue, summarize a document set, or generate a code review response.

3. Agent Sessions

An agent session manages state across turns. This is important because agent applications are rarely one-shot interactions. A user may ask a question, clarify it, upload a file, ask for a revision, and then request an action. The session helps preserve relevant state so the agent can continue the interaction coherently.

Session management is also important for long-running or human-in-the-loop workflows, where the application needs to pause, resume, or checkpoint progress.

4. Tools And MCP Integration

Tools let agents do more than generate text. A tool might search documents, call an API, run a calculation, query a database, or update a business system. Microsoft Agent Framework also supports MCP clients, which allow agents to connect to tools exposed through Model Context Protocol servers.

Tool integration is powerful, but it must be designed carefully. Tools should have clear names, typed inputs, safe outputs, and permission boundaries. A well-designed tool is easier for the agent to use and easier for humans to audit.

5. Context Providers And Memory

Context providers supply relevant information to the agent. This can include conversation history, retrieved documents, user profile data, application state, or domain-specific memory. The goal is to give the agent the right information at the right time without overloading the model context.

Good memory design helps the agent stay grounded, avoid repeated questions, and produce answers that reflect the current task state.

6. Middleware

Middleware intercepts or extends agent behavior. It can be used for logging, tracing, policy enforcement, content filtering, tool-call inspection, retries, or custom business rules. This is one of the ways the framework supports production-grade control around agent behavior.

Middleware is especially useful when teams want reusable safeguards across many agents instead of copying the same logic into every prompt or tool.

7. Workflows

Workflows are graph-based orchestrations that connect agents and functions. They are useful when the process has defined steps or when multiple agents and functions must coordinate. Workflows can support sequential execution, branching, concurrent work, checkpointing, and human-in-the-loop paths.

Microsoft?s guidance is simple: use an agent when the task is open-ended or conversational; use a workflow when the process has well-defined steps or needs explicit control over execution order. If a normal function can solve the task, write a function instead of using an AI agent.

8. Hosting With Microsoft Foundry

Agent Framework can integrate with Microsoft Foundry. Developers can use Foundry model endpoints directly, work with service-managed Foundry agents, or deploy Agent Framework agents as hosted agents in Microsoft Foundry Agent Service.

Hosted agents let developers package an Agent Framework agent or workflow and deploy it to Microsoft-managed infrastructure. Foundry can handle scaling, session state persistence, security, identity, and lifecycle management so the team can focus more on the agent logic.

Agents Vs Workflows

One of the most important design decisions is whether to use an agent or a workflow.

Use an agent when:

  • The task is open-ended or conversational.
  • The agent needs to choose tools dynamically.
  • A single assistant can reasonably handle the task.
  • The path to completion may change depending on user input or intermediate results.

Use a workflow when:

  • The process has known stages.
  • You need explicit control over order, branching, or concurrency.
  • Multiple agents or functions must coordinate.
  • You need checkpointing, human approval, or strong state transitions.

This distinction matters because not every problem should become an autonomous agent. Sometimes a simple function, rule, or workflow step is more reliable, cheaper, and easier to test.

Common Use Cases

Microsoft Agent Framework can be used for many agentic application patterns, including:

  • Customer support agents that search knowledge, classify intent, and draft responses.
  • Research assistants that gather information, summarize evidence, and produce structured reports.
  • Developer agents that inspect code, run tools, and assist with maintenance tasks.
  • Business process agents that coordinate approvals, API calls, and document generation.
  • Multi-agent workflows where specialized agents handle planning, retrieval, analysis, review, and final response generation.
  • Microsoft 365 agents that use Agent Framework as the orchestration layer while relying on Microsoft 365 Agents SDK for channels and conversation management.

Prerequisites For Learning Microsoft Agent Framework

You do not need to be an AI researcher to start, but you should be comfortable with application development and basic AI concepts.

  • Programming skills: Be comfortable in C#/.NET or Python, since these are the main ecosystems where Microsoft agent tooling is commonly used.
  • LLM fundamentals: Understand prompts, context windows, tool calling, structured outputs, model selection, and why hallucination happens.
  • Async and API development: Know how to call APIs, handle errors, work with asynchronous operations, and manage request/response flows.
  • Basic cloud knowledge: Understand Azure resources, identity, environment variables, secrets, and deployment environments if you plan to use Microsoft Foundry or Azure OpenAI.
  • Testing mindset: Know how to create repeatable test cases and evaluate behavior rather than trusting one good demo response.
  • Security awareness: Understand least privilege, prompt injection, secrets handling, and the risks of letting agents call tools or external services.

How To Start

The best way to start is to build one small agent first, then gradually add tools, sessions, workflows, and hosting. Avoid beginning with a complex multi-agent system. Learn the primitives before building the orchestra.

Step 1: Choose A Small Use Case

Pick a focused task such as a document Q&A assistant, issue triage helper, policy lookup bot, code review helper, meeting summary assistant, or internal research assistant. The task should have clear inputs, clear outputs, and simple success criteria.

Step 2: Create A Basic Agent

Start with a single agent that has clear instructions and one model provider. The first version should not need many tools. The goal is to learn how the framework represents agents, model clients, sessions, and responses.

Step 3: Add One Tool

Add a safe, simple tool such as a calculator, document search function, ticket lookup function, or internal API read operation. Make the tool narrow and typed. Test whether the agent knows when to call it and how to use its output.

Step 4: Add Session State

Introduce an agent session so the agent can maintain useful context across turns. Test follow-up questions and corrections. Check whether the agent remains grounded or starts drifting away from the original task.

Step 5: Add Middleware

Add middleware for logging, tracing, policy checks, or tool-call inspection. This turns the agent from a black box into an observable component. You should be able to inspect what the agent tried to do and why a run succeeded or failed.

Step 6: Convert Repeated Steps Into A Workflow

If your task has a stable sequence, move that sequence into a workflow. For example: classify request, retrieve context, draft answer, review safety, ask for approval, then send response. A workflow gives stronger control than asking one agent to improvise every step.

Step 7: Evaluate The Agent

Create a small eval set with normal cases, edge cases, and unsafe requests. Measure whether the agent uses tools correctly, follows instructions, avoids unsupported claims, and gives consistent results across repeated runs.

Step 8: Deploy Or Integrate

Once the local version works, decide how it should be exposed. You may integrate it into an application, connect it with Microsoft 365 Agents SDK, or deploy it through Microsoft Foundry Agent Service if you want managed hosting and enterprise controls.

Picture of Hai Hoang

Hai Hoang

Engineering Manager at NashTech VN

Leave a Comment

Your email address will not be published. Required fields are marked *

Suggested Article

Scroll to Top