@mastra/evals 0.0.0-error-handler-fix-20251020202607 → 0.0.0-esbuild-bundle-worker-20260807182016

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/CHANGELOG.md +950 -5
  2. package/LICENSE.md +15 -0
  3. package/README.md +19 -159
  4. package/dist/checks-64AonnEK.js +379 -0
  5. package/dist/checks-64AonnEK.js.map +1 -0
  6. package/dist/checks-DGTgg-nW.cjs +479 -0
  7. package/dist/checks-DGTgg-nW.cjs.map +1 -0
  8. package/dist/checks.cjs +14 -0
  9. package/dist/checks.d.ts +3 -0
  10. package/dist/checks.d.ts.map +1 -0
  11. package/dist/checks.js +2 -0
  12. package/dist/docs/SKILL.md +49 -0
  13. package/dist/docs/assets/SOURCE_MAP.json +6 -0
  14. package/dist/docs/references/docs-evals-built-in-scorers.md +66 -0
  15. package/dist/docs/references/docs-evals-overview.md +163 -0
  16. package/dist/docs/references/docs-evals-quick-checks.md +137 -0
  17. package/dist/docs/references/reference-evals-answer-relevancy.md +107 -0
  18. package/dist/docs/references/reference-evals-answer-similarity.md +99 -0
  19. package/dist/docs/references/reference-evals-bias.md +122 -0
  20. package/dist/docs/references/reference-evals-checks.md +212 -0
  21. package/dist/docs/references/reference-evals-completeness.md +138 -0
  22. package/dist/docs/references/reference-evals-content-similarity.md +103 -0
  23. package/dist/docs/references/reference-evals-context-precision.md +198 -0
  24. package/dist/docs/references/reference-evals-context-recall.md +205 -0
  25. package/dist/docs/references/reference-evals-context-relevance.md +533 -0
  26. package/dist/docs/references/reference-evals-faithfulness.md +116 -0
  27. package/dist/docs/references/reference-evals-hallucination.md +206 -0
  28. package/dist/docs/references/reference-evals-keyword-coverage.md +130 -0
  29. package/dist/docs/references/reference-evals-noise-sensitivity.md +677 -0
  30. package/dist/docs/references/reference-evals-prompt-alignment.md +617 -0
  31. package/dist/docs/references/reference-evals-rubric.md +115 -0
  32. package/dist/docs/references/reference-evals-scorer-utils.md +516 -0
  33. package/dist/docs/references/reference-evals-summarization.md +203 -0
  34. package/dist/docs/references/reference-evals-textual-difference.md +115 -0
  35. package/dist/docs/references/reference-evals-tone-consistency.md +121 -0
  36. package/dist/docs/references/reference-evals-tool-call-accuracy.md +535 -0
  37. package/dist/docs/references/reference-evals-toxicity.md +125 -0
  38. package/dist/docs/references/reference-evals-trajectory-accuracy.md +629 -0
  39. package/dist/index.cjs +12 -91
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +11 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +13 -87
  44. package/dist/index.js.map +1 -1
  45. package/dist/scorers/code/checks/index.d.ts +214 -0
  46. package/dist/scorers/code/checks/index.d.ts.map +1 -0
  47. package/dist/scorers/code/completeness/index.d.ts +1 -1
  48. package/dist/scorers/code/completeness/index.d.ts.map +1 -1
  49. package/dist/scorers/code/content-similarity/index.d.ts +1 -1
  50. package/dist/scorers/code/content-similarity/index.d.ts.map +1 -1
  51. package/dist/scorers/code/index.d.ts +2 -0
  52. package/dist/scorers/code/index.d.ts.map +1 -1
  53. package/dist/scorers/code/keyword-coverage/index.d.ts +1 -1
  54. package/dist/scorers/code/keyword-coverage/index.d.ts.map +1 -1
  55. package/dist/scorers/code/textual-difference/index.d.ts +1 -1
  56. package/dist/scorers/code/textual-difference/index.d.ts.map +1 -1
  57. package/dist/scorers/code/tone/index.d.ts +1 -1
  58. package/dist/scorers/code/tone/index.d.ts.map +1 -1
  59. package/dist/scorers/code/tool-call-accuracy/index.d.ts +2 -2
  60. package/dist/scorers/code/tool-call-accuracy/index.d.ts.map +1 -1
  61. package/dist/scorers/code/trajectory/index.d.ts +164 -0
  62. package/dist/scorers/code/trajectory/index.d.ts.map +1 -0
  63. package/dist/scorers/index.d.ts +1 -0
  64. package/dist/scorers/index.d.ts.map +1 -1
  65. package/dist/scorers/llm/answer-relevancy/index.d.ts +2 -1
  66. package/dist/scorers/llm/answer-relevancy/index.d.ts.map +1 -1
  67. package/dist/scorers/llm/answer-similarity/index.d.ts +3 -2
  68. package/dist/scorers/llm/answer-similarity/index.d.ts.map +1 -1
  69. package/dist/scorers/llm/bias/index.d.ts +2 -2
  70. package/dist/scorers/llm/bias/index.d.ts.map +1 -1
  71. package/dist/scorers/llm/context-precision/index.d.ts +4 -3
  72. package/dist/scorers/llm/context-precision/index.d.ts.map +1 -1
  73. package/dist/scorers/llm/context-recall/index.d.ts +20 -0
  74. package/dist/scorers/llm/context-recall/index.d.ts.map +1 -0
  75. package/dist/scorers/llm/context-recall/prompts.d.ts +19 -0
  76. package/dist/scorers/llm/context-recall/prompts.d.ts.map +1 -0
  77. package/dist/scorers/llm/context-relevance/index.d.ts +5 -4
  78. package/dist/scorers/llm/context-relevance/index.d.ts.map +1 -1
  79. package/dist/scorers/llm/faithfulness/index.d.ts +4 -1
  80. package/dist/scorers/llm/faithfulness/index.d.ts.map +1 -1
  81. package/dist/scorers/llm/hallucination/index.d.ts +20 -3
  82. package/dist/scorers/llm/hallucination/index.d.ts.map +1 -1
  83. package/dist/scorers/llm/index.d.ts +4 -0
  84. package/dist/scorers/llm/index.d.ts.map +1 -1
  85. package/dist/scorers/llm/noise-sensitivity/index.d.ts +3 -2
  86. package/dist/scorers/llm/noise-sensitivity/index.d.ts.map +1 -1
  87. package/dist/scorers/llm/prompt-alignment/index.d.ts +7 -7
  88. package/dist/scorers/llm/prompt-alignment/index.d.ts.map +1 -1
  89. package/dist/scorers/llm/rubric/index.d.ts +71 -0
  90. package/dist/scorers/llm/rubric/index.d.ts.map +1 -0
  91. package/dist/scorers/llm/rubric/prompts.d.ts +37 -0
  92. package/dist/scorers/llm/rubric/prompts.d.ts.map +1 -0
  93. package/dist/scorers/llm/summarization/index.d.ts +55 -0
  94. package/dist/scorers/llm/summarization/index.d.ts.map +1 -0
  95. package/dist/scorers/llm/summarization/prompts.d.ts +48 -0
  96. package/dist/scorers/llm/summarization/prompts.d.ts.map +1 -0
  97. package/dist/scorers/llm/tool-call-accuracy/index.d.ts +4 -4
  98. package/dist/scorers/llm/tool-call-accuracy/index.d.ts.map +1 -1
  99. package/dist/scorers/llm/toxicity/index.d.ts +2 -1
  100. package/dist/scorers/llm/toxicity/index.d.ts.map +1 -1
  101. package/dist/scorers/llm/trajectory/index.d.ts +58 -0
  102. package/dist/scorers/llm/trajectory/index.d.ts.map +1 -0
  103. package/dist/scorers/llm/trajectory/prompts.d.ts +20 -0
  104. package/dist/scorers/llm/trajectory/prompts.d.ts.map +1 -0
  105. package/dist/scorers/prebuilt/index.cjs +4546 -0
  106. package/dist/scorers/prebuilt/index.cjs.map +1 -0
  107. package/dist/scorers/prebuilt/index.d.ts +3 -0
  108. package/dist/scorers/prebuilt/index.d.ts.map +1 -0
  109. package/dist/scorers/prebuilt/index.js +4503 -0
  110. package/dist/scorers/prebuilt/index.js.map +1 -0
  111. package/dist/scorers/utils.cjs +967 -58
  112. package/dist/scorers/utils.cjs.map +1 -1
  113. package/dist/scorers/utils.d.ts +563 -16
  114. package/dist/scorers/utils.d.ts.map +1 -1
  115. package/dist/scorers/utils.js +939 -2
  116. package/dist/scorers/utils.js.map +1 -1
  117. package/package.json +42 -68
  118. package/dist/attachListeners.d.ts +0 -4
  119. package/dist/attachListeners.d.ts.map +0 -1
  120. package/dist/chunk-7QAUEU4L.cjs +0 -10
  121. package/dist/chunk-7QAUEU4L.cjs.map +0 -1
  122. package/dist/chunk-EMMSS5I5.cjs +0 -37
  123. package/dist/chunk-EMMSS5I5.cjs.map +0 -1
  124. package/dist/chunk-G3PMV62Z.js +0 -33
  125. package/dist/chunk-G3PMV62Z.js.map +0 -1
  126. package/dist/chunk-IUSAD2BW.cjs +0 -19
  127. package/dist/chunk-IUSAD2BW.cjs.map +0 -1
  128. package/dist/chunk-KHEXN75Q.js +0 -134
  129. package/dist/chunk-KHEXN75Q.js.map +0 -1
  130. package/dist/chunk-QKR2PMLZ.cjs +0 -148
  131. package/dist/chunk-QKR2PMLZ.cjs.map +0 -1
  132. package/dist/chunk-QTWX6TKR.js +0 -8
  133. package/dist/chunk-QTWX6TKR.js.map +0 -1
  134. package/dist/chunk-YGTIO3J5.js +0 -17
  135. package/dist/chunk-YGTIO3J5.js.map +0 -1
  136. package/dist/dist-E463LOAZ.js +0 -16729
  137. package/dist/dist-E463LOAZ.js.map +0 -1
  138. package/dist/dist-KKO3PIUK.cjs +0 -16751
  139. package/dist/dist-KKO3PIUK.cjs.map +0 -1
  140. package/dist/evaluation.d.ts +0 -8
  141. package/dist/evaluation.d.ts.map +0 -1
  142. package/dist/magic-string.es-7ORA5OGR.js +0 -1305
  143. package/dist/magic-string.es-7ORA5OGR.js.map +0 -1
  144. package/dist/magic-string.es-NZ2XWFKN.cjs +0 -1311
  145. package/dist/magic-string.es-NZ2XWFKN.cjs.map +0 -1
  146. package/dist/metrics/index.d.ts +0 -4
  147. package/dist/metrics/index.d.ts.map +0 -1
  148. package/dist/metrics/judge/index.cjs +0 -12
  149. package/dist/metrics/judge/index.cjs.map +0 -1
  150. package/dist/metrics/judge/index.d.ts +0 -7
  151. package/dist/metrics/judge/index.d.ts.map +0 -1
  152. package/dist/metrics/judge/index.js +0 -3
  153. package/dist/metrics/judge/index.js.map +0 -1
  154. package/dist/metrics/llm/answer-relevancy/index.d.ts +0 -16
  155. package/dist/metrics/llm/answer-relevancy/index.d.ts.map +0 -1
  156. package/dist/metrics/llm/answer-relevancy/metricJudge.d.ts +0 -20
  157. package/dist/metrics/llm/answer-relevancy/metricJudge.d.ts.map +0 -1
  158. package/dist/metrics/llm/answer-relevancy/prompts.d.ts +0 -19
  159. package/dist/metrics/llm/answer-relevancy/prompts.d.ts.map +0 -1
  160. package/dist/metrics/llm/bias/index.d.ts +0 -14
  161. package/dist/metrics/llm/bias/index.d.ts.map +0 -1
  162. package/dist/metrics/llm/bias/metricJudge.d.ts +0 -14
  163. package/dist/metrics/llm/bias/metricJudge.d.ts.map +0 -1
  164. package/dist/metrics/llm/bias/prompts.d.ts +0 -14
  165. package/dist/metrics/llm/bias/prompts.d.ts.map +0 -1
  166. package/dist/metrics/llm/context-position/index.d.ts +0 -16
  167. package/dist/metrics/llm/context-position/index.d.ts.map +0 -1
  168. package/dist/metrics/llm/context-position/metricJudge.d.ts +0 -20
  169. package/dist/metrics/llm/context-position/metricJudge.d.ts.map +0 -1
  170. package/dist/metrics/llm/context-position/prompts.d.ts +0 -17
  171. package/dist/metrics/llm/context-position/prompts.d.ts.map +0 -1
  172. package/dist/metrics/llm/context-precision/index.d.ts +0 -16
  173. package/dist/metrics/llm/context-precision/index.d.ts.map +0 -1
  174. package/dist/metrics/llm/context-precision/metricJudge.d.ts +0 -20
  175. package/dist/metrics/llm/context-precision/metricJudge.d.ts.map +0 -1
  176. package/dist/metrics/llm/context-precision/prompts.d.ts +0 -17
  177. package/dist/metrics/llm/context-precision/prompts.d.ts.map +0 -1
  178. package/dist/metrics/llm/context-relevancy/index.d.ts +0 -16
  179. package/dist/metrics/llm/context-relevancy/index.d.ts.map +0 -1
  180. package/dist/metrics/llm/context-relevancy/metricJudge.d.ts +0 -16
  181. package/dist/metrics/llm/context-relevancy/metricJudge.d.ts.map +0 -1
  182. package/dist/metrics/llm/context-relevancy/prompts.d.ts +0 -13
  183. package/dist/metrics/llm/context-relevancy/prompts.d.ts.map +0 -1
  184. package/dist/metrics/llm/contextual-recall/index.d.ts +0 -16
  185. package/dist/metrics/llm/contextual-recall/index.d.ts.map +0 -1
  186. package/dist/metrics/llm/contextual-recall/metricJudge.d.ts +0 -16
  187. package/dist/metrics/llm/contextual-recall/metricJudge.d.ts.map +0 -1
  188. package/dist/metrics/llm/contextual-recall/prompts.d.ts +0 -13
  189. package/dist/metrics/llm/contextual-recall/prompts.d.ts.map +0 -1
  190. package/dist/metrics/llm/faithfulness/index.d.ts +0 -16
  191. package/dist/metrics/llm/faithfulness/index.d.ts.map +0 -1
  192. package/dist/metrics/llm/faithfulness/metricJudge.d.ts +0 -22
  193. package/dist/metrics/llm/faithfulness/metricJudge.d.ts.map +0 -1
  194. package/dist/metrics/llm/faithfulness/prompts.d.ts +0 -20
  195. package/dist/metrics/llm/faithfulness/prompts.d.ts.map +0 -1
  196. package/dist/metrics/llm/hallucination/index.d.ts +0 -16
  197. package/dist/metrics/llm/hallucination/index.d.ts.map +0 -1
  198. package/dist/metrics/llm/hallucination/metricJudge.d.ts +0 -22
  199. package/dist/metrics/llm/hallucination/metricJudge.d.ts.map +0 -1
  200. package/dist/metrics/llm/hallucination/prompts.d.ts +0 -17
  201. package/dist/metrics/llm/hallucination/prompts.d.ts.map +0 -1
  202. package/dist/metrics/llm/index.cjs +0 -2481
  203. package/dist/metrics/llm/index.cjs.map +0 -1
  204. package/dist/metrics/llm/index.d.ts +0 -12
  205. package/dist/metrics/llm/index.d.ts.map +0 -1
  206. package/dist/metrics/llm/index.js +0 -2469
  207. package/dist/metrics/llm/index.js.map +0 -1
  208. package/dist/metrics/llm/prompt-alignment/index.d.ts +0 -33
  209. package/dist/metrics/llm/prompt-alignment/index.d.ts.map +0 -1
  210. package/dist/metrics/llm/prompt-alignment/metricJudge.d.ts +0 -20
  211. package/dist/metrics/llm/prompt-alignment/metricJudge.d.ts.map +0 -1
  212. package/dist/metrics/llm/prompt-alignment/prompts.d.ts +0 -17
  213. package/dist/metrics/llm/prompt-alignment/prompts.d.ts.map +0 -1
  214. package/dist/metrics/llm/summarization/index.d.ts +0 -19
  215. package/dist/metrics/llm/summarization/index.d.ts.map +0 -1
  216. package/dist/metrics/llm/summarization/metricJudge.d.ts +0 -34
  217. package/dist/metrics/llm/summarization/metricJudge.d.ts.map +0 -1
  218. package/dist/metrics/llm/summarization/prompts.d.ts +0 -30
  219. package/dist/metrics/llm/summarization/prompts.d.ts.map +0 -1
  220. package/dist/metrics/llm/toxicity/index.d.ts +0 -14
  221. package/dist/metrics/llm/toxicity/index.d.ts.map +0 -1
  222. package/dist/metrics/llm/toxicity/metricJudge.d.ts +0 -14
  223. package/dist/metrics/llm/toxicity/metricJudge.d.ts.map +0 -1
  224. package/dist/metrics/llm/toxicity/prompts.d.ts +0 -10
  225. package/dist/metrics/llm/toxicity/prompts.d.ts.map +0 -1
  226. package/dist/metrics/llm/types.d.ts +0 -7
  227. package/dist/metrics/llm/types.d.ts.map +0 -1
  228. package/dist/metrics/llm/utils.d.ts +0 -14
  229. package/dist/metrics/llm/utils.d.ts.map +0 -1
  230. package/dist/metrics/nlp/completeness/index.d.ts +0 -21
  231. package/dist/metrics/nlp/completeness/index.d.ts.map +0 -1
  232. package/dist/metrics/nlp/content-similarity/index.d.ts +0 -18
  233. package/dist/metrics/nlp/content-similarity/index.d.ts.map +0 -1
  234. package/dist/metrics/nlp/index.cjs +0 -203
  235. package/dist/metrics/nlp/index.cjs.map +0 -1
  236. package/dist/metrics/nlp/index.d.ts +0 -6
  237. package/dist/metrics/nlp/index.d.ts.map +0 -1
  238. package/dist/metrics/nlp/index.js +0 -190
  239. package/dist/metrics/nlp/index.js.map +0 -1
  240. package/dist/metrics/nlp/keyword-coverage/index.d.ts +0 -13
  241. package/dist/metrics/nlp/keyword-coverage/index.d.ts.map +0 -1
  242. package/dist/metrics/nlp/textual-difference/index.d.ts +0 -15
  243. package/dist/metrics/nlp/textual-difference/index.d.ts.map +0 -1
  244. package/dist/metrics/nlp/tone/index.d.ts +0 -18
  245. package/dist/metrics/nlp/tone/index.d.ts.map +0 -1
  246. package/dist/scorers/code/index.cjs +0 -329
  247. package/dist/scorers/code/index.cjs.map +0 -1
  248. package/dist/scorers/code/index.js +0 -315
  249. package/dist/scorers/code/index.js.map +0 -1
  250. package/dist/scorers/llm/index.cjs +0 -2588
  251. package/dist/scorers/llm/index.cjs.map +0 -1
  252. package/dist/scorers/llm/index.js +0 -2572
  253. package/dist/scorers/llm/index.js.map +0 -1
