Class InMemoryToolIdempotencyStore
In-memory idempotency store backed by a thin
composition — the registered repository handles the dedup key, an internal
dictionary remembers the cached output.
With a ttl, a completed call is forgotten that long after it completed: its key leaves the repository and
its output leaves the store, lazily, on a later reservation (no timer). A reservation still in flight (reserved,
neither completed nor released) is never aged out, so a second run of the same call cannot start while the first is
still running, however long it takes. Without a ttl nothing expires.
public sealed class InMemoryToolIdempotencyStore : IToolIdempotencyStore
Inheritance
Implements
Methods
CompleteAsync(string, string, string, IExchange?, CancellationToken)
Persists the tool output JSON for the previously-reserved key.
public Task CompleteAsync(string conversationId, string toolUseId, string outputJson, IExchange? exchange = null, CancellationToken ct = default)
ReleaseAsync(string, string, IExchange?, CancellationToken)
Releases the reservation on failure so a retry can re-run the tool.
public Task ReleaseAsync(string conversationId, string toolUseId, IExchange? exchange = null, CancellationToken ct = default)
TryReserveAsync(string, string, IExchange?, CancellationToken)
Attempts to reserve toolUseId for the given conversation.
public Task<ToolIdempotencyReservation> TryReserveAsync(string conversationId, string toolUseId, IExchange? exchange = null, CancellationToken ct = default)
Constructors
InMemoryToolIdempotencyStore(IIdempotentRepository, TimeSpan?, TimeProvider?)
Creates a store over the given idempotency repository.