Velamuvi AIAcademy

Lesson 1 of 39 · Getting Started

What Is Microsoft Agent Framework?

What Microsoft Agent Framework is: the successor to Semantic Kernel and AutoGen, agents vs workflows, its Python packages, versions and experimental features.

  • 12 min read
  • Intermediate
  • Reviewed
In this lesson you will learn
  • Explain what Microsoft Agent Framework is and where it came from
  • Tell agents and workflows apart, and choose between them
  • Know which Python packages to install and how integrations are imported
  • Check the installed version and recognise experimental features
  • Find your way around the rest of this course

One framework for agents and workflows

You have seen what an AI agent is: a language model that reads a goal, decides what to do, calls tools and keeps going until the job is done. Writing all of that by hand means a lot of plumbing: talking to model APIs, running tools, remembering the conversation, logging what happened, retrying, pausing for a person. A framework does that plumbing for you.

In this course we call it Agent Framework for short. Everything here uses the Python version, which needs Python 3.11 or newer. The .NET version has the same ideas with C# names.

Where it came from

Microsoft had two popular agent projects:

  • AutoGen, from Microsoft Research: simple agent abstractions and multi-agent patterns, such as group chats.
  • Semantic Kernel: the enterprise side: many model connectors, filters around every call, telemetry, typed plugins and session state.

Agent Framework is built by the same teams and combines both. Microsoft describes it as the successor to Semantic Kernel and AutoGen and publishes a migration guide from each. The AutoGen repository is now archived and points new users here. The lesson Migrating From AutoGen and Semantic Kernel, near the end of this course, shows how code from each maps onto Agent Framework.

The two building blocks

Agent Framework gives you two ways to build, and most real systems use both.

Here is the difference in plain Python, with a stand-in for the model:

Try it yourselfPython
# An AGENT decides its next step while it runs. A WORKFLOW follows steps you wired up in advance.
# Plain-Python stand-ins: fake_model plays the role of the language model.
def fake_model(goal, done):
    """Pick the next useful step for this goal, or "finish"."""
    for step in ["check weather", "find route", "book bike"]:
        topic = step.split()[1]
        if topic in goal and step not in done:
            return step
    return "finish"

def agent(goal):
    done = []
    while (step := fake_model(goal, done)) != "finish":    # the model chooses every step
        done.append(step)
    return done

def workflow(goal):
    return ["check weather", "find route", "book bike"]     # the same steps every time

for goal in ["weather for Sunday?", "a route and a bike, please"]:
    print(f"{goal}\n   agent:    {agent(goal)}\n   workflow: {workflow(goal)}")

The agent only did what each goal needed. The workflow did the same three steps every time: less flexible, but predictable, easy to test and easy to explain to an auditor.

An agent

import asyncio
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient

async def main():
    agent = Agent(
        client=OpenAIChatClient(model="MODEL_NAME"),       # reads OPENAI_API_KEY from the environment
        name="trip_helper",
        instructions="You help people plan short bike trips. Answer in one sentence.",
    )
    response = await agent.run("Is 40 km too far for a first day trip?")
    print(response.text)

asyncio.run(main())
Output
Not if the route is flat: 40 km is about three hours of easy riding with breaks.

Agent takes a chat client (the connection to a model provider), a name and instructions. await agent.run(...) sends your message and returns a response. Agent Framework is asynchronous, so the code runs inside async def main() and is started with asyncio.run(main()). MODEL_NAME is a placeholder: copy a current model name from your provider's documentation. Running this needs an OpenAI API key, which is a paid service; the next lesson shows every provider, including free local ones.

A workflow

import asyncio
from typing import Never
from agent_framework import Workflow, WorkflowBuilder, WorkflowContext, executor

@executor(id="clean")
async def clean(text: str, ctx: WorkflowContext[str]) -> None:
    await ctx.send_message(" ".join(text.split()))          # hand the result to the next step

@executor(id="count")
async def count(text: str, ctx: WorkflowContext[Never, int]) -> None:
    await ctx.yield_output(len(text.split()))               # an output of the whole workflow

workflow: Workflow = WorkflowBuilder(start_executor=clean).add_edge(clean, count).build()

async def main():
    result = await workflow.run("  Agents   decide,  workflows   follow a plan. ")
    print(result.get_outputs())

asyncio.run(main())
Output
[6]

Two executors (steps) are joined by an edge. WorkflowBuilder wires them up and build() returns a Workflow. The first step cleans the text and sends it on with ctx.send_message; the second counts the words and returns the result with ctx.yield_output. No model is involved here, but any step could call an agent.

Use an agent whenUse a workflow when
The steps depend on the request and can't be listed in advanceThe steps are known and must always happen in order
A conversation with a person is the main jobSeveral agents or systems must hand work to each other in a fixed way
Some unpredictability is acceptableYou need to pause for approval, resume after a crash, or audit every step

The packages

Agent Framework is split into a small core and many optional integration packages.

