Evaluate it before you rely on it
Eight test cases, a pass rule, a gate, and how to read and act on the judge.
The snippets on this page reuse the client from the setup.
Step 6: Evaluate it before you rely on it
You have seen it work on two examples. That is not evidence. An evaluation runs the real intent over a set of cases whose right answers you already know and tells you how often it is right. You will use one whenever you change the prompt, the policy or the model, so a regression shows up before your users see it.
An evaluation has three parts:
- A dataset: cases, each with an input and the output you expect.
- A suite: a dataset pointed at an intent, with a pass rule.
- A run: one execution of the suite, with a score for every case.
The dataset has eight disputes. It covers every category, a genuinely angry customer, a case where the cardholder suspects a relative, and a case where charges are still appearing.
{
"name": "Dispute triage cases",
"description": "Eight cardholder disputes covering every category, an angry message and a possible family use.",
"cases": [
{ "input": { "message": "I ordered a laptop stand three weeks ago and it never arrived. The seller has stopped answering.", "transaction": { "merchant": "DESKGEAR ONLINE", "amount": 84.5, "currency": "USD", "date": "2026-11-02", "card_type": "debit" }, "today": "2026-11-29" }, "expected_output": { "category": "merchandise_not_received", "urgency": "normal" } },
{ "input": { "message": "I did not make this purchase. I was at work and my card was in my wallet.", "transaction": { "merchant": "GLOBALTECH ELECTRONICS", "amount": 1249.0, "currency": "USD", "date": "2026-11-20", "card_type": "debit" }, "today": "2026-11-29" }, "expected_output": { "category": "unauthorized", "urgency": "high" } },
{ "input": { "message": "I was charged twice for the same 59.99 subscription box on the same day.", "transaction": { "merchant": "BOXLY", "amount": 59.99, "currency": "USD", "date": "2026-11-10", "card_type": "credit" }, "today": "2026-11-29" }, "expected_output": { "category": "duplicate", "urgency": "normal" } },
{ "input": { "message": "I agreed to pay 40 dollars for the repair but the garage charged my card 400.", "transaction": { "merchant": "MAPLE AUTO REPAIR", "amount": 400.0, "currency": "USD", "date": "2026-11-15", "card_type": "credit" }, "today": "2026-11-29" }, "expected_output": { "category": "incorrect_amount", "urgency": "normal" } },
{ "input": { "message": "I cancelled this streaming plan in September and it charged me again this month.", "transaction": { "merchant": "STREAMLY", "amount": 14.99, "currency": "USD", "date": "2026-11-05", "card_type": "credit" }, "today": "2026-11-29" }, "expected_output": { "category": "cancelled_subscription", "urgency": "normal" } },
{ "input": { "message": "I do not recognise this charge, but my brother borrowed my card last week so it might be his.", "transaction": { "merchant": "CITY FUEL", "amount": 62.3, "currency": "USD", "date": "2026-11-18", "card_type": "debit" }, "today": "2026-11-29" }, "expected_output": { "category": "other", "urgency": "normal" } },
{ "input": { "message": "This is complete bullshit, you charged me twice for the same order and nobody has called me back.", "transaction": { "merchant": "PIXEL SHOP", "amount": 129.0, "currency": "USD", "date": "2026-11-12", "card_type": "credit" }, "today": "2026-11-29" }, "expected_output": { "category": "duplicate", "urgency": "normal" } },
{ "input": { "message": "Someone has my card. There are new charges appearing right now that I did not make, please stop them.", "transaction": { "merchant": "QUICKMART", "amount": 212.4, "currency": "USD", "date": "2026-11-28", "card_type": "debit" }, "today": "2026-11-29" }, "expected_output": { "category": "unauthorized", "urgency": "high" } }
]
}Save it as dataset.json. The pass rule is a one-line expression that compares what the intent returned (output) with what you expected (expected): a case passes when both the category and the urgency match.
- Open Evaluations โ Datasets, choose New dataset, and add the eight cases from the JSON below.
- Open Evaluations โ Suites and choose New suite. Name it Dispute triage.
- Pick the Classify a dispute intent and the dataset you just made.
- Add a custom scorer with the expression
output.category == expected.category && output.urgency == expected.urgency, labelled Category and urgency match. - Set the gate's minimum pass rate to 0.85, and save.
- Choose Run. When it finishes, open Evaluations โ Runs and open the run.
The finished run, trimmed:
{
"status": "completed",
"progress": 100,
"cases_total": 8,
"cases_passed": 8,
"mean_score": 4.22,
"dimension_scores": {
"llm_coherence": 4.88,
"llm_faithfulness": 3.13,
"llm_actionability": 4,
"llm_answer_relevance": 5,
"llm_context_relevance": 4.13
}
}8 of 8 cases passed. Read the result in two layers, because they answer different questions:
- The pass rule decides pass or fail. It is deterministic: it compares fields and nothing else. That is why your gate should be built on it.
- The
llm_*dimensions are an AI judge's opinion, scored 1 to 5 against the sources. They are advisory (severity: warning) and they show what to improve. Here faithfulness is the lowest at 3.13, which is worth reading, because it points at something real.
Each case in results also carries the answer the intent gave, ready to use: output_text is the answer text, and output_structured is the parsed JSON for an intent with an output schema. Failing cases tell you which check failed and why.
What an evaluation costs
A run calls your intent once per case and then calls a judge model several times per answer. This run of eight cases cost about $0.80 in judge calls on the models this workspace was configured with. Costs follow your model settings. Watch them under Observe โ Costs, and keep datasets small until you need them to be large.
Read the judge, then fix the cause
Every dimension score comes with the judge's reasoning, in judge_rationale on each case's scores. Open the faithfulness ones. Seven of the eight cases scored a 3 for the same reason:
โฆthe rationale cites policy section identifiers 'DSP-130' and 'DSP-110' that appear nowhere in the retrieved context, making those attributions unsupported.
The judge is right, and the cause is in your knowledge, not your model. The prompt tells the model to cite DSP-130 and DSP-110, but those codes appear only in the headings of the two files. A passage retrieved for a call is a piece of the file, and the heading is usually not in it. So the model wrote down codes it could not see in its sources.
The fix is to make every passage carry its own label. Put the code in each paragraph:
**unauthorized** (DSP-130): the cardholder says they did not make or approve the transactionโฆ
**merchandise_not_received** (DSP-130): the cardholder paid for goods or a service that never arrivedโฆ**Debit cards (DSP-110, Regulation E).** A cardholder has 60 days from the date of the statementโฆ
**Urgency (DSP-110).** Set urgency to `high` when the cardholder reports that the card may be stolenโฆReplace the two documents, then run the same suite again. Remove the old documents first, so the collection holds only the corrected text.
- Open Knowledge โ Documents, delete the two dispute documents, and upload the edited files into the Card dispute policy collection.
- Open Evaluations โ Suites โ Dispute triage and choose Run again.
- Compare the two runs under Evaluations โ Runs.
The same eight cases, with nothing changed except the knowledge:
| First run | After the fix | |
|---|---|---|
| Cases passed | 8 of 8 | 8 of 8 |
| Faithfulness | 3.13 | 4.63 |
| Mean score | 4.22 | 4.50 |
The pass rule never moved, because the answers were already right. The fix shows up only in the judged dimension, which is why you read both layers. Notice also what you did: you changed a document, not the prompt or the model, and you proved the change with a measurement. That is the loop to keep: change one thing, run the suite, compare.
Use the result as a gate
A suite with a gate can answer one question: may this change ship? Ask for it from your deployment pipeline:
curl -s "$LIYA_API_URL/v1/evals/suites/$SUITE_ID/gate" -H "Authorization: Bearer $LIYA_API_KEY" | jq '.data.gate'{
"gate_configured": true,
"run_status": "completed",
"gate_decision": "passed",
"gate_failure_reasons": [],
"evaluation_outcome": "passed",
"mean_score": 4.22,
"cases_total": 8,
"cases_passed": 8
}Fail your build when gate_decision is not passed. See Evaluation API and Evaluations for baselines, comparing models and scheduled runs.
Put it into production
Your application now calls this intent with a runtime key, which can run intents but cannot create or change anything. Create one under Administration โ API Keys, store it on your server, and send the same POST /v1/run request you used in step 4. Then:
- Read your traces under Observe โ Traces to see every call, its sources, its cost and any flag.
- Re-run the suite whenever you change the prompt, the policy, the knowledge or the model.
- When the policy changes, upload the new document into the collection. The intent retrieves from it immediately.
What you built
| Piece | Where it lives | What it does |
|---|---|---|
Domain dispute-desk | Build โ Domains | Shared instructions, knowledge and policy |
Collection card-dispute-policy | Knowledge โ Collections | Your policy, split into retrievable passages |
Intent classify_dispute | Build โ Intents | A typed contract: input in, validated JSON out |
| Policy "Dispute desk - staff" | Guardrails โ Policies | Stops injected instructions before the model sees them |
| Suite "Dispute triage" | Evaluations โ Suites | Eight known answers, a pass rule and a gate |
Next
Protect it with a guardrail template
Start from a financial services template, then watch it refuse injected instructions.
Build a health plan member assistant
Build a conversational agent that answers a health plan member's questions from the plan's own documents, with healthcare guardrails, a conversation that remembers, and a way to report a wrong answer. Every step shows the Dashboard, the REST API, and the JavaScript and Python SDKs.