Skip to content

RunSampler

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Decides whether to sample a completed run for online evaluation and, when sampled, queues a JobKind.OnlineEval job.

public sealed class RunSampler

objectRunSampler

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

This class only writes to the queue. The actual judge call, which spends money, runs in the background through OnlineEvalJobHandler. Like WebhookPublisher, it slows the main run path only by a fast queue write, so a slow or unreachable judge has no impact.

RunRecordingAgent wraps this call in try/catch. A sampling failure does not affect the run, as required by the observability rule.

RunSampler(IJobStore, IOptionsMonitor<OnlineEvaluationOptions>, TimeProvider?, ILogger<RunSampler>?)

Section titled “ RunSampler(IJobStore, IOptionsMonitor<OnlineEvaluationOptions>, TimeProvider?, ILogger<RunSampler>?)”

Decides whether to sample a completed run for online evaluation and, when sampled, queues a JobKind.OnlineEval job.

public RunSampler(IJobStore jobStore, IOptionsMonitor<OnlineEvaluationOptions> optionsMonitor, TimeProvider? timeProvider = null, ILogger<RunSampler>? logger = null)

jobStore IJobStore

optionsMonitor IOptionsMonitor<OnlineEvaluationOptions>

timeProvider TimeProvider?

logger ILogger<RunSampler>?

This class only writes to the queue. The actual judge call, which spends money, runs in the background through OnlineEvalJobHandler. Like WebhookPublisher, it slows the main run path only by a fast queue write, so a slow or unreachable judge has no impact.

RunRecordingAgent wraps this call in try/catch. A sampling failure does not affect the run, as required by the observability rule.

SampleAsync(RunSampleRequest, CancellationToken)

Section titled “ SampleAsync(RunSampleRequest, CancellationToken)”

Evaluates a run for sampling and queues it when required.

public ValueTask<bool> SampleAsync(RunSampleRequest request, CancellationToken cancellationToken = default)

request RunSampleRequest

The summary of the run to sample.

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

true when a job was queued.