Skip to main content

RAG, agent, image and voice scorers

An eval scorer decides whether one answer is good. This page covers sixteen scorers for four kinds of work that plain text checks cannot grade well. Two grade answers built from retrieved documents, two check what an agent did without any judge model, five judge images inside an answer, and seven measure recorded voice audio without any judge model. You choose them in the same Scorer dropdown and send them in the same scorer object as every scorer in the metric catalogue, and they are part of the enterprise evals feature.

A real-world scenario​

A travel company runs three assistants through the gateway. Its booking agent once called the same search tool forty times in a row and once tried cancel_booking while only meant to search. The team adds a nightly eval with agent_loop_detection and tool_permission set to deny cancel_booking, and both cost nothing because no judge model is called. Its help center answers questions from retrieved articles and cites them, so a weekly run grades it with citation_faithfulness and ragas. Its phone line records each call, so the team exports a few short calls as conversations with a WAV clip on every assistant turn and scores them with agent_responsiveness and audio_integrity, which catch an assistant that went silent or whose audio cut off. The image generator for travel brochures is graded with text_to_image, which asks a vision model whether each picture matches its prompt.

The scorers​

ScorerWhat it checksNeeds a judge modelItem needs
citation_faithfulnessEvery passage the answer cites from retrieval_context really says what it is cited for.Yesretrieval_context
ragasThe RAGAS score, the average of contextual precision, contextual recall, faithfulness and answer relevancy.Yesexpected and retrieval_context
agent_loop_detectionThe agent never repeats the same tool call with the same arguments, never repeats its previous reply and never calls back into itself.NoNothing
tool_permissionEvery tool call is on allowed_tools, when you set it, and not on denied_tools.NoNothing
text_to_imageThe image in the answer follows the prompt and looks good.Yes, a vision modelAn image in the answer
image_editingThe image in the answer applies the edit the prompt asks for to the image in the prompt.Yes, a vision modelAn image in the prompt and the answer
image_coherenceEach image in the answer fits the text around it.Yes, a vision modelAn image in the answer
image_helpfulnessEach image in the answer helps the reader understand the text around it.Yes, a vision modelAn image in the answer
image_referenceThe text around each image refers to that image accurately.Yes, a vision modelAn image in the answer
voice_naturalnessThe assistant's recorded speech has a natural pitch, pace and pauses.Noaudio
turn_taking_naturalnessThe gaps and overlaps between recorded turns feel like a natural conversation.Noaudio with a start_time on every clip
speech_intelligibilityThe assistant's recorded speech is loud and clear enough to follow.Noaudio
voice_consistencyThe assistant sounds like the same voice in every recorded turn.Noaudio on at least two assistant turns
agent_responsivenessThe assistant answers every user turn with audio, so nobody has to repeat themselves.Noaudio
audio_integrityThe assistant's audio has no dropouts, clipping, loops or cut-off endings.Noaudio
voice_reliabilityThe average of agent responsiveness and audio integrity, 0 when either finds a critical failure such as a turn with no audio.Noaudio

Every scorer takes a threshold from 0 to 1, and an item passes when its score reaches it. The default is 0.5, except tool_permission, whose default of 1 fails an item on its first forbidden call. Judged scorers take a judge_model, which must be a model the gateway serves, and every judge call goes through the gateway's router as you, so it is logged and charged like any other request.

ragas runs its four parts as separate judge calls through the gateway, so it needs no separate RAGAS package and no provider key of its own. Its reason lists each part's score, and the item fails when any part produces no score.

agent_loop_detection and tool_permission read the whole conversation, so they run in Replay conversation, Agent with tools and Score logged conversation mode. agent_loop_detection takes repetition_threshold, how many identical calls count as a loop (2 to 100, default 3), and similarity_threshold, how alike two replies in a row must be to count as stuck (0.5 to 1, default 0.85). tool_permission takes allowed_tools and denied_tools, lists of tool names as the conversation shows them, and needs at least one of them. A tool on both lists counts as denied, and an item that called no tool scores 1. An agent that was still calling tools when it hit max_steps, or a logged conversation that ends on a tool call, is scored on its calls like any other, so a loop that ran out of steps shows up as a low score, not an error. Both scorers also work on online scoring rules, so you can watch live agents for loops and forbidden calls.

Images​

