Interface IKnowledgeStore
Persists embedding-backed knowledge chunks for retrieval-augmented agent
runs. The MVP contract is intentionally narrow — upsert + cosine-similarity
query over an opaque vector. Providers that index the chunks separately
(e.g. pgvector, Qdrant) wrap this interface.
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 IKnowledgeStore
Methods
DeleteAsync(string, IExchange?, CancellationToken)
Drops a chunk by id; no-op when not found.
Task DeleteAsync(string chunkId, IExchange? exchange = null, CancellationToken ct = default)
SearchAsync(ReadOnlyMemory<float>, int, string?, IExchange?, CancellationToken)
Returns the topK most-similar chunks for the query embedding.
Task<IReadOnlyList<KnowledgeSearchResult>> SearchAsync(ReadOnlyMemory<float> queryEmbedding, int topK, string? collection = null, IExchange? exchange = null, CancellationToken ct = default)
SearchTextAsync(string, int, string?, IExchange?, CancellationToken)
Keyword fallback — returns up to topK chunks whose text
Task<IReadOnlyList<KnowledgeSearchResult>> SearchTextAsync(string query, int topK, string? collection = null, IExchange? exchange = null, CancellationToken ct = default)
UpsertAsync(KnowledgeChunk, IExchange?, CancellationToken)
Persists or replaces a chunk by its .
Task UpsertAsync(KnowledgeChunk chunk, IExchange? exchange = null, CancellationToken ct = default)
UpsertManyAsync(IEnumerable<KnowledgeChunk>, IExchange?, CancellationToken)
Persists or replaces many chunks at once. Bulk-friendly stores commit
Task UpsertManyAsync(IEnumerable<KnowledgeChunk> chunks, IExchange? exchange = null, CancellationToken ct = default)