The Microsoft Agent Framework Harness is now released | Microsoft Agent Framework
Skip to main content
Dev Blogs
AI
All .NET posts
.NET MAUI<br>ASP.NET Core<br>Blazor<br>Entity Framework
C++<br>C#<br>F#<br>TypeScript
NuGet<br>Servicing<br>.NET Blog in Chinese
Microsoft for Developers<br>Agent Framework<br>Develop from the cloud<br>Xcode<br>ISE Developer<br>TypeScript<br>PowerShell<br>Python<br>Java<br>Java Blog in Chinese<br>Go<br>Microsoft Edge Dev<br>Microsoft 365 Developer<br>Microsoft Entra Identity Developer<br>Microsoft Entra PowerShell
Visual Studio<br>Visual Studio Code<br>Aspire
All things Azure<br>Azure SDK<br>Azure VM Runtime Team<br>Microsoft Azure<br>Azure Cosmos DB<br>Azure DocumentDB<br>Azure Data Studio<br>Azure SQL<br>DevOps<br>DirectX<br>Microsoft Foundry<br>Power Platform
OData<br>Unified Data Model (IDEAs)
Windows Command Line<br>#ifdef Windows<br>Inside MSIX<br>MIDI and music<br>React Native<br>The Old New Thing<br>Windows Developer
Wes Steyn
Principal Software Engineer
Your agents can now be built on a stable, batteries-included harness – the loop, planning, memory, context management, approvals, and telemetry that turn a model into an agent that actually does things – in both Python and .NET .
What is an agent harness?
An agent harness is the scaffolding that turns a language model into an agent. A model on its own can only generate text. To have it call tools, work through multi-step tasks, remember what it has done, and keep going until the job is finished, you need a runtime wrapped around the model – and that runtime is the harness.
Agent Framework ships a ready-made one so you don’t have to build that scaffolding yourself. It’s an opinionated, fully customizable, batteries-included agent that wraps a chat client with a complete agentic pipeline, tuned for long-running, autonomous work such as research, data analysis, and general task automation. Internally it’s just a chat-client agent (Agent in Python, ChatClientAgent in .NET) with a curated set of Agent Framework features added – each enabled by default and individually customizable or removable:
Function invocation – the automatic tool-calling loop, with a configurable iteration limit.
Per-service-call history persistence – chat history saved after every model call for crash
recovery and mid-run inspection.
Compaction – context-window management so long tool-calling loops don’t overflow.
Todo & agent-mode providers – a persistent todo list plus plan/execute mode tracking, so the agent plans work then executes it.
File memory – durable session notes and artifacts that survive across turns.
Skills – progressive discovery and loading of packaged domain expertise.
Web search – enables the inference service’s built-in web search tool, when the underlying service provides one, so the agent can ground answers in current information.
Tool approval – "don’t ask again" standing rules plus heuristic auto-approval for safe calls.
Telemetry – built-in OpenTelemetry.
You supply your own chat client and only configure what makes the agent yours – its instructions and its tools. Everything else has a sensible default.
What you can do with it
Here are some examples of the types of agents you can build with it:
Research assistants that plan a topic into todos, switch between plan and execute modes, search the web, and work autonomously through the plan.
Data-processing agents that read and analyze a folder of files with approval-gated file tools.
Domain assistants – like a personal-finance "claw" – that combine custom tools, memory, skills, and planning into a single agent you can grow feature by feature.
A basic harness agent
The harness collapses the whole pipeline into a single call. You bring a chat client, instructions, and (optionally) custom tools; the harness adds function invocation, planning, history persistence, compaction, approvals, web search, and telemetry.
.NET
using Azure.AI.Projects;<br>using Azure.Identity;<br>using Microsoft.Agents.AI;<br>using Microsoft.Extensions.AI;
var endpoint = Environment.GetEnvironmentVariable("FOUNDRY_PROJECT_ENDPOINT")<br>?? throw new InvalidOperationException("FOUNDRY_PROJECT_ENDPOINT is not set.");<br>var deploymentName = Environment.GetEnvironmentVariable("FOUNDRY_MODEL") ?? "gpt-5.4";
// Build an IChatClient backed by a Microsoft Foundry project...<br>IChatClient chatClient =<br>new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential())<br>.GetProjectOpenAIClient()<br>.GetResponsesClient()<br>.AsIChatClient(deploymentName);
// ...then wrap it in the harness. One call gives you the full agentic pipeline.<br>AIAgent agent = chatClient.AsHarnessAgent(new HarnessAgentOptions<br>ChatOptions = new ChatOptions<br>Instructions = "You are a helpful research assistant. Plan your work, then execute it.",<br>Tools = [/* your custom AIFunction tools */],<br>},<br>});
AgentRunResponse response = await agent.RunAsync("Research the outlook for renewable energy stocks.");<br>Console.WriteLine(response.Text);<br>Python
import asyncio
from agent_framework import create_harness_agent<br>from agent_framework.foundry import...