Path: redb-route/redb.Route.Llm/Engine/Eval/LlmEvalCase.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/Engine/Eval/LlmEvalCase.cs
----
using redb.Route.Llm.Abstractions.Tools;
using redb.Route.Llm.Engine.Governance;
using redb.Route.Llm.Providers;
namespace redb.Route.Llm.Engine.Eval;
///
/// Declarative description of a single eval case. Combines the inputs the harness
/// feeds to with the assertions it scores
/// against the produced . Cases are pure data so the
/// same set can be replayed offline (via ReplayProvider) and against a
/// live provider.
///
public sealed class LlmEvalCase
{
/// Stable scenario name — also persisted on .
public required string Scenario { get; init; }
/// System prompt for the run. Null = no system prompt.
public string? SystemPrompt { get; init; }
/// User content blocks for the initial turn. Use for the common text-only case.
public IReadOnlyList UserContent { get; init; } = [];
/// Tools available to the model on this case (empty = no tools).
public IReadOnlyList Tools { get; init; } = [];
/// Maximum tool-loop iterations forwarded to .
public int MaxIterations { get; init; } = 4;
/// Per-run budget forwarded to .
public AgentBudget Budget { get; init; } = AgentBudget.Unbounded;
/// Sampling temperature override.
public double? Temperature { get; init; }
/// Max-tokens override.
public int? MaxTokens { get; init; }
/// Substrings the final assistant text must contain (case-sensitive).
public IReadOnlyList ExpectedTextContains { get; init; } = [];
/// Substrings the final assistant text must NOT contain (case-sensitive).
public IReadOnlyList ExpectedTextNotContains { get; init; } = [];
/// Tool names that must be invoked at least once across the run (in any order).
public IReadOnlyList ExpectedToolCalls { get; init; } = [];
/// When set, the run's final stop reason must equal this value.
public LlmStopReason? ExpectedStopReason { get; init; }
/// When set, the run's iteration count must be ≤ this value.
public int? MaxObservedIterations { get; init; }
/// When set, the run's total cost must be ≤ this value (USD).
public decimal? MaxObservedCostUsd { get; init; }
///
/// Optional custom scorer — receives the final and
/// returns a . Composes with the built-in
/// assertions: a case fails when any built-in assertion fails OR the custom
/// scorer returns = false.
///
public Func? CustomScorer { get; init; }
/// Convenience: builds a single-text-block .
public static IReadOnlyList UserText(string text) => [new LlmTextBlock(text)];
}
///
/// Outcome of a custom scorer. Pass=false marks the case as failed regardless of
/// other assertions; and flow into
/// the persisted .
///
public readonly record struct LlmEvalCaseScore(
bool Pass,
double? Score = null,
IReadOnlyDictionary? Dimensions = null,
string? Notes = null)
{
/// Convenience: passing score with no extras.
public static readonly LlmEvalCaseScore Passed = new(true);
}