Microsoft Agent Framework, hands-on: build a local multi-agent team on Ollama — no API key, no cloud
Microsoft Agent Framework is the production successor to AutoGen and Semantic Kernel — and it runs on a local Ollama model for $0. This tutorial builds a three-agent briefing team (researcher, critic, writer) with real tools, structured output, streaming, sessions, and a sequential orchestration, and verifies every step.
- Packages (pinned):
agent-framework-core==1.26.0,agent-framework-ollama==1.0.0b261112(beta),agent-framework-orchestrations==1.4.2. Theagent-frameworkmeta-package pulls every provider, including a 178 MB Claude SDK wheel — install the pieces you need instead. - Model:
qwen3:4bvia Ollama (llama3.2also works). Always passmodel=explicitly — the no-argumentOllamaChatClient()in the docs only works whenOLLAMA_MODELis set. - Orchestration is a separate install: sequential, concurrent, handoff, group-chat, and Magentic-One patterns live in
agent-framework-orchestrations(1.4.2), not in the core. - Verified in a sandbox: all 10 checks passed — tool execution, structured output parsing, streaming, sessions, the three-agent sequential run (which wrote the briefing file), Ollama client construction rules, and a live MCP filesystem server that returned real file contents. Model replies were scripted; no Ollama daemon or GPU was on the test machine.
- Honest limit: Ollama has no hosted tools (no web search, file search, or code interpreter), and a 4B model fumbles tool chains a frontier model handles cleanly — keep each agent's job narrow.