InstallWhat you get
pip install agent-frameworkEverything: the core plus every standard integration. Best for learning, and what this course assumes
pip install agent-framework-coreThe core only: agents, tools, sessions, middleware, telemetry and workflows. No model provider
pip install agent-framework-openaiThe core plus OpenAI and Azure OpenAI clients
pip install agent-framework-orchestrationsReady-made multi-agent patterns (sequential, concurrent, group chat, handoff, Magentic)
pip install agent-framework-foundry, -anthropic, -gemini, -ollama, ...One package per provider or service

Whatever you install, you always import from agent_framework. Integrations live in sub-modules such as agent_framework.openai, agent_framework.anthropic or agent_framework.orchestrations, which load their package the first time you use them.

python -m venv .venv
source .venv/bin/activate          # on Windows: .venv\Scripts\activate
pip install agent-framework

Some integrations are previews: their versions contain a letter, such as 1.0.0b261112 (b for beta). Microsoft's instructions add --pre when installing a preview package on its own, for example pip install --pre agent-framework-copilotstudio. The agent-framework bundle pulls in the right preview versions for you.

Versions and feature stages

Agent Framework changes quickly, so always know which version you are using. This course was written and tested with version 1.26.0.

import agent_framework
from agent_framework import ExperimentalFeature, FileHistoryProvider, ReleaseCandidateFeature

print(agent_framework.__version__)
print([feature.value for feature in ExperimentalFeature][:4], "...")
print(list(ReleaseCandidateFeature))
print(getattr(FileHistoryProvider, "__feature_stage__", "stable"), getattr(FileHistoryProvider, "__feature_id__", None))
print(getattr(agent_framework.Agent, "__feature_stage__", "stable"))
Output
1.26.0
['AGENT_TRIGGERED_COMPACTION', 'AGENT_HOOKS', 'COMPUTER_USE', 'DECLARATIVE_AGENTS'] ...
[]
experimental FILE_HISTORY
stable

Every API has a stage:

  • Stable: most of the framework, like Agent. Safe to build on.
  • Release candidate: almost final, may still get small changes. ReleaseCandidateFeature lists them; in 1.26.0 the list is empty.
  • Experimental: new and allowed to change or disappear without notice. ExperimentalFeature lists their IDs, for example FILE_HISTORY, HARNESS, FUNCTIONAL_WORKFLOWS and EVALS.

An experimental API marks itself with __feature_stage__ and __feature_id__, and the first time you use it, Python prints a warning:

Output
app.py:3: ExperimentalWarning: [FILE_HISTORY] FileHistoryProvider is experimental and may change or be removed in future versions without notice.

Read it, decide whether the risk is fine for your project, and if so, hide it for that one feature:

import tempfile
import warnings
from agent_framework import FileHistoryProvider

warnings.filterwarnings("ignore", message=r"\[FILE_HISTORY\]")   # hide this one feature's warning
history = FileHistoryProvider(tempfile.mkdtemp())                  # no warning printed now
print(type(history).__name__, "created")

How this course is organised

PartWhat you will learn
Getting StartedInstalling, connecting to model providers, your first agent, messages and streaming, other agent types
ToolsFunction tools, approvals, hosted tools, shell and sandboxed code, MCP, agents as tools
Sessions, Memory and ContextMulti-turn chat, history storage, compaction, long-term memory, RAG, skills
The Agent HarnessReady-made agents with to-do lists, modes, file memory and background work
Control, Safety and QualityStructured output, middleware, security, OpenTelemetry, evaluations, DevUI
WorkflowsExecutors and edges, branching and loops, state, functional workflows, human input, checkpoints
OrchestrationsSequential, concurrent, group chat, handoff and Magentic patterns
ProductionDeclarative YAML, hosting protocols, migration, a production checklist and a final project

The code that calls a model is shown with a placeholder model name and needs an API key, as above. Each example was run with the real framework, and the output shown is a real run in which the model's replies came from a scripted test model, so your model's exact words will differ.

Common mistakes

Practice exercise

Find the preview packages in a list of installed versions.

Your solutionPython
packages = {
    "agent-framework-core": "1.26.0",
    "agent-framework-openai": "1.18.2",
    "agent-framework-anthropic": "1.0.0b261112",
    "agent-framework-orchestrations": "1.4.2",
    "agent-framework-copilotstudio": "1.0.0b261106",
}

# A preview package has a letter in its version, like the b (beta) in 1.0.0b261112.
# Print each preview package as "<name> (preview)", one per line, in the order above.
Knowledge check

An insurer must run every claim through the same five checks in a fixed order, with a person approving large payouts. What fits best?

Summary

  • Agent Framework is Microsoft's open-source framework for agents and multi-agent workflows, the successor to Semantic Kernel and AutoGen.
  • An agent lets the model choose the steps; a workflow follows a graph of steps you define. Real systems often combine them.
  • pip install agent-framework installs everything; agent-framework-core plus single integration packages keeps installs small. You always import from agent_framework.
  • Check agent_framework.__version__, pin it in production, and watch for experimental features listed in ExperimentalFeature.

Next: Installation, Settings and Chat Clients.

Finished reading? Tick it off to track your progress.