Skip to content

FileEvaluationCaptureStore

NexusLabs.Needlr.AgentFramework.Evaluation

FileEvaluationCaptureStore Class

Disk-backed IEvaluationCaptureStore that persists each response as a single JSON file under a caller-supplied directory. File names are the request hash plus a .json extension.

public sealed class FileEvaluationCaptureStore : NexusLabs.Needlr.AgentFramework.Evaluation.IEvaluationCaptureStore

Inheritance System.Object 🡒 FileEvaluationCaptureStore

Implements IEvaluationCaptureStore

Remarks

Writes are atomic per file via write-then-rename. Reads return null when no file exists for the requested key, and propagate any other I/O error.

Constructors

FileEvaluationCaptureStore(string) Constructor

Creates a store that reads from and writes to directoryPath. The directory is created on first write if it does not already exist.

public FileEvaluationCaptureStore(string directoryPath);

Parameters

directoryPath System.String

Absolute or relative path to the cache directory.

Methods

FileEvaluationCaptureStore.SaveAsync(string, ChatResponse, CancellationToken) Method

Persists response under key. Overwrites any existing entry for the same key.

public System.Threading.Tasks.Task SaveAsync(string key, Microsoft.Extensions.AI.ChatResponse response, System.Threading.CancellationToken cancellationToken);

Parameters

key System.String

Opaque request hash produced by the capture client.

response Microsoft.Extensions.AI.ChatResponse

The response to persist.

cancellationToken System.Threading.CancellationToken

Cancellation token.

Implements SaveAsync(string, ChatResponse, CancellationToken)

Returns

System.Threading.Tasks.Task

FileEvaluationCaptureStore.TryGetAsync(string, CancellationToken) Method

Looks up a previously captured response for key.

public System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatResponse?> TryGetAsync(string key, System.Threading.CancellationToken cancellationToken);

Parameters

key System.String

Opaque request hash produced by the capture client.

cancellationToken System.Threading.CancellationToken

Cancellation token.

Implements TryGetAsync(string, CancellationToken)

Returns

System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatResponse>
The cached Microsoft.Extensions.AI.ChatResponse when present, otherwise null.