.NETBruno Capuano10 min readintermediate
Build Your Own AI Agent Harness in C#, the MafClaw Live Series
Summary
The post walks .NET developers through using Microsoft Agent Framework's harness to turn a simple IChatClient into a fully‑featured C# AI agent, showing code for tool integration, file sandboxing, approval flows, and memory, then outlines further capabilities like skills and observability.
- Wrap an IChatClient with AsHarnessAgent to get automatic function calling, planning, context compaction, and OpenTelemetry out of the box.
- Sandbox file access with FileSystemAgentFileStore so the model can only read/write inside a designated folder.
- Use ApprovalRequiredAIFunction (and auto‑approval rules) to require human consent for risky actions while allowing harmless reads to proceed automatically.
- Configure durable, scoped memory instead of relying on the model’s “I saved that” claim to ensure persistence.
.NET engineers building AI‑driven assistants need a ready‑made harness that handles orchestration, safety, and observability so they can focus on domain logic.
6/10


