How a Custom Evaluator Works
A custom evaluator is a Workflow app that you publish as an evaluation workflow. The evaluation runs it once for each row of the test set. The evaluator’s User Input node receives values you choose from that row’s run of the evaluated workflow: an input variable, such as the question, or a node’s output, such as the answer. The evaluator can’t read your test set’s reference answers, so leave comparisons with them to the built-in metrics. Each variable of the evaluator’s Output node comes back as one of the row’s custom metrics. An evaluation takes one custom evaluator. To check several rules, put them all in one evaluator, with a separate output for each rule you want to judge on its own. The evaluator’s runs are ordinary runs of its app. They appear in its Logs, one for each row it runs on.Build the Evaluator
Say your support workflow takes aquestion, retrieves passages from a knowledge base, and has an LLM node answer from them. Your team wants every answer to follow its style: answer the question that was asked, stay under about 120 words, and end with a next step the user can take.
To check these rules, create a Workflow app and name it Support Style Check. An evaluation workflow can’t contain Trigger nodes or Human Input nodes, so leave those out.
Take In the Values to Check
In the User Input node, add an input variable for each value the evaluator will receive. To tell whether an answer addresses its question, the evaluator needs both, so add two Paragraph variables:question and answer.
Score the Answer Against Your Rules
Choose the scoring node by the rule:- A rule that takes judgment, such as whether an answer addresses its question, needs an LLM node with your rubric.
- A rule a script can check exactly, such as a word count or a required value, fits a Code node.
Style Check and set its temperature to 0, since a scorer should give the same answer the same score every time. Write the rules into its system instruction, along with the score each outcome earns:
Return Scores Your Conditions Can Test
Each output becomes a metric, and its type decides how a judgment condition can test it:- Number (integer or decimal), such as a
score: compared with a threshold, such as ≥ 0.8 - Boolean, such as a
passedflag: checked as true or false - String, such as a
reason, and any other type: compared as text, for example with contains
Style Check, turn on structured output, and add two required fields:
Then add both fields to the Output node:
score, fromStyle Check’sstructured_output.scorereason, fromStyle Check’sstructured_output.reason
Publish It as an Evaluation Workflow
Publishing or switching an evaluation workflow requires the Publish and manage app versions permission.
score and reason it returns look right, open the Publish menu and click Publish as Evaluation Workflow.
To turn a workflow that’s already published into an evaluator, choose Switch to Evaluation Workflow instead. It converts the version that’s currently published, so publish any draft changes first.
An evaluation workflow can be turned back into a standard one, but evaluations that use it can’t run until it’s an evaluation workflow again.
Add It to an Evaluation
Open the support workflow’s Evaluation page, click Add Metric > Custom metrics, and selectSupport Style Check. If an evaluator a teammate built isn’t listed, ask for access to its app and the Test and use app permission on it.
Under Variable Mapping, choose what each of the evaluator’s input variables receives from the support workflow’s published version:
question, from the User Input node’squestionanswer, from the LLM node’stext, the answer itself
Pass or Fail Rows on Its Outputs
Under Judgment Conditions, add the conditionSupport Style Check / score ≥ 0.8. An answer that breaks any of the style rules scores below 0.8, so only one that follows all of them passes.
Custom and built-in metrics combine in the same conditions. Say the evaluation also scores the LLM node on Faithfulness. Add Faithfulness ≥ 0.8 too, and join the two conditions with AND.
Update or Delete an Evaluator
- Update its rules: edit the evaluator and publish. The update applies to runs started afterward.
- Delete it: first make sure no run that uses it is in progress, since deleting cancels those runs. Deleting removes it from every evaluation that uses it, along with the conditions on its outputs. An evaluation that had no other metrics loses its whole saved setup.
When the Evaluator Fails on a Row
A row usually showsEVAL_CUSTOM_EVALUATOR_FAILED for one of these reasons:
- A mapped value is missing in that row: the node it comes from didn’t run, or didn’t output the field you mapped. If a branch skipped the node, map from one that runs on every path instead.
- A mapped value doesn’t fit the evaluator’s input variable: for example, a value that isn’t text, or text longer than the variable’s length limit. The evaluator doesn’t run, so nothing shows in its Logs. Check each mapping against its variable’s type and length limit.
- The evaluator’s run failed: for example, its model call errored. Find that run in the evaluator app’s Logs to see what went wrong.
- The evaluator’s creator has left the workspace: the evaluator runs as the person who created it, so every row fails. Have a current member create a replacement, publish it as an evaluation workflow, and set it up in the evaluation in place of the old one.