Interface IBatchStore
Tracks async-batch jobs submitted to LLM providers (Anthropic Message
Batches, OpenAI Batch API, vLLM batch endpoints). The framework does not
prescribe a submit protocol — providers stay free to implement
SubmitAsync however they like — but every submitted batch should be
registered here so that incoming webhooks can be correlated, deduplicated
and routed back to the originating conversation.
Idempotency of the callback itself is the caller's responsibility (use
with the batch id as key); this store
only persists the submit-time metadata.
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) using the named-redb
hint stored in . 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 IBatchStore
Methods
GetAsync(string, IExchange?, CancellationToken)
Loads a previously-registered batch by id; null if unknown.
Task<BatchJobRecord?> GetAsync(string batchId, IExchange? exchange = null, CancellationToken ct = default)
MarkCompletedAsync(string, IExchange?, CancellationToken)
Marks a batch as completed; convenience wrapper around .
Task MarkCompletedAsync(string batchId, IExchange? exchange = null, CancellationToken ct = default)
MarkFailedAsync(string, string, IExchange?, CancellationToken)
Marks a batch as failed; convenience wrapper around .
Task MarkFailedAsync(string batchId, string errorMessage, IExchange? exchange = null, CancellationToken ct = default)
RegisterAsync(BatchJobRecord, IExchange?, CancellationToken)
Records a batch submission. Replaces an existing row with the same id.
Task RegisterAsync(BatchJobRecord record, IExchange? exchange = null, CancellationToken ct = default)
RegisterManyAsync(IEnumerable<BatchJobRecord>, IExchange?, CancellationToken)
Records many batch submissions at once. Bulk-friendly stores commit the
Task RegisterManyAsync(IEnumerable<BatchJobRecord> records, IExchange? exchange = null, CancellationToken ct = default)
UpdateStatusAsync(string, string, DateTimeOffset?, string?, IExchange?, CancellationToken)
Updates lifecycle status and optional fields. Unknown ids are ignored
Task UpdateStatusAsync(string batchId, string status, DateTimeOffset? completedAtUtc = null, string? errorMessage = null, IExchange? exchange = null, CancellationToken ct = default)