Microsoft spent 2025 with two agent frameworks — Semantic Kernel for enterprise apps, AutoGen for multi-agent research — and in April 2026 it folded both into one: Microsoft Agent Framework hit 1.0, and the AutoGen and Semantic Kernel lines now point at it as the successor. Version 1.26.0, released November 12, 2026, is the current release. This tutorial builds a working multi-agent team on it, end to end, with a local model and no API key: a researcher, a critic, and a writer that turn a file of rough notes into a saved morning briefing. You will use real tools, structured output, streaming, sessions, and a sequential orchestration — the five pieces that make up most production agent work.
Everything here runs against Ollama on your own machine, so the whole exercise costs $0 and your notes never leave your disk. Every code block below was executed against agent-framework 1.26.0 in a sandbox with a scripted stand-in for the model (the test machine had no Ollama daemon and no GPU); the Ollama commands themselves are Microsoft's documented path, and the one place the docs and the installed code disagree is called out where it matters.
What you'll need#
- Python 3.11 or newer. The packages require
>=3.11. Check withpython3 --version. - Ollama installed and running (ollama.com), plus a model that supports tool calling. Microsoft's docs recommend
llama3.2orqwen3:4b; this tutorial usesqwen3:4b, a 4-billion-parameter model and a download of a few gigabytes. - Three pip packages, pinned:
agent-framework-core==1.26.0,agent-framework-ollama==1.0.0b261112(beta), andagent-framework-orchestrations==1.4.2. Pin them — the Ollama provider is still a beta with date-stamped releases, and the framework ships weekly. - No accounts, no API keys, no cloud bill for the Ollama path. Step 7 shows the one-line swap to OpenAI if you want a hosted model later.
One thing to know before you install: pip install agent-framework installs the meta-package, which pulls every provider — Foundry, OpenAI, Anthropic, Bedrock, Gemini, Redis, Mem0, and a 178 MB Claude Agent SDK wheel among them. In this tutorial's sandbox that install died partway through downloading. For local work, install the pieces you actually need instead. It is faster, smaller, and exactly what the rest of this tutorial uses.
Step 1: Install the stack#
Create a project folder and a virtual environment, then install the three packages:
mkdir maf-briefing && cd maf-briefing
python3 -m venv .venv
.venv/bin/pip install "agent-framework-core==1.26.0" \
"agent-framework-ollama==1.0.0b261112" \
"agent-framework-orchestrations==1.4.2"
Verify the install and confirm the versions:
.venv/bin/pip list | grep -i -E "agent-framework|ollama|pydantic"
.venv/bin/python -c "import agent_framework; print('import ok')"
Expected output:
agent-framework-core 1.26.0
agent-framework-ollama 1.0.0b261112
agent-framework-orchestrations 1.4.2
ollama 0.6.4
pydantic 2.14.4
import ok
Then pull the model and confirm Ollama can see it:
ollama pull qwen3:4b
ollama list
Two gotchas, both found the hard way. First, Microsoft's docs show OllamaChatClient() with no arguments — that only works if the OLLAMA_MODEL environment variable is set. Without it, construction raises SettingNotFoundError: Required setting 'model' was not provided. Always pass model= explicitly, as every snippet below does. Second, if you run in a sandboxed or CI environment with proxy variables set, importing the Ollama client can fail with httpx.InvalidURL: the underlying ollama package builds an HTTP client at import time and chokes on some proxy values. Clear the proxy variables for the import (or run outside the proxied shell) and it goes away.
Step 2: Your first agent#
An agent in this framework is three things: a chat client, instructions, and optionally tools. Save this as hello.py:
import asyncio
from agent_framework import Agent
from agent_framework.ollama import OllamaChatClient
async def main() -> None:
agent = Agent(
client=OllamaChatClient(model="qwen3:4b"),
name="HelloAgent",
instructions="You are a friendly assistant.",
)
result = await agent.run("Write a haiku about shipping 1.0.")
print(result.text)
if __name__ == "__main__":
asyncio.run(main())
.venv/bin/python hello.py
That is the whole "hello world": Agent takes the client as its first argument, instructions is the system prompt, and agent.run() returns a response whose .text is the model's reply. Two details worth noticing now because they recur all through the tutorial. First, run() is async — everything in this framework is async, so your scripts need the asyncio.run(main()) wrapper. Second, the client is interchangeable: every chat client in the framework satisfies the same protocol, so the agent you just built accepts an OpenAI, Anthropic, or Bedrock client with no other change. Step 7 uses that.
Before going further, create the notes file the team will work from. Save this as notes.md in the same folder — it is sample data; replace it with your own notes and the tutorial still works:
## 2026-12-01 — Agent Framework 1.0 follow-ups
Microsoft Agent Framework hit 1.0 in April 2026 and is now at 1.26.0
(released November 12, 2026). It is the supported successor to AutoGen and
Semantic Kernel, with first-party connectors for Foundry, Azure OpenAI,
OpenAI, Anthropic, Bedrock, Gemini, and Ollama.
## 2026-12-01 — Local models keep getting better at tool use
The docs recommend llama3.2 or qwen3:4b for tool calling through Ollama.
Small models still fumble multi-step tool chains; keep each agent's job
narrow and verify tool results before acting on them.
## 2026-12-02 — Orchestration is a separate install
Sequential, concurrent, handoff, group-chat, and Magentic-One patterns live
in the agent-framework-orchestrations package (1.4.2), not in the core.
Install it separately or the import tells you exactly that.
Step 3: Give it tools that do real work#
Tools are plain Python functions decorated with @tool. The framework reads the function signature and docstring to build the tool schema the model sees, runs the function when the model calls it, and feeds the result back into the conversation — the whole loop is automatic. Two tools carry this tutorial: one reads the notes, one saves the finished briefing.
from pathlib import Path
from agent_framework import Agent, tool
from agent_framework.ollama import OllamaChatClient
NOTES = Path("notes.md")
OUT = Path("briefing.md")
@tool
def read_notes() -> str:
"""Read the raw research notes file and return its full text."""
return NOTES.read_text()
@tool
def save_briefing(title: str, body: str) -> str:
"""Save the finished briefing to briefing.md and confirm the path."""
OUT.write_text(f"# {title}\n\n{body}\n")
return f"Saved briefing to {OUT}"
Wire the reading tool into an agent. Put both blocks in one file, researcher.py — the second block uses the tools defined in the first:
import asyncio
async def main() -> None:
researcher = Agent(
client=OllamaChatClient(model="qwen3:4b"),
name="researcher",
instructions=(
"You read the notes with read_notes and extract the three most "
"important items. Quote numbers and dates exactly as written. "
"Do not add anything that is not in the notes."
),
tools=[read_notes],
)
result = await researcher.run(
"What are the three most important items in the notes?"
)
print(result.text)
if __name__ == "__main__":
asyncio.run(main())
.venv/bin/python researcher.py
The model calls read_notes (you can watch the round trip if you add a print inside the tool), then answers from the file contents — not from its training data. Three things about tools that will save you debugging time later:
- The docstring is the tool's documentation for the model. Write it as an instruction to the model, not a note to yourself. A vague docstring is the most common reason a small model picks the wrong tool or the wrong arguments.
- Tools can be a single callable, not just a list.
tools=read_notesworks as well astools=[read_notes]. - Approval modes exist for dangerous tools.
@tool(approval_mode="never_require")is the default posture for harmless reads; a tool that deletes or publishes should use the default approval flow, which pauses the run for a human decision. The framework also supports per-call approval callbacks if you need them.
One honest limit: with Ollama there are no hosted tools — no code interpreter, file search, or web search runs on the provider side, because there is no provider side. Function tools and local MCP tools (Step 8) are what you get, and for local work they are the right ones. Also note the native Ollama client supports tool_choice values auto and none only; asking for required raises an error, because Ollama cannot enforce it.