@@ -0,0 +1,66 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Built-in scorers
4
+
5
+ Mastra provides a complete set of built-in scorers for evaluating AI outputs. These scorers are optimized for common evaluation scenarios and are ready to use in your agents and workflows.
6
+
7
+ To create your own scorers, see the [Custom Scorers](https://mastra.ai/docs/evals/custom-scorers) guide.
8
+
9
+ ## Available scorers
10
+
11
+ ### Accuracy and reliability
12
+
13
+ These scorers evaluate how correct, truthful, and complete your agent's answers are:
14
+
15
+ - [`answer-relevancy`](https://mastra.ai/reference/evals/answer-relevancy): Evaluates how well responses address the input query (`0-1`, higher is better)
16
+ - [`answer-similarity`](https://mastra.ai/reference/evals/answer-similarity): Compares agent outputs against ground-truth answers for CI/CD testing using semantic analysis (`0-1`, higher is better)
17
+ - [`faithfulness`](https://mastra.ai/reference/evals/faithfulness): Measures how accurately responses represent provided context (`0-1`, higher is better)
18
+ - [`hallucination`](https://mastra.ai/reference/evals/hallucination): Detects factual contradictions and unsupported claims (`0-1`, lower is better)
19
+ - [`completeness`](https://mastra.ai/reference/evals/completeness): Checks if responses include all necessary information (`0-1`, higher is better)
20
+ - [`content-similarity`](https://mastra.ai/reference/evals/content-similarity): Measures textual similarity using character-level matching (`0-1`, higher is better)
21
+ - [`textual-difference`](https://mastra.ai/reference/evals/textual-difference): Measures textual differences between strings (`0-1`, higher means more similar)
22
+ - [`tool-call-accuracy`](https://mastra.ai/reference/evals/tool-call-accuracy): Evaluates whether the LLM selects the correct tool from available options (`0-1`, higher is better)
23
+ - [`trajectory-accuracy`](https://mastra.ai/reference/evals/trajectory-accuracy): Evaluates the expected action sequence for all span types. Covered spans include tool and model activity plus workflow steps (`0-1`, higher is better)
24
+ - [`prompt-alignment`](https://mastra.ai/reference/evals/prompt-alignment): Measures how well agent responses align with user prompt intent, requirements, completeness, and format (`0-1`, higher is better)
25
+
26
+ ### Context quality
27
+
28
+ These scorers evaluate the quality and relevance of context used in generating responses:
29
+
30
+ - [`context-precision`](https://mastra.ai/reference/evals/context-precision): Uses Mean Average Precision to evaluate context ranking. Relevant context receives a higher score when it occurs early (`0-1`, higher is better)
31
+ - [`context-relevance`](https://mastra.ai/reference/evals/context-relevance): Measures context utility through relevance levels and usage tracking. It also detects missing context (`0-1`, higher is better)
32
+
33
+ > **Context Scorer Selection:**
34
+ >
35
+ > - Use **Context Precision** when context ordering matters and you need standard IR metrics (ideal for RAG ranking evaluation)
36
+ > - Use **Context Relevance** when you need detailed relevance assessment and want to track context usage and identify gaps
37
+ >
38
+ > Both context scorers support:
39
+ >
40
+ > - **Static context**: Pre-defined context arrays
41
+ > - **Dynamic context extraction**: Extract context from runs using custom functions (ideal for RAG systems, vector databases, etc.)
42
+
43
+ ### Output quality
44
+
45
+ These scorers evaluate adherence to format, style, and safety requirements:
46
+
47
+ - [`tone-consistency`](https://mastra.ai/reference/evals/tone-consistency): Measures consistency in formality, complexity, and style (`0-1`, higher is better)
48
+ - [`toxicity`](https://mastra.ai/reference/evals/toxicity): Detects harmful or inappropriate content (`0-1`, lower is better)
49
+ - [`bias`](https://mastra.ai/reference/evals/bias): Detects potential biases in the output (`0-1`, lower is better)
50
+ - [`keyword-coverage`](https://mastra.ai/reference/evals/keyword-coverage): Assesses technical terminology usage (`0-1`, higher is better)
51
+
52
+ ### Quick Checks
53
+
54
+ Zero-LLM micro-scorers for fast, deterministic assertions. See the [Quick Checks](https://mastra.ai/docs/evals/quick-checks) guide for usage details.
55
+
56
+ - [`checks.includes`](https://mastra.ai/reference/evals/checks): Scores 1 if output contains a substring (`0` or `1`)
57
+ - [`checks.excludes`](https://mastra.ai/reference/evals/checks): Scores 1 if output doesn't contain a substring (`0` or `1`)
58
+ - [`checks.equals`](https://mastra.ai/reference/evals/checks): Scores 1 if output exactly matches a string (`0` or `1`)
59
+ - [`checks.matches`](https://mastra.ai/reference/evals/checks): Scores 1 if output matches a regex (`0` or `1`)
60
+ - [`checks.similarity`](https://mastra.ai/reference/evals/checks): String similarity via Dice coefficient (`0-1`, or binary with threshold)
61
+ - [`checks.calledTool`](https://mastra.ai/reference/evals/checks): Scores 1 if a tool was called at least N times (`0` or `1`)
62
+ - [`checks.didNotCall`](https://mastra.ai/reference/evals/checks): Scores 1 if a tool wasn't called (`0` or `1`)
63
+ - [`checks.toolOrder`](https://mastra.ai/reference/evals/checks): Scores 1 if tools were called in order (`0` or `1`)
64
+ - [`checks.maxToolCalls`](https://mastra.ai/reference/evals/checks): Scores 1 if tool call count is within limit (`0` or `1`)
65
+ - [`checks.usedNoTools`](https://mastra.ai/reference/evals/checks): Scores 1 if no tools were called (`0` or `1`)
66
+ - [`checks.noToolErrors`](https://mastra.ai/reference/evals/checks): Scores 1 if no tool calls had errors (`0` or `1`)
@@ -0,0 +1,163 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Scorers overview
4
+
5
+ While traditional software tests have clear pass/fail conditions, AI outputs are non-deterministic, they can vary with the same input. **Scorers** help bridge this gap by providing quantifiable metrics for measuring agent quality.
6
+
7
+ Scorers are automated tests that evaluate Agents outputs using model-graded, rule-based, and statistical methods. Scorers return **scores**: numerical values (typically between 0 and 1) that quantify how well an output meets your evaluation criteria. These scores enable you to objectively track performance, compare different approaches, and identify areas for improvement in your AI systems. Scorers can be customized with your own prompts and scoring functions.
8
+
9
+ Scorers can be run in the cloud, capturing real-time results. But scorers can also be part of your CI/CD pipeline, allowing you to test and monitor your agents over time.
10
+
11
+ > **📹 Watch:** Watch [Mastra evals overview](https://www.youtube.com/watch?v=12WN6u2DrBk) for an introduction to evals and how to reason about agent quality.
12
+
13
+ ## Types of scorers
14
+
15
+ Mastra provides different kinds of scorers, each serving a specific purpose. Here are some common types:
16
+
17
+ 1. **Textual Scorers**: Evaluate accuracy, reliability, and context understanding of agent responses
18
+ 2. **Classification Scorers**: Measure accuracy in categorizing data based on predefined categories
19
+ 3. **Prompt Engineering Scorers**: Explore impact of different instructions and input formats
20
+
21
+ ## Installation
22
+
23
+ To access Mastra's scorers feature install the `@mastra/evals` package.
24
+
25
+ **npm**:
26
+
27
+ ```bash
28
+ npm install @mastra/evals@latest
29
+ ```
30
+
31
+ **pnpm**:
32
+
33
+ ```bash
34
+ pnpm add @mastra/evals@latest
35
+ ```
36
+
37
+ **Yarn**:
38
+
39
+ ```bash
40
+ yarn add @mastra/evals@latest
41
+ ```
42
+
43
+ **Bun**:
44
+
45
+ ```bash
46
+ bun add @mastra/evals@latest
47
+ ```
48
+
49
+ ## Live evaluations
50
+
51
+ **Live evaluations** allow you to automatically score AI outputs in real-time as your agents and workflows operate. Instead of running evaluations manually or in batches, scorers run asynchronously alongside your AI systems, providing continuous quality monitoring.
52
+
53
+ ### Adding scorers to agents
54
+
55
+ You can add built-in scorers to your agents to automatically evaluate their outputs. See the [full list of built-in scorers](https://mastra.ai/docs/evals/built-in-scorers) for all available options.
56
+
57
+ ```typescript
58
+ import { Agent } from '@mastra/core/agent'
59
+ import { createAnswerRelevancyScorer, createToxicityScorer } from '@mastra/evals/scorers/prebuilt'
60
+
61
+ export const evaluatedAgent = new Agent({
62
+ id: 'evaluated-agent',
63
+ scorers: {
64
+ relevancy: {
65
+ scorer: createAnswerRelevancyScorer({ model: 'openai/gpt-5-mini' }),
66
+ sampling: { type: 'ratio', rate: 0.5 },
67
+ },
68
+ safety: {
69
+ scorer: createToxicityScorer({ model: 'openai/gpt-5-mini' }),
70
+ sampling: { type: 'ratio', rate: 1 },
71
+ },
72
+ },
73
+ })
74
+ ```
75
+
76
+ ### Adding scorers to workflow steps
77
+
78
+ You can also add scorers to individual workflow steps to evaluate outputs at specific points in your process. Each scorer receives that step's own input and output, so you can measure quality at each step instead of only scoring the final answer:
79
+
80
+ ```typescript
81
+ import { createWorkflow, createStep } from "@mastra/core/workflows";
82
+ import { z } from "zod";
83
+ import { customStepScorer } from "../scorers/custom-step-scorer";
84
+
85
+ const contentStep = createStep({
86
+ id: "content-step",
87
+ inputSchema: z.object({ topic: z.string() }),
88
+ outputSchema: z.object({ content: z.string() }),
89
+ scorers: {
90
+ customStepScorer: {
91
+ scorer: customStepScorer(),
92
+ sampling: {
93
+ type: "ratio",
94
+ rate: 1, // Score every step execution
95
+ },
96
+ },
97
+ },
98
+ execute: async ({ inputData }) => {
99
+ return { content: await generateContent(inputData.topic) };
100
+ },
101
+ });
102
+
103
+ export const contentWorkflow = createWorkflow({
104
+ id: "content-workflow",
105
+ inputSchema: z.object({ topic: z.string() }),
106
+ outputSchema: z.object({ content: z.string() }),
107
+ })
108
+ .then(contentStep)
109
+ .commit();
110
+ ```
111
+
112
+ For the step-level `scorers` API, see the [Step class reference](https://mastra.ai/reference/workflows/step).
113
+
114
+ ### How live evaluations work
115
+
116
+ **Asynchronous execution**: Live evaluations run in the background without blocking your agent responses or workflow execution. This ensures your AI systems maintain their performance while still being monitored.
117
+
118
+ **Sampling control**: The `sampling.rate` parameter (0-1) controls what percentage of outputs get scored:
119
+
120
+ - `1.0`: Score every single response (100%)
121
+ - `0.5`: Score half of all responses (50%)
122
+ - `0.1`: Score 10% of responses
123
+ - `0.0`: Disable scoring
124
+
125
+ **Automatic storage**: All scoring results are automatically stored in the `mastra_scorers` table in your configured database, allowing you to analyze performance trends over time.
126
+
127
+ ## Trace evaluations
128
+
129
+ In addition to live evaluations, you can use scorers to evaluate historical traces from your agent interactions and workflows.
130
+
131
+ This is particularly useful for analyzing past performance or debugging issues, or alternatively running batch evaluations.
132
+
133
+ > **Observability required:** To score traces, you must first configure observability in your Mastra instance to collect trace data. See [Tracing documentation](https://mastra.ai/docs/observability/tracing/overview) for setup instructions.
134
+
135
+ ## Studio
136
+
137
+ To score traces, you first need to register your scorers with your Mastra instance:
138
+
139
+ ```typescript
140
+ const mastra = new Mastra({
141
+ scorers: {
142
+ answerRelevancy: myAnswerRelevancyScorer,
143
+ responseQuality: myResponseQualityScorer,
144
+ },
145
+ })
146
+ ```
147
+
148
+ Once registered, you can score traces interactively within Studio under the **Observability** section. Open Studio to manage scorers and review scores, plus run experiments.
149
+
150
+ - **Scorers list**: Browse all registered scorers with their description, and the number of agents and workflows each scorer is attached to.
151
+ - **Score results**: Select a scorer to see a paginated list of every score it has produced. Click a row to open the detail panel, which shows the score value, reason, input, output, and the prompts used by the judge. From this panel, save any result as a dataset item for future experiments.
152
+ - **Agent Evaluate tab**: Open the Evaluate tab on any agent to manage scorers and datasets. You can also run experiments there. Experiment results display per-item scores alongside pass/fail status and version tags.
153
+ - **Trace scoring**: In the Observability section, run a scorer against any historical trace or span to evaluate past interactions. Filter scores by agent or workflow.
154
+
155
+ ## Next steps
156
+
157
+ - Use [Quick Checks](https://mastra.ai/docs/evals/quick-checks) for fast, deterministic assertions on text and tool usage
158
+ - Add [gates and verdicts](https://mastra.ai/docs/evals/gates-and-verdicts) to enforce hard requirements and quality thresholds
159
+ - Test [multi-turn conversations](https://mastra.ai/docs/evals/multi-turn) where behavior emerges across sequential turns
160
+ - Learn how to create your own scorers in the [Creating Custom Scorers](https://mastra.ai/docs/evals/custom-scorers) guide
161
+ - Explore built-in scorers in the [Built-in Scorers](https://mastra.ai/docs/evals/built-in-scorers) section
162
+ - Test scorers with [Studio](https://mastra.ai/docs/studio/overview)
163
+ - 📹 [Mastra evals workshop](https://www.youtube.com/watch?v=OHOZ5PgPj5M\&t=3578s)
@@ -0,0 +1,137 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Quick Checks
4
+
5
+ Quick Checks are composable micro-scorers for common assertions like "output contains X" or "agent called tool Y." They require no LLM, run instantly, and plug into the same `scorers: [...]` array as any other scorer.
6
+
7
+ ## When to use Quick Checks
8
+
9
+ Use Quick Checks when you need fast, deterministic assertions:
10
+
11
+ - Verify output text contains or excludes specific strings
12
+ - Confirm an agent called (or avoided) specific tools
13
+ - Validate tool call ordering and count limits
14
+ - Gate CI pipelines with zero-cost binary checks
15
+ - Combine with LLM-based scorers for layered evaluation
16
+
17
+ For subjective or semantic evaluation, use [LLM-based scorers](https://mastra.ai/docs/evals/built-in-scorers) instead.
18
+
19
+ ## Quickstart
20
+
21
+ ```typescript
22
+ import { checks } from '@mastra/evals/checks'
23
+ import { runEvals } from '@mastra/core/evals'
24
+ import { weatherAgent } from '../agents'
25
+
26
+ const result = await runEvals({
27
+ data: [{ input: 'What is the weather in Brooklyn?' }],
28
+ target: weatherAgent,
29
+ scorers: [checks.includes('Brooklyn'), checks.calledTool('get_weather'), checks.noToolErrors()],
30
+ })
31
+
32
+ console.log(result.scores)
33
+ // { 'check-includes': 1, 'check-called-tool': 1, 'check-no-tool-errors': 1 }
34
+ ```
35
+
36
+ ## Available checks
37
+
38
+ Quick Checks fall into these categories:
39
+
40
+ ### Text checks
41
+
42
+ These scorers evaluate the agent's text output:
43
+
44
+ | Check | What it does | Score |
45
+ | ------------------------ | ------------------------------------- | -------------------------------- |
46
+ | `checks.includes(str)` | Output contains substring | 1 or 0 |
47
+ | `checks.excludes(str)` | Output doesn't contain substring | 1 or 0 |
48
+ | `checks.equals(str)` | Output exactly equals string | 1 or 0 |
49
+ | `checks.matches(regex)` | Output matches regular expression | 1 or 0 |
50
+ | `checks.similarity(str)` | Dice coefficient similarity to string | 0-1 (or binary with `threshold`) |
51
+
52
+ ### Tool call checks
53
+
54
+ These scorers evaluate tool usage from the agent's run:
55
+
56
+ | Check | What it does | Score |
57
+ | ------------------------- | -------------------------------- | ------ |
58
+ | `checks.calledTool(name)` | Tool was called at least N times | 1 or 0 |
59
+ | `checks.didNotCall(name)` | Tool wasn't called | 1 or 0 |
60
+ | `checks.toolOrder([...])` | Tools called in expected order | 1 or 0 |
61
+ | `checks.maxToolCalls(n)` | No more than N tool calls total | 1 or 0 |
62
+ | `checks.usedNoTools()` | No tools called at all | 1 or 0 |
63
+ | `checks.noToolErrors()` | No tool invocations had errors | 1 or 0 |
64
+
65
+ ## Combining checks with LLM scorers
66
+
67
+ Checks compose with LLM-based scorers in a single `runEvals` call. Use checks for deterministic gates and LLM scorers for qualitative evaluation:
68
+
69
+ ```typescript
70
+ import { checks } from '@mastra/evals/checks'
71
+ import { createFaithfulnessScorer } from '@mastra/evals/scorers/prebuilt'
72
+ import { runEvals } from '@mastra/core/evals'
73
+ import { myAgent } from '../agents'
74
+
75
+ const result = await runEvals({
76
+ data: [
77
+ {
78
+ input: 'What is the weather in Brooklyn?',
79
+ context: ['Brooklyn weather data: sunny, 72°F'],
80
+ },
81
+ ],
82
+ target: myAgent,
83
+ scorers: [
84
+ // Deterministic checks (instant, free)
85
+ checks.includes('Brooklyn'),
86
+ checks.calledTool('get_weather'),
87
+ checks.excludes('error'),
88
+ checks.noToolErrors(),
89
+
90
+ // LLM-based scorer (semantic, costs tokens)
91
+ createFaithfulnessScorer({ model: 'openai/gpt-5-mini' }),
92
+ ],
93
+ })
94
+ ```
95
+
96
+ ## Using checks in live scoring
97
+
98
+ Attach checks to agents for continuous monitoring:
99
+
100
+ ```typescript
101
+ import { Agent } from '@mastra/core/agent'
102
+ import { checks } from '@mastra/evals/checks'
103
+
104
+ export const weatherAgent = new Agent({
105
+ id: 'weather-agent',
106
+ name: 'Weather Agent',
107
+ instructions: 'Answer weather questions using the get_weather tool.',
108
+ model: 'openai/gpt-5.6-sol',
109
+ tools: { get_weather: weatherTool },
110
+ scorers: {
111
+ noErrors: {
112
+ scorer: checks.noToolErrors(),
113
+ sampling: { type: 'ratio', rate: 1 },
114
+ },
115
+ mentionCity: {
116
+ scorer: checks.includes('Brooklyn'),
117
+ sampling: { type: 'ratio', rate: 0.5 },
118
+ },
119
+ },
120
+ })
121
+ ```
122
+
123
+ ## How checks work
124
+
125
+ Each check is a standard `createScorer()` instance with a `preprocess` step and a `generateScore` step. They follow the same [four-step pipeline](https://mastra.ai/docs/evals/custom-scorers) as any other scorer:
126
+
127
+ 1. **preprocess**: Extracts and normalizes relevant data from the agent run (text content, tool calls)
128
+ 2. **generateScore**: Converts the preprocessed result into a score (typically binary 1 or 0)
129
+
130
+ Because checks skip the `analyze` and `generateReason` steps and make no LLM calls, they run in microseconds. Visit the [Quick Checks reference](https://mastra.ai/reference/evals/checks) for the full API, including all parameters and options for each check.
131
+
132
+ ## Related
133
+
134
+ - [Quick Checks reference](https://mastra.ai/reference/evals/checks)
135
+ - [Built-in Scorers](https://mastra.ai/docs/evals/built-in-scorers)
136
+ - [Custom Scorers](https://mastra.ai/docs/evals/custom-scorers)
137
+ - [`runEvals()` reference](https://mastra.ai/reference/evals/run-evals)
@@ -0,0 +1,107 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Answer relevancy scorer
4
+
5
+ The `createAnswerRelevancyScorer()` function accepts a single options object with the following properties:
6
+
7
+ ## Parameters
8
+
9
+ **model** (`LanguageModel`): Configuration for the model used to evaluate relevancy.
10
+
11
+ **uncertaintyWeight** (`number`): Weight given to 'unsure' verdicts in scoring (0-1). (Default: `0.3`)
12
+
13
+ **scale** (`number`): Maximum score value. (Default: `1`)
14
+
15
+ This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer)), but the return value includes LLM-specific fields as documented below.
16
+
17
+ ## `.run()` returns
18
+
19
+ **runId** (`string`): The id of the run (optional).
20
+
21
+ **score** (`number`): Relevancy score (0 to scale, default 0-1)
22
+
23
+ **preprocessPrompt** (`string`): The prompt sent to the LLM for the preprocess step (optional).
24
+
25
+ **preprocessStepResult** (`object`): Object with extracted statements: { statements: string\[] }
26
+
27
+ **analyzePrompt** (`string`): The prompt sent to the LLM for the analyze step (optional).
28
+
29
+ **analyzeStepResult** (`object`): Object with results: { results: Array<{ result: 'yes' | 'unsure' | 'no', reason: string }> }
30
+
31
+ **generateReasonPrompt** (`string`): The prompt sent to the LLM for the reason step (optional).
32
+
33
+ **reason** (`string`): Explanation of the score.
34
+
35
+ ## Scoring details
36
+
37
+ The scorer evaluates relevancy through query-answer alignment, considering completeness and detail level, but not factual correctness.
38
+
39
+ ### Scoring Process
40
+
41
+ 1. **Statement Preprocess:**
42
+ - Breaks output into useful statements while preserving context.
43
+
44
+ 2. **Relevance Analysis:**
45
+
46
+ - Each statement is evaluated as:
47
+
48
+ - "yes": Full weight for direct matches
49
+ - "unsure": Partial weight (default: 0.3) for approximate matches
50
+ - "no": Zero weight for irrelevant content
51
+
52
+ 3. **Score Calculation:**
53
+ - `((direct + uncertainty * partial) / total_statements) * scale`
54
+
55
+ ### Score Interpretation
56
+
57
+ A relevancy score between 0 and 1:
58
+
59
+ - **1.0**: The response fully answers the query with relevant and focused information.
60
+ - **0.7 to 0.9**: The response mostly answers the query but may include minor unrelated content.
61
+ - **0.4 to 0.6**: The response partially answers the query, mixing relevant and unrelated information.
62
+ - **0.1 to 0.3**: The response includes minimal relevant content and largely misses the intent of the query.
63
+ - **0.0**: The response is entirely unrelated and doesn't answer the query.
64
+
65
+ ## Example
66
+
67
+ Evaluate agent responses for relevancy across different scenarios:
68
+
69
+ ```typescript
70
+ import { runEvals } from '@mastra/core/evals'
71
+ import { createAnswerRelevancyScorer } from '@mastra/evals/scorers/prebuilt'
72
+ import { myAgent } from './agent'
73
+
74
+ const scorer = createAnswerRelevancyScorer({ model: 'openai/gpt-5.6-sol' })
75
+
76
+ const result = await runEvals({
77
+ data: [
78
+ {
79
+ input: 'What are the health benefits of regular exercise?',
80
+ },
81
+ {
82
+ input: 'What should a healthy breakfast include?',
83
+ },
84
+ {
85
+ input: 'What are the benefits of meditation?',
86
+ },
87
+ ],
88
+ scorers: [scorer],
89
+ target: myAgent,
90
+ onItemComplete: ({ scorerResults }) => {
91
+ console.log({
92
+ score: scorerResults[scorer.id].score,
93
+ reason: scorerResults[scorer.id].reason,
94
+ })
95
+ },
96
+ })
97
+
98
+ console.log(result.scores)
99
+ ```
100
+
101
+ For more details on `runEvals`, see the [runEvals reference](https://mastra.ai/reference/evals/run-evals).
102
+
103
+ To add this scorer to an agent, see the [Scorers overview](https://mastra.ai/docs/evals/overview) guide.
104
+
105
+ ## Related
106
+
107
+ - [Faithfulness Scorer](https://mastra.ai/reference/evals/faithfulness)
@@ -0,0 +1,99 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Answer similarity scorer
4
+
5
+ The `createAnswerSimilarityScorer()` function creates a scorer that evaluates how similar an agent's output is to a ground truth answer. This scorer is specifically designed for CI/CD testing scenarios where you have expected answers and want to ensure consistency over time.
6
+
7
+ ## Parameters
8
+
9
+ **model** (`LanguageModel`): The language model used to evaluate semantic similarity between outputs and ground truth.
10
+
11
+ **options** (`AnswerSimilarityOptions`): Configuration options for the scorer.
12
+
13
+ **options.requireGroundTruth** (`boolean`): Whether to require ground truth for evaluation. If false, missing ground truth returns score 0.
14
+
15
+ **options.semanticThreshold** (`number`): Weight for semantic matches vs exact matches (0-1).
16
+
17
+ **options.exactMatchBonus** (`number`): Additional score bonus for exact matches (0-1).
18
+
19
+ **options.missingPenalty** (`number`): Penalty per missing key concept from ground truth.
20
+
21
+ **options.contradictionPenalty** (`number`): Penalty for contradictory information. High value ensures wrong answers score near 0.
22
+
23
+ **options.extraInfoPenalty** (`number`): Mild penalty for extra information not present in ground truth (capped at 0.2).
24
+
25
+ **options.scale** (`number`): Score scaling factor.
26
+
27
+ This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer)), but **requires ground truth** to be provided in the run object.
28
+
29
+ ## `.run()` returns
30
+
31
+ **runId** (`string`): The id of the run (optional).
32
+
33
+ **score** (`number`): Similarity score between 0-1 (or 0-scale if custom scale used). Higher scores indicate better similarity to ground truth.
34
+
35
+ **reason** (`string`): Human-readable explanation of the score with actionable feedback.
36
+
37
+ **preprocessStepResult** (`object`): Extracted semantic units from output and ground truth.
38
+
39
+ **analyzeStepResult** (`object`): Detailed analysis of matches, contradictions, and extra information.
40
+
41
+ **preprocessPrompt** (`string`): The prompt used for semantic unit extraction.
42
+
43
+ **analyzePrompt** (`string`): The prompt used for similarity analysis.
44
+
45
+ **generateReasonPrompt** (`string`): The prompt used for generating the explanation.
46
+
47
+ ## Scoring details
48
+
49
+ The scorer uses a multi-step process:
50
+
51
+ 1. **Extract**: Breaks down output and ground truth into semantic units
52
+ 2. **Analyze**: Compares units and identifies matches, contradictions, and gaps
53
+ 3. **Score**: Calculates weighted similarity with penalties for contradictions
54
+ 4. **Reason**: Generates human-readable explanation
55
+
56
+ Score calculation: `max(0, base_score - contradiction_penalty - missing_penalty - extra_info_penalty) × scale`
57
+
58
+ ## Example
59
+
60
+ Evaluate agent responses for similarity to ground truth across different scenarios:
61
+
62
+ ```typescript
63
+ import { runEvals } from '@mastra/core/evals'
64
+ import { createAnswerSimilarityScorer } from '@mastra/evals/scorers/prebuilt'
65
+ import { myAgent } from './agent'
66
+
67
+ const scorer = createAnswerSimilarityScorer({ model: 'openai/gpt-5.6-sol' })
68
+
69
+ const result = await runEvals({
70
+ data: [
71
+ {
72
+ input: 'What is 2+2?',
73
+ groundTruth: '4',
74
+ },
75
+ {
76
+ input: 'What is the capital of France?',
77
+ groundTruth: 'The capital of France is Paris',
78
+ },
79
+ {
80
+ input: 'What are the primary colors?',
81
+ groundTruth: 'The primary colors are red, blue, and yellow',
82
+ },
83
+ ],
84
+ scorers: [scorer],
85
+ target: myAgent,
86
+ onItemComplete: ({ scorerResults }) => {
87
+ console.log({
88
+ score: scorerResults[scorer.id].score,
89
+ reason: scorerResults[scorer.id].reason,
90
+ })
91
+ },
92
+ })
93
+
94
+ console.log(result.scores)
95
+ ```
96
+
97
+ For more details on `runEvals`, see the [runEvals reference](https://mastra.ai/reference/evals/run-evals).
98
+
99
+ To add this scorer to an agent, see the [Scorers overview](https://mastra.ai/docs/evals/overview) guide.