<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs" -->

---
title: Build Your Own AI Agent Harness in C#, the MafClaw Live...
description: Bruno Capuano is running a four-part live-coding series building a C# AI agent using the Microsoft Agent Framework's harness. Starting from a single...
canonical: https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Build Your Own AI Agent Harness in C#, the MafClaw Live Series | daily.dev
og:description: Bruno Capuano is running a four-part live-coding series building a C# AI agent using the Microsoft Agent Framework's harness. Starting from a single...
og:url: https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs
og:image: https://api.daily.dev/og/posts/YVwVbyzCs.png
og:image:alt: Build Your Own AI Agent Harness in C#, the MafClaw Live Series
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

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

**[.NET Blog](https://daily.dev/sources/dotnet)** · 11 min read · 21 upvotes · 0 comments

## Summary

Bruno Capuano is running a four-part live-coding series building a C# AI agent using the Microsoft Agent Framework's harness. Starting from a single IChatClient call, the series progressively adds tools, file access with approval boundaries, durable memory, skills, shell access, CodeAct code execution, background agents, and finally observability, Purview governance, evaluations, and Foundry-hosted deployment. The example agent throughout is a personal finance education assistant, chosen because it naturally raises questions around read vs write access, approvals for simulated trades, and safe execution boundaries. Sessions stream live on the .NET YouTube channel and Microsoft Reactor, with recordings available afterward; two of four sessions were live at time of writing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://devblogs.microsoft.com/dotnet/build-your-own-ai-agent-harness-in-csharp-the-maf-claw-live-series>

## Questions this post answers

### What is an agent harness in Microsoft Agent Framework and what does it provide?

An agent harness is the surrounding runtime that turns a language model into a working agent, supplying automatic function invocation, history persistence, planning with todo lists, context compaction, file memory, web search, tool approvals, skills, and OpenTelemetry instrumentation. In C#, calling chatClient.AsHarnessAgent with HarnessAgentOptions wraps an IChatClient into a full AIAgent pipeline, and each capability is configurable, replaceable, or disabled individually.

_daily.dev surfaces walkthroughs like this for developers wiring up agent runtimes instead of building orchestration loops from scratch._

### How do you require human approval before an AI agent executes a risky action in C#?

Wrap the function in ApprovalRequiredAIFunction, such as new ApprovalRequiredAIFunction(AIFunctionFactory.Create(RequestSimulatedTradeOrder, "request_simulated_trade")), so the model can request the action but the harness intercepts it and emits an approval request instead of executing it directly. Auto-approval rules can be configured separately for read-only tools so harmless actions do not interrupt the user, while writes and destructive operations still require explicit approval.

_track patterns like approval gating on daily.dev when designing safe tool access for autonomous agents._

### What happens if a user never responds to an AI agent's approval request?

Silence is treated as denial, not consent. A TimedApprovalPolicy configured with a maximum number of approval attempts and a timeout (for example 5 attempts and a 5-second timeout) issues automatic denial after the final attempt, immediate denial on explicit refusal, sticky denial for the rest of the user prompt, and a cap on repeated approval rounds requested by the model.

_developers hardening agent approval flows can find implementation details like this via daily.dev._

## Similar posts on daily.dev

- [Agent Harness: Scaling the claw or harness capabilities](https://daily.dev/posts/agent-harness-scaling-the-claw-or-harness-capabilities-kmc2tlu6x) · DevBlogs · 1 upvotes · 0 comments
- [The Unexpected AI Stack: C\# \+ .NET \(Part 3\)](https://daily.dev/posts/the-unexpected-ai-stack-c-net-part-3--silxqutsc) · ITNEXT · 0 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#.net](https://daily.dev/tags/.net), [#observability](https://daily.dev/tags/observability), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Build Your Own AI Agent Harness in C#, the MafClaw Live Series","url":"https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs"},"datePublished":"2026-09-16T21:01:18.694Z","dateModified":"2026-09-16T21:13:56.291Z","description":"Bruno Capuano is running a four-part live-coding series building a C# AI agent using the Microsoft Agent Framework's harness. Starting from a single...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/6564c507711f9aa63a03ab5249f9f1e3?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/6564c507711f9aa63a03ab5249f9f1e3?_a=AQAEuop","isAccessibleForFree":true,"articleSection":".NET Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":".NET Blog","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/f23eb59371bd4f07aeef64c4eef73266","url":"https://daily.dev/sources/dotnet"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":21},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,.net,observability,c#","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":".NET Blog","item":"https://daily.dev/sources/dotnet"},{"@type":"ListItem","position":3,"name":"Build Your Own AI Agent Harness in C#, the MafClaw Live Series"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/build-your-own-ai-agent-harness-in-c-the-mafclaw-live-series-yvwvbyzcs#faq","mainEntity":[{"@type":"Question","name":"What is an agent harness in Microsoft Agent Framework and what does it provide?","acceptedAnswer":{"@type":"Answer","text":"An agent harness is the surrounding runtime that turns a language model into a working agent, supplying automatic function invocation, history persistence, planning with todo lists, context compaction, file memory, web search, tool approvals, skills, and OpenTelemetry instrumentation. In C#, calling chatClient.AsHarnessAgent with HarnessAgentOptions wraps an IChatClient into a full AIAgent pipeline, and each capability is configurable, replaceable, or disabled individually. daily.dev surfaces walkthroughs like this for developers wiring up agent runtimes instead of building orchestration loops from scratch."}},{"@type":"Question","name":"How do you require human approval before an AI agent executes a risky action in C#?","acceptedAnswer":{"@type":"Answer","text":"Wrap the function in ApprovalRequiredAIFunction, such as new ApprovalRequiredAIFunction(AIFunctionFactory.Create(RequestSimulatedTradeOrder, \"request_simulated_trade\")), so the model can request the action but the harness intercepts it and emits an approval request instead of executing it directly. Auto-approval rules can be configured separately for read-only tools so harmless actions do not interrupt the user, while writes and destructive operations still require explicit approval. track patterns like approval gating on daily.dev when designing safe tool access for autonomous agents."}},{"@type":"Question","name":"What happens if a user never responds to an AI agent's approval request?","acceptedAnswer":{"@type":"Answer","text":"Silence is treated as denial, not consent. A TimedApprovalPolicy configured with a maximum number of approval attempts and a timeout (for example 5 attempts and a 5-second timeout) issues automatic denial after the final attempt, immediate denial on explicit refusal, sticky denial for the rest of the user prompt, and a cap on repeated approval rounds requested by the model. developers hardening agent approval flows can find implementation details like this via daily.dev."}}]}
```

