D4S.Agent 1.0.2

dotnet add package D4S.Agent --version 1.0.2
                    
NuGet\Install-Package D4S.Agent -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="D4S.Agent" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="D4S.Agent" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="D4S.Agent" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add D4S.Agent --version 1.0.2
                    
#r "nuget: D4S.Agent, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package D4S.Agent@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=D4S.Agent&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=D4S.Agent&version=1.0.2
                    
Install as a Cake Tool

D4S.Agent

Reusable Microsoft Agent Framework implementation for Microsoft 365 / Teams bots. Add one DI call, depend on IMafAgent, and the package owns the agent turn, guardrail, middlewares, tools, and prompt composition — your host keeps only auth, storage, and bot wiring.

Features

  • Single-call setupAddMafAgent(configuration) wires chat clients, middlewares, plugins, guardrail, and MCP tools.
  • Agent turnInvokeAgentAsync with session persistence; returns text or an Adaptive Card.
  • Topic guardrail — off-topic messages get a polite redirect, no main-model call.
  • Middlewares — thinking-UX labels, audit logging, loop cap, Teams keep-alive heartbeat.
  • Tools — built-in Adaptive Card tool, host-contributed tools, and MCP server tools.
  • Prompt composerPrompts/base (generic) + Prompts/specific (per-customer) always-on, Prompts/features on-demand.

Install

dotnet add package D4S.Agent

Quick start

Register everything the agent needs in one call:

builder.Services.AddMafAgent(builder.Configuration);

Depend on IMafAgent from your bot and render its response:

var response = await _agent.InvokeAgentAsync(turnContext, turnState, cancellationToken);
// response.ContentType ∈ { Text, AdaptiveCard }; response.Content is the payload.

Your host must:

  • provide the MicrosoftFoundry config — a valid Endpoint is required at startup;
  • copy Prompts/base/*.md, Prompts/specific/*.md and Prompts/features/*.md to its output directory — the composer reads them from AppContext.BaseDirectory (plus Skills/ when Bot:AgentSkillsEnabled is on).

Configuration

Section Purpose
MicrosoftFoundry Azure OpenAI Endpoint / ApiKey / Deployment for the main chat client.
MicrosoftFoundryGuardrail Smaller deployment for the guardrail (falls back to MicrosoftFoundry). Required when Bot:TopicGuardEnabled.
Bot Feature toggles + tuning (topic guard, Adaptive Cards, skills, heartbeat, loop cap…).
Mcp MCP servers whose tools are exposed to the agent.

Extending

  • Add a tool (code): AddMafAgent(config, o => o.AdditionalTools.Add(new AgentTool(sp => AIFunctionFactory.Create(...), InstructionsFile: "my-tool.md"))). The optional .md (under Prompts/features) is appended to the instructions.
  • Add MCP servers (config): list them under Mcp:Servers (Http or Stdio). An optional Tools allow-list selects a subset; unreachable servers are logged and skipped (fail-soft).
  • Override the agent: register your own IMafAgent after AddMafAgent (it wins over the default), or subclass MafAgent and override BuildAgent / BuildResponse.

Requirements

  • net10.0
  • Key dependencies: Microsoft.Agents.AI, Microsoft.Extensions.AI(.OpenAI), Microsoft.Agents.Builder, Azure.AI.OpenAI, ModelContextProtocol.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 41 6/5/2026
1.0.1 38 6/4/2026
1.0.0 37 6/4/2026