---
title: "Build Your Own AI Agent Harness in C#, the MafClaw Live Series"
slug: build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series
url: https://listedarticles.com/articles/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series
canonical_url: https://devblogs.microsoft.com/dotnet/build-your-own-ai-agent-harness-in-csharp-the-maf-claw-live-series/
content_type: tutorial
language: en
published_at: 2026-09-16T00:00:00.000Z
updated_at: 2026-09-22T06:15:28.110Z
author: "Bruno Capuano"
author_url: https://devblogs.microsoft.com/dotnet/author/bruno-capuano/
authored_by: human
publisher: ".NET Blog"
publisher_url: https://devblogs.microsoft.com/dotnet/
topics: ["AI Agents", "Programming", "Engineering", "LLMs", "Tutorials"]
license: all-rights-reserved
word_count: 349
reading_minutes: 2
citation: "Bruno Capuano, .NET Blog. \"Build Your Own AI Agent Harness in C#, the MafClaw Live Series.\" 16 Sept 2026. https://devblogs.microsoft.com/dotnet/build-your-own-ai-agent-harness-in-csharp-the-maf-claw-live-series/ (all-rights-reserved)"
# The full text follows. The web page shows an extract and sends readers
# to the source above; quote the citation and link the canonical URL.
---

# Build Your Own AI Agent Harness in C#, the MafClaw Live Series

> Bruno Capuano’s four-part .NET / Microsoft Reactor series builds a finance-education agent on the Microsoft Agent Framework harness—tools, file boundaries, approvals, skills, shell, CodeAct, observability, and Foundry hosting.

# Build Your Own AI Agent Harness in C#, the MafClaw Live Series

A few weeks ago Bruno Capuano wrote about going from `dotnet run` to a Foundry Hosted Agent in three lines of C#. That post starts near the end of the journey. The next question: what should you put inside the agent before you deploy it?

Tools. Planning. Safe file access. Human approval. Memory. Skills. Shell. Code execution. Background agents. Observability. Governance. Evaluations.

Microsoft Agent Framework includes an **agent harness**. Capuano is building a complete C# agent with it live in a four-part series—*From Model to Agent: The Agent Framework Harness, Live in C#*—streaming on the .NET YouTube channel and Microsoft Reactor.

## What is an agent harness?

A language model generates text. An agent needs a loop that calls tools, inspects results, updates a plan, remembers information, requests approval for risky actions, manages context, and keeps working until the task is complete. That surrounding runtime is the harness.

In .NET:

```csharp
AIAgent agent = chatClient.AsHarnessAgent(new HarnessAgentOptions
{
    ChatOptions = new ChatOptions
    {
        Instructions = "You are a personal finance education assistant.",
        Tools = [StockTools.GetStockPrice]
    }
});
```

The harness supplies automatic function invocation, history persistence, planning, context compaction, file memory, web search, tool approvals, skills, and OpenTelemetry—each configurable.

## What the series builds

Across four sessions, one personal finance education assistant grows through:

1. **Tools, web search, and a plan** — smallest useful agent with a custom stock-price tool and todo planning
2. **Files, approvals, and memory** — portfolio CSV inside an approved working directory; `ApprovalRequiredAIFunction` for simulated trades; local vs Foundry Memory; timed approval policy for unanswered prompts
3. **Skills, shell, CodeAct, and background agents** — discoverable skills, confined shell, code execution for arithmetic, parallel research agents
4. **Observability, governance, evaluations, and Foundry Hosted Agent deployment**

All prices and transactions in the samples are mock and illustrative—not financial advice.

## Why start with the harness?

You can rebuild every piece yourself. Most teams want to spend time on domain behavior: which tools, which data, which approvals, what memory, which skills, which policies, how to evaluate. The harness gives those decisions a composable home. You still own the boundaries.

*Source: [devblogs.microsoft.com/dotnet/...](https://devblogs.microsoft.com/dotnet/build-your-own-ai-agent-harness-in-csharp-the-maf-claw-live-series/)*
