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" />
<PackageReference Include="D4S.Agent" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=D4S.Agent&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 setup —
AddMafAgent(configuration)wires chat clients, middlewares, plugins, guardrail, and MCP tools. - Agent turn —
InvokeAgentAsyncwith 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 composer —
Prompts/base(generic) +Prompts/specific(per-customer) always-on,Prompts/featureson-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
MicrosoftFoundryconfig — a validEndpointis required at startup; - copy
Prompts/base/*.md,Prompts/specific/*.mdandPrompts/features/*.mdto its output directory — the composer reads them fromAppContext.BaseDirectory(plusSkills/whenBot:AgentSkillsEnabledis 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(underPrompts/features) is appended to the instructions. - Add MCP servers (config): list them under
Mcp:Servers(HttporStdio). An optionalToolsallow-list selects a subset; unreachable servers are logged and skipped (fail-soft). - Override the agent: register your own
IMafAgentafterAddMafAgent(it wins over the default), or subclassMafAgentand overrideBuildAgent/BuildResponse.
Requirements
net10.0- Key dependencies:
Microsoft.Agents.AI,Microsoft.Extensions.AI(.OpenAI),Microsoft.Agents.Builder,Azure.AI.OpenAI,ModelContextProtocol.
| Product | Versions 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.
-
net10.0
- Azure.AI.OpenAI (>= 2.1.0)
- Microsoft.Agents.AI (>= 1.5.0)
- Microsoft.Agents.Builder (>= 1.5.181)
- Microsoft.Extensions.AI (>= 10.6.0)
- Microsoft.Extensions.AI.OpenAI (>= 10.6.0)
- ModelContextProtocol (>= 1.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.