The image scorers find images inside the text of the prompt and the answer, written as Markdown images, for example ![the beach](https://images.example.com/beach.png). A prompt whose input is a conversation can also attach images to a user turn with images, a list of URLs. An image must be an https URL or a data:image/png, jpeg, gif or webp base64 URL. Anything else, such as an http link or a file path, stays plain text, so the gateway never reads a file from its own disk and never fetches an image itself. The judge model receives each image as an image part of its message, so it must be a vision model, and the image is sent to that model's provider. Images on user turns are also sent to the model under test in replay and agent mode, so a dataset can test vision models too.

Voice​

The voice scorers measure recorded audio, so they need a conversation whose turns carry it. Add audio to a user or assistant message with data_url, the recording as a data:audio/wav;base64 URL of 16-bit PCM WAV, and an optional start_time, the seconds from the start of the call to the start of that turn. Score such a dataset in Score logged conversation mode, which grades the conversation as it was recorded and calls no model. Audio is never sent to a model, and online rules refuse voice scorers, because live traffic carries no recording.

An item is stored as JSON and may be at most 256 KiB, so a dataset holds short calls, roughly 6 seconds of 16 kHz mono audio or 12 seconds at 8 kHz telephone quality in each item. Split a long call into several items. Recordings of people's voices are personal data, so keep only calls you are allowed to keep, and note that datasets you create yourself stay until you delete them.

Steps​

Through the Admin UI:

  1. Open /ui/evals and stay on the Datasets tab. Click New dataset, enter a name, keep Paste rows and paste one JSON object per line, for example the voice item below, then click Create dataset.
  2. Open the Runs tab and click New run. Pick the dataset. For voice, choose Score logged conversation under Run mode. For the agent checks, choose Agent with tools or Replay conversation and pick the models.
  3. In Scorer, choose the scorer, for example agent_responsiveness, fill in its settings, such as a judge model for the image scorers or the tool names for tool_permission, and click Start run. A "Some items lack what this scorer needs" warning counts the items without the image, audio or retrieval context the scorer reads.
  4. Open the run from the list when its status reads Completed and read each result's score and reason.

Through the API, with a proxy admin key in SPANWAY_API_KEY:

curl -X POST http://localhost:4000/eval/datasets \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "phone line, short calls",
"items": [
{
"item_id": "call-1",
"input": [
{"role": "user", "content": "I want to change my flight."},
{"role": "assistant", "content": "Sure, what is your booking code?", "audio": {"data_url": "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YQAAAAA=", "start_time": 1.2}}
]
}
]
}'

curl -X POST http://localhost:4000/eval/runs \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"dataset_id": "<dataset_id>",
"mode": "logged",
"scorer": {"type": "agent_responsiveness"}
}'

An agent check on a replayed conversation, and an image judge:

curl -X POST http://localhost:4000/eval/runs \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"dataset_id": "<dataset_id>", "models": ["booking-agent"], "mode": "agent", "scorer": {"type": "tool_permission", "denied_tools": ["cancel_booking"]}}'

curl -X POST http://localhost:4000/eval/runs \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"dataset_id": "<dataset_id>", "models": ["brochure-images"], "scorer": {"type": "text_to_image", "judge_model": "<a vision model>"}}'

GET /eval/scorers lists every scorer with its settings, defaults and the item fields it needs.

Expected result​

Each result carries a score, a verdict and the scorer's reason. A booking agent that called search_rooms six times with the same arguments reads "score": 0.6 with the reason Tool 'search_rooms' called 6 times with identical arguments., a forbidden call reads 1 of 2 tool call(s) were unauthorized: ['cancel_booking'], a phone call where the assistant answered every turn reads "score": 1.0 with The agent responded without requiring a reprompt., and a ragas result reads, for example, ContextualPrecision 0.80; ContextualRecall 1.00; Faithfulness 0.90; AnswerRelevancy 0.95.

Errors​

StatusBody or result errorMeaning and fix
400{"detail": {"error": "scorer: tool_permission needs allowed_tools, denied_tools or both"}}The tool permission scorer was sent with both lists empty. Name the tools to allow or deny.
400{"detail": {"error": "scorer agent_loop_detection needs the evals extra installed on the proxy"}}The gateway image lacks the eval components. Use a Spanway image, which carries them.
400{"detail": {"error": "scorers[0]: voice_naturalness needs audio, which live traffic does not carry"}}A voice scorer was put on an online rule. Score recorded calls in a dataset run instead.
422an image must be an https URL or a base64 data:image/png, jpeg, gif or webp URLAn item's images holds a path, an http link or another kind of file. Host the image on https or embed it as a data URL.
422audio must be a base64 data:audio/wav URLA turn's audio is not a base64 WAV data URL. Convert the recording to WAV and embed it.
Result erroritem call-1 has no audio, which voice_naturalness needsThe item has no recorded turn. Add audio to its assistant turns.
Result errorvoice_consistency: At least two decodable assistant audio turns are required to evaluate voice consistency.The scorer needs more recordings than the item has.
Result errortext_to_image: ValueError: The test case must have atleast one image in the actual_output ...The answer holds no Markdown image with an https or data:image URL.
Result errorragas: ContextualRecallMetric: ...One of the four RAGAS parts failed, often because the judge did not answer in the format it was asked for. Try a stronger judge model.

Errors about the dataset, the run mode or the models are the same as for any eval run, see the evals page.

Logs​

These scorers add no log lines of their own. Judge calls appear in the request logs like any other request, labelled with the eval run they belong to, and a run that fails carries the cause in its error field.