Interface IToolIdempotencyStore
Tracks tool invocations so that retried or duplicated tool calls produce a
single side effect. The contract is intentionally a thin wrapper over
— the redb-backed implementation reuses
the existing IdempotentEntryProps table to avoid duplicating schema.
The optional exchange parameter on every method carries the route
pipeline's current exchange; REDB-backed implementations resolve a
per-exchange through
IRouteContext.GetRedbService(name, exchange). In-memory
implementations ignore it.
Without an exchange a redb-backed implementation opens a redb scope of its own for the call. That scope joins an
ambient (a , a
route's .Transacted()) as every redb connection does, but not a transaction begun on the context's shared
IRedbService (ExecuteAtomicAsync, BeginTransaction), which it does not see: pass the exchange,
or use a TransactionScope, when the call must commit or roll back with that work. In-memory implementations
take part in no transaction.
public interface IToolIdempotencyStore
Methods
CompleteAsync(string, string, string, IExchange?, CancellationToken)
Persists the tool output JSON for the previously-reserved key.
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.
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.
Task<ToolIdempotencyReservation> TryReserveAsync(string conversationId, string toolUseId, IExchange? exchange = null, CancellationToken ct = default)