Soenneker.Maf.Cache
11.0.193
Prefix Reserved
dotnet add package Soenneker.Maf.Cache --version 11.0.193
NuGet\Install-Package Soenneker.Maf.Cache -Version 11.0.193
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="Soenneker.Maf.Cache" Version="11.0.193" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Maf.Cache" Version="11.0.193" />
<PackageReference Include="Soenneker.Maf.Cache" />
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 Soenneker.Maf.Cache --version 11.0.193
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.Maf.Cache, 11.0.193"
#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 Soenneker.Maf.Cache@11.0.193
#: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=Soenneker.Maf.Cache&version=11.0.193
#tool nuget:?package=Soenneker.Maf.Cache&version=11.0.193
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Soenneker.Maf.Cache
Provides async thread-safe caching of Microsoft Agent Framework AIAgent instances.
Install
dotnet add package Soenneker.Maf.Cache
Usage
using Microsoft.Extensions.DependencyInjection;
using Soenneker.Maf.Cache.Abstract;
using Soenneker.Maf.Cache.Registrars;
using Soenneker.Maf.Dtos.Options;
services.AddMafCacheAsSingleton();
IMafCache cache = serviceProvider.GetRequiredService<IMafCache>();
var options = new MafOptions
{
ModelId = "my-model",
AgentFactory = static (value, cancellationToken) =>
CreateAgentAsync(value.ModelId!, cancellationToken)
};
AIAgent agent = await cache.Get("support-agent", options, cancellationToken);
Calls using the same id share one agent. The options and factory are used when that id is first created; remove the entry before recreating it with different options.
What you get
IMafCache— Provides async thread-safe caching of Microsoft Agent FrameworkAIAgentinstances.MafCacheRegistrar— Registration extensions forIMafCache.
API at a glance
| API | What it does | Result / important behavior |
|---|---|---|
IMafCache.Get(id, options, cancellationToken) |
Retrieves an AIAgent instance asynchronously, creating it via options if necessary. |
A task whose result is the requested AI Agent. |
IMafCache.Remove(id, cancellationToken) |
Removes an agent instance from the cache. | true if removes an agent instance from the cache; otherwise, false. |
IMafCache.Clear(cancellationToken) |
Clears all cached agent instances. | A task that completes when the Maf Cache has been cleared. |
IMafCache.GetAll(cancellationToken) |
Returns all cached agents by id. | A task whose result is the requested dictionary. |
MafCacheRegistrar.AddMafCacheAsSingleton(services) |
Adds IMafCache as a singleton service. |
The same service collection, so additional registrations can be chained. |
MafCacheRegistrar.AddMafCacheAsScoped(services) |
Adds IMafCache as a scoped service. |
The same service collection, so additional registrations can be chained. |
Practical notes
- Register the cache as a singleton to share agents across scopes, or use
AddMafCacheAsScoped()to isolate them per scope. Remove()andClear()remove cached agents; callers should not retain an agent after removing it.GetAll()returns a snapshot keyed by the ids passed toGet().
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net11.0
- Soenneker.Dictionaries.Singletons (>= 11.0.141)
- Soenneker.Maf.Dtos.Options (>= 11.0.70)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Maf.Cache:
| Package | Downloads |
|---|---|
|
Soenneker.Maf.Pool
A high-performance, thread-safe pool implementation for Microsoft Agent Framework agents with built-in rate limiting capabilities. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.193 | 78 | 11/15/2026 |
| 11.0.192 | 188 | 11/11/2026 |
| 11.0.191 | 102 | 11/11/2026 |
| 11.0.190 | 53 | 11/11/2026 |
| 11.0.189 | 54 | 11/11/2026 |
| 11.0.188 | 59 | 11/11/2026 |
| 11.0.187 | 59 | 11/11/2026 |
| 11.0.186 | 403 | 11/7/2026 |
| 11.0.185 | 439 | 11/3/2026 |
| 11.0.184 | 93 | 11/3/2026 |
| 11.0.183 | 311 | 10/31/2026 |
| 11.0.182 | 236 | 10/27/2026 |
| 11.0.181 | 159 | 10/27/2026 |
| 11.0.180 | 288 | 10/26/2026 |
| 11.0.177 | 157 | 10/26/2026 |
| 11.0.176 | 151 | 10/26/2026 |
| 11.0.175 | 191 | 10/26/2026 |
| 11.0.174 | 98 | 10/26/2026 |
| 11.0.173 | 101 | 10/26/2026 |
| 4.0.172 | 354 | 10/24/2026 |
Loading failed
Updated Soenneker.Dictionaries.Singletons to 11.0.141