Creating a deterministic evaluator
Create a custom deterministic evaluator in Cloudera Agent Studio that applies fixed, rule-based checks to the traces or sessions of an agent, without a language model.
A deterministic evaluator runs checks that return the same result for the same evidence. You define the evidence that the evaluator reads, which are the extractors, and the rules that the evaluator applies to that evidence, which are the checks. Agent Studio saves the evaluator as a versioned custom evaluator. After you save it, you can select it when you run an evaluation.
The name of the evaluator identifies it across versions, and the display name is the name that users see. If you save an evaluator with the name of an existing evaluator and the content is different, Agent Studio creates a new version. If the content is identical to an existing version, Agent Studio does not create a new version.
The New deterministic evaluator page has the following sections:
- Details: The Display name, Name, and Description of the evaluator.
- Scope and coverage: The evidence scopes that the evaluator supports and the Coverage policy.
- Evaluator definition: The Import definition JSON file picker and the collapsible Definition JSON text area. You can import or paste a definition, or you can build the definition in the Extractors and Checks sections.
- Extractors: The named evidence sources that the checks read from.
- Checks: The rules that run against one or more extractors. Each check contributes an assessment to the run.
In Scope and coverage, you select the evidence scopes and the coverage policy:
- Trace: The evaluator runs checks against single-trace evidence. This scope is selected by default.
- Session: The evaluator runs checks against session-level evidence.
- Require all extractors: The run fails if a required extractor cannot be populated. This policy is selected by default.
- Allow partial coverage: The evaluator can run when some extractors cannot be populated.
Each extractor has one of the following types:
- Final output: The text that the agent returned to the user.
- Tool arguments (not available yet): The arguments that the agent passed to a tool. The type is unavailable.
- Tool results (not available yet): The structured results of a tool call. The type is unavailable.
- Call log: The ordered tool-call and delegation events of the trace.
- Span log: The span-level log lines of the trace.
The cardinality of an extractor defines how many matches the extractor keeps:
all: Keep every match. The Call log and Span log types always useall.exactly_one: Fail if no match or more than one match exists.first: Use the first match in trace order.last: Use the last match in trace order.
Each check has one of the following types:
- Syntax: Parses extracted SQL or Python text.
- AST policy: Applies SQL or PySpark syntax-tree rules, such as allowed statements and forbidden nodes.
- Embedded syntax: Checks SQL that is embedded in PySpark call sites.
- JSON schema: Validates JSON against a schema from the expectations of the test case or from a snapshot.
- Schema snapshot: Compares the shape of extracted JSON with an expected snapshot.
- SQL lineage: Compares the tables that parsed SQL references with the expected tables.
- Value compare: Compares a scalar value with the value at the expectations path.
- Table compare: Compares the rows and columns of tabular tool output.
- Set relation: Checks whether two sets of values are equal, or whether one is a subset or a superset of the other, or whether they are disjoint.
- Text contains: Checks whether extracted text contains a substring or a token.
- Number in text: Compares the numbers in prose with the expected numbers.
- Count: Compares the number of tool calls, delegations, human-in-the-loop pauses, or plans with an expected limit.
- Uniqueness: Detects duplicate tool calls by selected key fields.
- Sequence: Compares the ordered tool calls or delegations with an expected sequence.
- Presence: Checks whether a plan, a delegation, or a human-in-the-loop pause occurred.
- Error rate: Limits the share of spans or tool spans that have errors.
Each check has a gating value. A check with the Required gating value blocks a pass when the check fails. A check with the Advisory gating value reports a signal and does not fail the run.
Each check returns one of the following statuses: PASS, FAIL, UNSCORABLE, PREMISE_UNMET, or SKIPPED.
- Plan the extractors and the checks. A definition has the following structure:
- schema_version: The value is always
deterministic-evaluator-v1. - supported_scopes:
["trace"],["session"], or["trace","session"]. - coverage_policy:
require_allorallow_partial. - extractors: An object of 1 to 32 extractors. The key of each extractor is its reference name. Each extractor has the fields type, version, cardinality, and required. A tool extractor also has the fields role and field. A Final output extractor can have the field language.
- checks: An array of 1 to 64 checks. Each check has the fields id, type, version, inputs, depends_on, gating, params, and expectation_path.
- schema_version: The value is always
- Ensure that the definition is 256 KiB or smaller.
- Optional: To import a definition, save the definition in a file with the extension .json. A check can depend only on checks that precede it in the checks array. The New deterministic evaluator page does not set depends_on, so use an imported definition to set it.
- Optional: To compare a value with the expected result of a test case, add the expectations object to the test cases of your test set. See Creating a test set.
- Ensure each serialized test case, including its expectations object, is
256 KiBor smaller. - Note the run limits. A check runs for up to 5 seconds, and all the checks of an evaluator run for up to 30 seconds.
After you save the evaluator, the Deterministic sub-tab of the Evaluators tab opens, and one of the following messages is displayed:
- Saved deterministic evaluator v<version>: Agent Studio saved the evaluator as a new version.
- Deterministic evaluator unchanged (v<version>): The content is identical to an existing version, and Agent Studio did not create a new version.
The evaluator is displayed in the Custom evaluators section. To use the evaluator, select it in the Evaluators section of the New run page. See Running an evaluation.
If the save fails, the alert Fix these issues before saving lists each error, and the message Fix the errors listed on this page, then save again. is displayed.