Step 4: Get structured output back#
Free text is fine for a chat reply and useless for a pipeline. When the next step in your program needs to use the model's answer, ask for a shape, not a paragraph. Define a Pydantic model and pass it as response_format in ChatOptions:
import asyncio
from agent_framework import Agent, ChatOptions
from agent_framework.ollama import OllamaChatClient
from pydantic import BaseModel
class Briefing(BaseModel):
"""Structured shape for a finished briefing."""
title: str
items: list[str]
bottom_line: str
async def main() -> None:
formatter = Agent(
client=OllamaChatClient(model="qwen3:4b"),
name="formatter",
instructions="Rewrite the given text as a structured briefing.",
default_options=ChatOptions(response_format=Briefing),
)
result = await formatter.run(
"Format this as a briefing: Agent Framework 1.26.0 is out, local "
"tool use works with qwen3:4b, orchestrations ship separately."
)
briefing = result.value
print(briefing.title)
print(briefing.items)
print(briefing.bottom_line)
if __name__ == "__main__":
asyncio.run(main())
result.value is a real Briefing instance, not a string you have to parse — the framework validates the model's JSON against the model and hands you the object. Two practical notes. First, response_format lives on ChatOptions, and you can pass options per-agent with default_options= (as above) or per-call with agent.run(message, options=ChatOptions(...)). Second, small local models are the weak point here: a 4B model will occasionally return malformed JSON or add commentary around it. If result.value comes back unparsed, tighten the instructions ("Reply with JSON only, no other text"), retry once, and keep the schema small — three fields with short types is about the right size for this class of model.
Step 5: The three-agent team#
One agent that reads, judges, and writes is one agent doing three jobs badly. Split the work: a researcher extracts, a critic checks, a writer produces the final text and saves it. The sequential orchestration runs them in order, passing each agent's output to the next. It lives in the separate agent-framework-orchestrations package you installed in Step 1 — importing it from the core raises an error telling you exactly which package to install, which is how the split was discovered.
import asyncio
from pathlib import Path
from agent_framework import Agent, tool
from agent_framework.ollama import OllamaChatClient
from agent_framework.orchestrations import SequentialBuilder
NOTES = Path("notes.md")
OUT = Path("briefing.md")
@tool
def read_notes() -> str:
"""Read the raw research notes file and return its full text."""
return NOTES.read_text()
@tool
def save_briefing(title: str, body: str) -> str:
"""Save the finished briefing to briefing.md and confirm the path."""
OUT.write_text(f"# {title}\n\n{body}\n")
return f"Saved briefing to {OUT}"
def build_client():
return OllamaChatClient(model="qwen3:4b")
async def main() -> None:
client = build_client()
researcher = Agent(
client=client,
name="researcher",
instructions=(
"You read the notes with read_notes and extract the three most "
"important items. Quote numbers and dates exactly as written. "
"Do not add anything that is not in the notes."
),
tools=[read_notes],
)
critic = Agent(
client=client,
name="critic",
instructions=(
"You check a draft briefing against the notes. List anything in "
"the draft that the notes do not support, and anything important "
"in the notes that the draft missed. Be specific and brief."
),
)
writer = Agent(
client=client,
name="writer",
instructions=(
"You turn the reviewed draft into a tight morning briefing and "
"save it with save_briefing. Keep it under 150 words."
),
tools=[save_briefing],
)
workflow = SequentialBuilder(participants=[researcher, critic, writer]).build()
result = await workflow.run("Turn the notes into a morning briefing.")
final = result.get_outputs()[-1]
print(final.text)
print("---")
print(OUT.read_text())
if __name__ == "__main__":
asyncio.run(main())
Save this as briefing_team.py and run it. The researcher reads notes.md through its tool, the critic checks the draft, the writer saves briefing.md — and the printed output shows the writer's final message followed by the saved file. The finished file looks like this:
# Morning briefing
Agent Framework 1.26.0 is out. Use qwen3:4b for tool calls.
Orchestrations install separately.
A few things about the orchestration API that are easy to get wrong. SequentialBuilder takes participants= as a keyword argument, and .build() returns a Workflow. A plain await workflow.run(...) returns a WorkflowRunResult; result.get_outputs() gives you the final agent responses (one per terminal participant — here, just the writer's). If you want live progress instead, pass stream=True and read event.data.text on the events whose event.type == "output" — those carry AgentResponseUpdate deltas, not message lists, which is a change from the 1.0 announcement's example. The same builder family covers the other patterns: ConcurrentBuilder fans out to several agents at once, HandoffBuilder lets agents pass control to each other, GroupChatBuilder runs a moderated discussion, and MagenticBuilder implements the Magentic-One research pattern. Start with sequential; it is the only one where the output order is deterministic, which is what you want while you are still debugging prompts.

Step 6: Streaming and sessions#
Two behaviors every real agent needs: showing partial output as it arrives, and remembering earlier turns. Both are one call each. Add both functions to briefing_team.py from Step 5 — the imports and the tools are already there.
Streaming. Pass stream=True to run() and iterate the updates:
async def streaming_demo() -> None:
agent = Agent(
client=OllamaChatClient(model="qwen3:4b"),
instructions="You are a helpful assistant.",
)
print("Agent: ", end="", flush=True)
async for chunk in agent.run("Tell me about Python.", stream=True):
if chunk.text:
print(chunk.text, end="", flush=True)
print()
Each chunk is an AgentResponseUpdate; guard on chunk.text because some updates carry tool calls or metadata instead of text. This is the same shape the workflow used in Step 5 — streaming is the default way to watch a long orchestration without waiting for the final event.
Sessions. An agent is stateless between run() calls unless you give it a session:
async def session_demo() -> None:
agent = Agent(
client=OllamaChatClient(model="qwen3:4b"),
name="researcher",
instructions="You answer questions about the notes.",
tools=[read_notes],
)
session = agent.create_session()
first = await agent.run(
"What is the first item in the notes?", session=session
)
print(first.text)
second = await agent.run(
"And what date was it written?", session=session
)
print(second.text)
The second question only makes sense because the session carries the first exchange — "it" refers to the item from the previous turn. Without the session, the model has no memory of the conversation at all. Sessions are the multi-turn primitive; for anything longer-lived, the framework also offers file-backed history providers and a pluggable memory architecture (including Mem0 and Redis backends) if you need persistence across processes.
Step 7: Swap the provider#
Everything so far ran on a local model. The swap to a hosted model is a client change and nothing else — the agents, tools, and orchestration are untouched:
.venv/bin/pip install "agent-framework-openai==1.18.2"
from agent_framework.openai import OpenAIChatClient
# Before:
# client = OllamaChatClient(model="qwen3:4b")
# After:
client = OpenAIChatClient(model="gpt-5.3", api_key="sk-...")
That is the entire change. The same holds for the other first-party clients — FoundryChatClient, AnthropicClient, BedrockChatClient, GeminiChatClient — each in its own small provider package, each satisfying the same protocol. Two practical warnings. First, the framework's default model has changed across releases, so always set model= explicitly rather than relying on a default. Second, the provider swap changes what the model can do, not just where it runs: hosted clients get hosted tools (web search, file search, code interpreter) that Ollama cannot offer, and small local models will fumble tool chains that a frontier model handles cleanly. Keep the prompts and the agent's job narrow on the local path, and re-test the tool loop when you switch providers — the same instructions can behave differently on a different model.
Step 8: Plug in MCP tools#
Your own @tool functions cover code you write. For tools other people wrote, the framework speaks MCP: it can start an MCP server as a subprocess and hand its tools to the model as if they were local functions. The reference filesystem server is the quickest demonstration — it exposes read_text_file, list_directory, write_file, and friends, confined to the directories you pass on the command line.
Two extra packages first. MCP support needs the mcp Python package, and the framework's MCP layer needs tenacity for subscription recovery — without each, the run fails with an error naming the missing package:
.venv/bin/pip install mcp tenacity
import asyncio
from agent_framework import Agent, MCPStdioTool
from agent_framework.ollama import OllamaChatClient
async def main() -> None:
filesystem = MCPStdioTool(
"filesystem",
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
request_timeout=90,
)
agent = Agent(
client=OllamaChatClient(model="qwen3:4b"),
name="fs-agent",
instructions="Read files and report their contents.",
tools=[filesystem],
)
result = await agent.run("What is in /tmp/notes.txt?")
print(result.text)
await agent.close()
if __name__ == "__main__":
asyncio.run(main())
Verified end to end in the sandbox: the server started, the model called the discovered read_text_file tool, and the real file contents came back through the framework into the model's next turn — {"content": "alpha note\nbeta note\n"} for a two-line test file. Three things to know. First, await agent.close() at the end shuts the server subprocess down; skip it and the Node process lingers. Second, the first npx run downloads the server package, which can exceed the default 30-second initialize timeout on a slow connection — if the connect times out, just run it again; the package is cached after the first download. Third, the server only ever sees the directories you list in args, so scope it to one folder the way the example scopes it to /tmp.
Which approach should you use?#
Four reasonable ways to build the same briefing team, and when each wins:
| Approach | Use it when | Watch out for |
|---|---|---|
| Microsoft Agent Framework + Ollama (this tutorial) | You want $0 local runs, enterprise patterns (approvals, telemetry, sessions), and the option to move the same code to Azure Foundry later. | The package surface is split across many small packages; install only what you need. The Ollama provider is still beta. |
| OpenAI Agents SDK | You live in the OpenAI ecosystem and want the smallest possible API surface — agents, handoffs, guardrails, and tracing in one small package. | Hosted models only in practice; local models need a LiteLLM bridge, and the default model changes between releases. |
| LangGraph | Your workflow is a state machine with branches, retries, and human interrupts, and you want explicit control over every edge. | More boilerplate for simple chains; the graph is the product, so small teams pay the complexity up front. |
| Raw chat completions + your own loop | The agent is one prompt and one tool, and you want zero framework to debug. | You re-implement the tool loop, retries, history, and streaming yourself — usually around the third feature. |
The honest rule: if the team is three agents in a line, the sequential orchestration in this tutorial is the right amount of framework. If it is one agent and one tool, skip the orchestration and use a single agent. If it is a branching workflow with human approvals, reach for the graph-based workflow engine or LangGraph and accept the boilerplate.
The takeaway#
You now have a local multi-agent team that reads files, argues with itself, and saves its work — for $0, with no account and no data leaving your machine. The five moves that matter: install the slim packages, not the meta-package; give each agent one job and one tool; ask for structured output when a program consumes the answer; use the sequential orchestration for anything with a fixed order; and keep the provider behind the client constructor so the same code runs on Ollama today and a hosted model tomorrow. The failure modes you will actually hit are mundane — a missing model=, a tool with a vague docstring, a 4B model returning chatty JSON — and all three are fixed in the code, not in the model. From here, the productive next steps are a concurrent orchestration for independent research tasks, a file-backed session store so briefings survive restarts, and the DevUI visual debugger (pip install agent-framework-devui) to watch the tool calls flow in the browser.