Soenneker.Maf.Pool 11.0.203

Prefix Reserved
dotnet add package Soenneker.Maf.Pool --version 11.0.203
                    
NuGet\Install-Package Soenneker.Maf.Pool -Version 11.0.203
                    
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.Pool" Version="11.0.203" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Maf.Pool" Version="11.0.203" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Maf.Pool" />
                    
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 Soenneker.Maf.Pool --version 11.0.203
                    
#r "nuget: Soenneker.Maf.Pool, 11.0.203"
                    
#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.Pool@11.0.203
                    
#: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.Pool&version=11.0.203
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Maf.Pool&version=11.0.203
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Maf.Pool

Selects an available Microsoft Agent Framework AIAgent from named pools while enforcing per-entry request quotas.

Install

dotnet add package Soenneker.Maf.Pool

Usage

using Microsoft.Extensions.DependencyInjection;
using Soenneker.Maf.Dtos.Options;
using Soenneker.Maf.Pool.Abstract;
using Soenneker.Maf.Pool.Registrars;

services.AddMafPoolAsSingleton();

IMafPool pool = serviceProvider.GetRequiredService<IMafPool>();

await pool.Add("chat", "primary", new MafOptions
{
    ModelId = "my-model",
    RequestsPerMinute = 60,
    AgentFactory = static (options, cancellationToken) =>
        CreateAgentAsync(options.ModelId!, cancellationToken)
}, cancellationToken);

(AIAgent? agent, IMafPoolEntry? entry) =
    await pool.GetAvailable("chat", cancellationToken);

if (agent is not null)
{
    // Use the selected agent. The request allowance was consumed by checkout.
}

Add multiple entries to a pool to provide fallback capacity. Entries are checked in registration order; an entry whose quota is exhausted is skipped until capacity becomes available.

What you get

  • IMafPool — Defines a pool of Microsoft Agent Framework AIAgent entries, organized by poolId. Allows registering, unregistering, clearing, and checking out an agent instance.
  • IMafPoolEntry — Represents a single agent source (model + config) with rate limiting capabilities.
  • IMafRateLimiter — Represents a rate limiter that tracks requests per second, per minute, and per day using sliding windows.
  • MafPoolRegistrar — Registration extensions for IMafCache and IMafPool.

API at a glance

API What it does Result / important behavior
IMafPool.GetAvailable(poolId, cancellationToken) Attempts to fetch an available AIAgent from the specified pool. Will retry every 500ms until cancellationToken is cancelled. A ValueTask{TResult} containing a tuple of: - AIAgent instance (or null if cancelled) - Corresponding IMafPoolEntry used to manage that agent.
IMafPool.GetRemainingQuotas(poolId, cancellationToken) Retrieves the remaining usage quotas for every entry in the specified pool. A ValueTask{TResult} containing a Dictionary{TKey, TValue}, where each key is an entryKey and the value is a tuple of (secondsRemaining, minutesRemaining, daysRemaining).
IMafPool.Add(poolId, entryKey, options, cancellationToken) Registers a new agent entry under the specified poolId using options. A task that completes when the add operation is complete.
IMafPool.Add(poolId, entryKey, entry, cancellationToken) Registers an existing IMafPoolEntry under the specified poolId. A task that completes when the add operation is complete.
IMafPool.Remove(poolId, entryKey, cancellationToken) Unregisters (removes) the entry with entryKey from the specified pool. Also removes that entry from the internal cache. True if the entry existed and was removed; false if it was not present.
IMafPool.Clear(poolId, cancellationToken) Clears and removes all entries from the specified poolId, and also clears the internal cache. A task that completes when the Maf Pool has been cleared.
IMafPool.ClearAll(cancellationToken) Clears and removes every sub-pool (all poolIds) and clears the internal cache completely. A task that completes when the Maf Pool has been cleared.
IMafPool.TryGet(poolId, entryKey, entry) Attempts to fetch the IMafPoolEntry for a given poolId and entryKey without modifying state. True if the entry was found; otherwise false.
IMafPoolEntry.RateLimiter Gets rate limiter. Gets rate limiter.
IMafPoolEntry.Options Gets options. Gets options.
IMafPoolEntry.Key Gets key. Gets key.
IMafPoolEntry.IsAvailable(cancellationToken) Gets whether this agent is currently available based on rate limits. true if gets whether this agent is currently available based on rate limits; otherwise, false.
IMafPoolEntry.RemainingQuota(cancellationToken) Gets the remaining quota for this pool entry. A task whose result is the requested (int Second, int Minute, int Day).
IMafRateLimiter.TryConsume(cancellationToken) Attempts to consume a token from the rate limiter. True if a token was consumed successfully, false if the rate limit was exceeded.
IMafRateLimiter.GetRemaining(cancellationToken) Gets the remaining quota for each time window. A tuple containing the remaining requests for second, minute, and day windows.
MafPoolRegistrar.AddMafPoolAsSingleton(services) Adds IMafCache and IMafPool as singleton services. The same service collection, so additional registrations can be chained.
MafPoolRegistrar.AddMafPoolAsScoped(services) Adds IMafCache and IMafPool as scoped services. The same service collection, so additional registrations can be chained.

Practical notes

  • GetAvailable() waits when every entry is rate-limited. Always pass a cancellation token when an indefinite wait is undesirable.
  • A successful checkout consumes one request from the selected entry. The pool does not observe whether the eventual model request succeeds.
  • Pool ids isolate both registrations and cached agents, so the same entry key can be used in different pools.
  • Clear(poolId) affects only that pool. ClearAll() removes every pool and cached agent.
  • Singleton registration shares quotas and agents application-wide; scoped registration creates independent pools per scope.
Product 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.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Soenneker.Maf.Pool:

Package Downloads
Soenneker.Maf.Pool.Anthropic

Provides Anthropic-specific registration extensions for MafPoolManager, enabling integration via Microsoft Agent Framework.

Soenneker.Maf.Pool.Mistral

Provides Mistral-specific registration extensions for MafPoolManager, enabling integration with local LLMs via Microsoft Agent Framework.

Soenneker.Maf.Pool.Gemini

Provides Gemini-specific registration extensions for MafPoolManager, enabling integration via Microsoft Agent Framework.

Soenneker.Maf.Pool.OpenAI

Provides OpenAI-specific registration extensions for MafPoolManager, enabling integration via Microsoft Agent Framework.

Soenneker.Maf.Pool.OpenAI.Azure

Provides Azure OpenAI-specific registration extensions for MafPoolManager, enabling integration via Microsoft Agent Framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.203 66 11/15/2026
11.0.202 245 11/11/2026
11.0.201 135 11/11/2026
11.0.199 135 11/11/2026
11.0.198 112 11/11/2026
11.0.197 321 11/7/2026
11.0.196 456 11/3/2026
11.0.194 158 11/3/2026
11.0.193 221 10/31/2026
11.0.192 239 10/27/2026
11.0.191 141 10/27/2026
11.0.190 153 10/27/2026
11.0.189 233 10/26/2026
11.0.188 158 10/26/2026
11.0.186 142 10/26/2026
11.0.185 195 10/26/2026
11.0.184 159 10/26/2026
4.0.183 258 10/24/2026
4.0.182 696 10/15/2026
4.0.181 101 10/15/2026
Loading failed

Updated Multiple NuGet packages