@mastra/evals 1.6.0 → 1.7.0

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 (62) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/checks-64AonnEK.js +379 -0
  3. package/dist/checks-64AonnEK.js.map +1 -0
  4. package/dist/checks-DGTgg-nW.cjs +479 -0
  5. package/dist/checks-DGTgg-nW.cjs.map +1 -0
  6. package/dist/checks.cjs +14 -56
  7. package/dist/checks.js +2 -3
  8. package/dist/docs/SKILL.md +2 -1
  9. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  10. package/dist/docs/references/docs-evals-built-in-scorers.md +4 -4
  11. package/dist/docs/references/docs-evals-overview.md +6 -4
  12. package/dist/docs/references/docs-evals-quick-checks.md +2 -2
  13. package/dist/docs/references/reference-evals-answer-relevancy.md +5 -5
  14. package/dist/docs/references/reference-evals-answer-similarity.md +1 -1
  15. package/dist/docs/references/reference-evals-bias.md +4 -4
  16. package/dist/docs/references/reference-evals-checks.md +3 -3
  17. package/dist/docs/references/reference-evals-completeness.md +5 -5
  18. package/dist/docs/references/reference-evals-content-similarity.md +5 -5
  19. package/dist/docs/references/reference-evals-context-precision.md +5 -5
  20. package/dist/docs/references/reference-evals-context-recall.md +11 -11
  21. package/dist/docs/references/reference-evals-context-relevance.md +15 -15
  22. package/dist/docs/references/reference-evals-faithfulness.md +4 -4
  23. package/dist/docs/references/reference-evals-hallucination.md +11 -11
  24. package/dist/docs/references/reference-evals-keyword-coverage.md +6 -6
  25. package/dist/docs/references/reference-evals-noise-sensitivity.md +15 -15
  26. package/dist/docs/references/reference-evals-prompt-alignment.md +20 -20
  27. package/dist/docs/references/reference-evals-rubric.md +2 -2
  28. package/dist/docs/references/reference-evals-scorer-utils.md +4 -4
  29. package/dist/docs/references/reference-evals-summarization.md +203 -0
  30. package/dist/docs/references/reference-evals-textual-difference.md +4 -4
  31. package/dist/docs/references/reference-evals-tool-call-accuracy.md +4 -4
  32. package/dist/docs/references/reference-evals-toxicity.md +5 -5
  33. package/dist/docs/references/reference-evals-trajectory-accuracy.md +10 -10
  34. package/dist/index.cjs +12 -2
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.js +13 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/scorers/llm/index.d.ts +1 -0
  39. package/dist/scorers/llm/index.d.ts.map +1 -1
  40. package/dist/scorers/llm/summarization/index.d.ts +55 -0
  41. package/dist/scorers/llm/summarization/index.d.ts.map +1 -0
  42. package/dist/scorers/llm/summarization/prompts.d.ts +48 -0
  43. package/dist/scorers/llm/summarization/prompts.d.ts.map +1 -0
  44. package/dist/scorers/prebuilt/index.cjs +2753 -2848
  45. package/dist/scorers/prebuilt/index.cjs.map +1 -1
  46. package/dist/scorers/prebuilt/index.js +2735 -2791
  47. package/dist/scorers/prebuilt/index.js.map +1 -1
  48. package/dist/scorers/utils.cjs +966 -101
  49. package/dist/scorers/utils.cjs.map +1 -1
  50. package/dist/scorers/utils.js +939 -2
  51. package/dist/scorers/utils.js.map +1 -1
  52. package/package.json +11 -10
  53. package/dist/checks.cjs.map +0 -1
  54. package/dist/checks.js.map +0 -1
  55. package/dist/chunk-GGHVFNVI.cjs +0 -233
  56. package/dist/chunk-GGHVFNVI.cjs.map +0 -1
  57. package/dist/chunk-IZLA36WC.cjs +0 -654
  58. package/dist/chunk-IZLA36WC.cjs.map +0 -1
  59. package/dist/chunk-UJ4WCQ3F.js +0 -626
  60. package/dist/chunk-UJ4WCQ3F.js.map +0 -1
  61. package/dist/chunk-WEADJCUA.js +0 -216
  62. package/dist/chunk-WEADJCUA.js.map +0 -1
@@ -0,0 +1,479 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ const require_scorers_utils = require("./scorers/utils.cjs");
24
+ let _mastra_core_evals = require("@mastra/core/evals");
25
+ let string_similarity = require("string-similarity");
26
+ string_similarity = __toESM(string_similarity, 1);
27
+ //#region src/scorers/code/checks/index.ts
28
+ /**
29
+ * Scores 1 if the agent's output text contains the expected substring, 0 otherwise.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { checks } from '@mastra/evals';
34
+ * const scorer = checks.includes('sunny');
35
+ * ```
36
+ */
37
+ function includes(expected, options = {}) {
38
+ const { ignoreCase = true } = options;
39
+ return (0, _mastra_core_evals.createScorer)({
40
+ id: "check-includes",
41
+ name: "Includes Check",
42
+ description: `Checks if output includes "${expected}"`,
43
+ type: "agent"
44
+ }).preprocess(async ({ run }) => {
45
+ let output = run.output.filter((m) => m.role === "assistant").map((m) => require_scorers_utils.getTextContentFromMastraDBMessage(m)).join(" ");
46
+ let target = expected;
47
+ if (ignoreCase) {
48
+ output = output.toLowerCase();
49
+ target = target.toLowerCase();
50
+ }
51
+ return {
52
+ output,
53
+ target,
54
+ found: output.includes(target)
55
+ };
56
+ }).generateScore(({ results }) => {
57
+ return results.preprocessStepResult?.found ? 1 : 0;
58
+ });
59
+ }
60
+ /**
61
+ * Scores 1 if the agent's output text does NOT contain the substring, 0 otherwise.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { checks } from '@mastra/evals';
66
+ * const scorer = checks.excludes('error');
67
+ * ```
68
+ */
69
+ function excludes(unwanted, options = {}) {
70
+ const { ignoreCase = true } = options;
71
+ return (0, _mastra_core_evals.createScorer)({
72
+ id: "check-excludes",
73
+ name: "Excludes Check",
74
+ description: `Checks that output does not include "${unwanted}"`,
75
+ type: "agent"
76
+ }).preprocess(async ({ run }) => {
77
+ let output = run.output.filter((m) => m.role === "assistant").map((m) => require_scorers_utils.getTextContentFromMastraDBMessage(m)).join(" ");
78
+ let target = unwanted;
79
+ if (ignoreCase) {
80
+ output = output.toLowerCase();
81
+ target = target.toLowerCase();
82
+ }
83
+ return {
84
+ output,
85
+ target,
86
+ excluded: !output.includes(target)
87
+ };
88
+ }).generateScore(({ results }) => {
89
+ return results.preprocessStepResult?.excluded ? 1 : 0;
90
+ });
91
+ }
92
+ /**
93
+ * Scores 1 if the output text exactly equals the expected string (after optional normalization).
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { checks } from '@mastra/evals';
98
+ * const scorer = checks.equals('Hello, world!');
99
+ * ```
100
+ */
101
+ function equals(expected, options = {}) {
102
+ const { ignoreCase = true } = options;
103
+ return (0, _mastra_core_evals.createScorer)({
104
+ id: "check-equals",
105
+ name: "Equals Check",
106
+ description: `Checks if output equals "${expected}"`,
107
+ type: "agent"
108
+ }).preprocess(async ({ run }) => {
109
+ let output = run.output.filter((m) => m.role === "assistant").map((m) => require_scorers_utils.getTextContentFromMastraDBMessage(m)).join("");
110
+ let target = expected;
111
+ if (ignoreCase) {
112
+ output = output.toLowerCase();
113
+ target = target.toLowerCase();
114
+ }
115
+ return {
116
+ output,
117
+ target,
118
+ isEqual: output === target
119
+ };
120
+ }).generateScore(({ results }) => {
121
+ return results.preprocessStepResult?.isEqual ? 1 : 0;
122
+ });
123
+ }
124
+ /**
125
+ * Scores 1 if the output matches the given regular expression, 0 otherwise.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * import { checks } from '@mastra/evals';
130
+ * const scorer = checks.matches(/\d{1,3}°[FC]/);
131
+ * ```
132
+ */
133
+ function matches(pattern, options = {}) {
134
+ const { exact = false } = options;
135
+ return (0, _mastra_core_evals.createScorer)({
136
+ id: "check-matches",
137
+ name: "Matches Check",
138
+ description: `Checks if output matches pattern ${pattern}`,
139
+ type: "agent"
140
+ }).preprocess(async ({ run }) => {
141
+ const output = run.output.filter((m) => m.role === "assistant").map((m) => require_scorers_utils.getTextContentFromMastraDBMessage(m)).join("");
142
+ const matched = (exact ? new RegExp(`^${pattern.source}$`, pattern.flags) : pattern).test(output);
143
+ return {
144
+ output,
145
+ pattern: pattern.toString(),
146
+ matched
147
+ };
148
+ }).generateScore(({ results }) => {
149
+ return results.preprocessStepResult?.matched ? 1 : 0;
150
+ });
151
+ }
152
+ /**
153
+ * Returns the string similarity score (0-1) between the output and an expected string.
154
+ * Useful for fuzzy matching when exact equality is too strict.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * import { checks } from '@mastra/evals';
159
+ * const scorer = checks.similarity('Sunny, 72°F');
160
+ * ```
161
+ */
162
+ function similarity(expected, options = {}) {
163
+ const { ignoreCase = true, threshold } = options;
164
+ return (0, _mastra_core_evals.createScorer)({
165
+ id: "check-similarity",
166
+ name: "Similarity Check",
167
+ description: `Checks string similarity to "${expected}"`,
168
+ type: "agent"
169
+ }).preprocess(async ({ run }) => {
170
+ let output = run.output.filter((m) => m.role === "assistant").map((m) => require_scorers_utils.getTextContentFromMastraDBMessage(m)).join(" ");
171
+ let target = expected;
172
+ if (ignoreCase) {
173
+ output = output.toLowerCase();
174
+ target = target.toLowerCase();
175
+ }
176
+ const score = string_similarity.default.compareTwoStrings(output, target);
177
+ return {
178
+ output,
179
+ target,
180
+ score,
181
+ threshold
182
+ };
183
+ }).generateScore(({ results }) => {
184
+ const score = results.preprocessStepResult?.score ?? 0;
185
+ const t = results.preprocessStepResult?.threshold;
186
+ return t !== void 0 ? score >= t ? 1 : 0 : score;
187
+ });
188
+ }
189
+ /**
190
+ * Scores 1 if the agent called the specified tool (at least `times` times).
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { checks } from '@mastra/evals';
195
+ * const scorer = checks.calledTool('get_weather');
196
+ * const twice = checks.calledTool('search', { times: 2 });
197
+ * ```
198
+ */
199
+ function calledTool(toolName, options = {}) {
200
+ const { times = 1 } = options;
201
+ return (0, _mastra_core_evals.createScorer)({
202
+ id: "check-called-tool",
203
+ name: "Called Tool Check",
204
+ description: `Checks that "${toolName}" was called${times > 1 ? ` at least ${times} times` : ""}`,
205
+ type: "agent"
206
+ }).preprocess(async ({ run }) => {
207
+ const { tools } = require_scorers_utils.extractToolCalls(run.output);
208
+ const count = tools.filter((t) => t === toolName).length;
209
+ return {
210
+ toolName,
211
+ expectedTimes: times,
212
+ actualCount: count,
213
+ passed: count >= times
214
+ };
215
+ }).generateScore(({ results }) => {
216
+ return results.preprocessStepResult?.passed ? 1 : 0;
217
+ });
218
+ }
219
+ /**
220
+ * Scores 1 if the agent did NOT call the specified tool.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * import { checks } from '@mastra/evals';
225
+ * const scorer = checks.didNotCall('delete_user');
226
+ * ```
227
+ */
228
+ function didNotCall(toolName) {
229
+ return (0, _mastra_core_evals.createScorer)({
230
+ id: "check-did-not-call",
231
+ name: "Did Not Call Check",
232
+ description: `Checks that "${toolName}" was NOT called`,
233
+ type: "agent"
234
+ }).preprocess(async ({ run }) => {
235
+ const { tools } = require_scorers_utils.extractToolCalls(run.output);
236
+ const count = tools.filter((t) => t === toolName).length;
237
+ return {
238
+ toolName,
239
+ count,
240
+ passed: count === 0
241
+ };
242
+ }).generateScore(({ results }) => {
243
+ return results.preprocessStepResult?.passed ? 1 : 0;
244
+ });
245
+ }
246
+ /**
247
+ * Scores 1 if the tools were called in the specified order (relaxed: allows other calls in between).
248
+ *
249
+ * @example
250
+ * ```ts
251
+ * import { checks } from '@mastra/evals';
252
+ * const scorer = checks.toolOrder(['search', 'summarize', 'respond']);
253
+ * ```
254
+ */
255
+ function toolOrder(expectedOrder) {
256
+ return (0, _mastra_core_evals.createScorer)({
257
+ id: "check-tool-order",
258
+ name: "Tool Order Check",
259
+ description: `Checks tool call order: [${expectedOrder.join(" → ")}]`,
260
+ type: "agent"
261
+ }).preprocess(async ({ run }) => {
262
+ const { tools } = require_scorers_utils.extractToolCalls(run.output);
263
+ let orderIndex = 0;
264
+ for (const tool of tools) if (orderIndex < expectedOrder.length && tool === expectedOrder[orderIndex]) orderIndex++;
265
+ return {
266
+ actualTools: tools,
267
+ expectedOrder,
268
+ passed: orderIndex === expectedOrder.length
269
+ };
270
+ }).generateScore(({ results }) => {
271
+ return results.preprocessStepResult?.passed ? 1 : 0;
272
+ });
273
+ }
274
+ /**
275
+ * Scores 1 if the agent used no more than `max` tool calls.
276
+ *
277
+ * @example
278
+ * ```ts
279
+ * import { checks } from '@mastra/evals';
280
+ * const scorer = checks.maxToolCalls(5);
281
+ * ```
282
+ */
283
+ function maxToolCalls(max) {
284
+ return (0, _mastra_core_evals.createScorer)({
285
+ id: "check-max-tool-calls",
286
+ name: "Max Tool Calls Check",
287
+ description: `Checks that no more than ${max} tool calls were made`,
288
+ type: "agent"
289
+ }).preprocess(async ({ run }) => {
290
+ const { tools } = require_scorers_utils.extractToolCalls(run.output);
291
+ return {
292
+ count: tools.length,
293
+ max,
294
+ passed: tools.length <= max
295
+ };
296
+ }).generateScore(({ results }) => {
297
+ return results.preprocessStepResult?.passed ? 1 : 0;
298
+ });
299
+ }
300
+ /**
301
+ * Scores 1 if the agent made no tool calls at all.
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * import { checks } from '@mastra/evals';
306
+ * const scorer = checks.usedNoTools();
307
+ * ```
308
+ */
309
+ function usedNoTools() {
310
+ return (0, _mastra_core_evals.createScorer)({
311
+ id: "check-used-no-tools",
312
+ name: "Used No Tools Check",
313
+ description: "Checks that no tools were called",
314
+ type: "agent"
315
+ }).preprocess(async ({ run }) => {
316
+ const { tools } = require_scorers_utils.extractToolCalls(run.output);
317
+ return {
318
+ count: tools.length,
319
+ passed: tools.length === 0
320
+ };
321
+ }).generateScore(({ results }) => {
322
+ return results.preprocessStepResult?.passed ? 1 : 0;
323
+ });
324
+ }
325
+ /**
326
+ * Scores 1 if none of the tool invocations resulted in an error state.
327
+ * Checks for tool invocations with state other than 'result' (i.e., missing results).
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * import { checks } from '@mastra/evals';
332
+ * const scorer = checks.noToolErrors();
333
+ * ```
334
+ */
335
+ function noToolErrors() {
336
+ return (0, _mastra_core_evals.createScorer)({
337
+ id: "check-no-tool-errors",
338
+ name: "No Tool Errors Check",
339
+ description: "Checks that no tool calls resulted in errors",
340
+ type: "agent"
341
+ }).preprocess(async ({ run }) => {
342
+ const invocations = extractRawInvocations(run.output);
343
+ const errorCount = invocations.filter((inv) => inv.state === "call" || inv.result && inv.result.error).length;
344
+ return {
345
+ errorCount,
346
+ totalCalls: invocations.length,
347
+ passed: errorCount === 0
348
+ };
349
+ }).generateScore(({ results }) => {
350
+ return results.preprocessStepResult?.passed ? 1 : 0;
351
+ });
352
+ }
353
+ function extractRawInvocations(output) {
354
+ const invocations = [];
355
+ for (const message of output) {
356
+ const legacy = message?.content?.toolInvocations;
357
+ const fromParts = legacy ? void 0 : (message?.content)?.parts?.filter((p) => p.type === "tool-invocation").map((p) => p.toolInvocation);
358
+ for (const inv of legacy ?? fromParts ?? []) if (inv) invocations.push(inv);
359
+ }
360
+ return invocations;
361
+ }
362
+ /**
363
+ * Quick Checks — composable micro-scorers for common assertions.
364
+ *
365
+ * These are zero-LLM, zero-ceremony scorers that plug into the existing
366
+ * `scorers: [...]` array anywhere scorers are used. Internally they are
367
+ * standard `createScorer()` instances with the same observability, storage,
368
+ * and pipeline integration as any other scorer.
369
+ *
370
+ * @example
371
+ * ```ts
372
+ * import { checks } from '@mastra/evals';
373
+ *
374
+ * await runEvals({
375
+ * data: [...],
376
+ * target: myAgent,
377
+ * scorers: [
378
+ * checks.includes('sunny'),
379
+ * checks.calledTool('get_weather'),
380
+ * checks.toolOrder(['search', 'summarize']),
381
+ * checks.noToolErrors(),
382
+ * ],
383
+ * });
384
+ * ```
385
+ */
386
+ const checks = {
387
+ includes,
388
+ excludes,
389
+ equals,
390
+ matches,
391
+ similarity,
392
+ calledTool,
393
+ didNotCall,
394
+ toolOrder,
395
+ maxToolCalls,
396
+ usedNoTools,
397
+ noToolErrors
398
+ };
399
+ //#endregion
400
+ Object.defineProperty(exports, "__toESM", {
401
+ enumerable: true,
402
+ get: function() {
403
+ return __toESM;
404
+ }
405
+ });
406
+ Object.defineProperty(exports, "calledTool", {
407
+ enumerable: true,
408
+ get: function() {
409
+ return calledTool;
410
+ }
411
+ });
412
+ Object.defineProperty(exports, "checks", {
413
+ enumerable: true,
414
+ get: function() {
415
+ return checks;
416
+ }
417
+ });
418
+ Object.defineProperty(exports, "didNotCall", {
419
+ enumerable: true,
420
+ get: function() {
421
+ return didNotCall;
422
+ }
423
+ });
424
+ Object.defineProperty(exports, "equals", {
425
+ enumerable: true,
426
+ get: function() {
427
+ return equals;
428
+ }
429
+ });
430
+ Object.defineProperty(exports, "excludes", {
431
+ enumerable: true,
432
+ get: function() {
433
+ return excludes;
434
+ }
435
+ });
436
+ Object.defineProperty(exports, "includes", {
437
+ enumerable: true,
438
+ get: function() {
439
+ return includes;
440
+ }
441
+ });
442
+ Object.defineProperty(exports, "matches", {
443
+ enumerable: true,
444
+ get: function() {
445
+ return matches;
446
+ }
447
+ });
448
+ Object.defineProperty(exports, "maxToolCalls", {
449
+ enumerable: true,
450
+ get: function() {
451
+ return maxToolCalls;
452
+ }
453
+ });
454
+ Object.defineProperty(exports, "noToolErrors", {
455
+ enumerable: true,
456
+ get: function() {
457
+ return noToolErrors;
458
+ }
459
+ });
460
+ Object.defineProperty(exports, "similarity", {
461
+ enumerable: true,
462
+ get: function() {
463
+ return similarity;
464
+ }
465
+ });
466
+ Object.defineProperty(exports, "toolOrder", {
467
+ enumerable: true,
468
+ get: function() {
469
+ return toolOrder;
470
+ }
471
+ });
472
+ Object.defineProperty(exports, "usedNoTools", {
473
+ enumerable: true,
474
+ get: function() {
475
+ return usedNoTools;
476
+ }
477
+ });
478
+
479
+ //# sourceMappingURL=checks-DGTgg-nW.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks-DGTgg-nW.cjs","names":["getTextContentFromMastraDBMessage","stringSimilarity","extractToolCalls"],"sources":["../src/scorers/code/checks/index.ts"],"sourcesContent":["import { createScorer } from '@mastra/core/evals';\nimport stringSimilarity from 'string-similarity';\nimport { extractToolCalls, getTextContentFromMastraDBMessage } from '../../utils';\n\n// ─── Output Text Checks ───────────────────────────────────────────────────────\n\nexport interface IncludesOptions {\n /** Case-insensitive match (default: true) */\n ignoreCase?: boolean;\n}\n\n/**\n * Scores 1 if the agent's output text contains the expected substring, 0 otherwise.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.includes('sunny');\n * ```\n */\nexport function includes(expected: string, options: IncludesOptions = {}) {\n const { ignoreCase = true } = options;\n return createScorer({\n id: 'check-includes',\n name: 'Includes Check',\n description: `Checks if output includes \"${expected}\"`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n let output = run.output\n .filter(m => m.role === 'assistant')\n .map(m => getTextContentFromMastraDBMessage(m))\n .join(' ');\n let target = expected;\n if (ignoreCase) {\n output = output.toLowerCase();\n target = target.toLowerCase();\n }\n return { output, target, found: output.includes(target) };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.found ? 1 : 0;\n });\n}\n\n/**\n * Scores 1 if the agent's output text does NOT contain the substring, 0 otherwise.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.excludes('error');\n * ```\n */\nexport function excludes(unwanted: string, options: IncludesOptions = {}) {\n const { ignoreCase = true } = options;\n return createScorer({\n id: 'check-excludes',\n name: 'Excludes Check',\n description: `Checks that output does not include \"${unwanted}\"`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n let output = run.output\n .filter(m => m.role === 'assistant')\n .map(m => getTextContentFromMastraDBMessage(m))\n .join(' ');\n let target = unwanted;\n if (ignoreCase) {\n output = output.toLowerCase();\n target = target.toLowerCase();\n }\n return { output, target, excluded: !output.includes(target) };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.excluded ? 1 : 0;\n });\n}\n\n/**\n * Scores 1 if the output text exactly equals the expected string (after optional normalization).\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.equals('Hello, world!');\n * ```\n */\nexport function equals(expected: string, options: IncludesOptions = {}) {\n const { ignoreCase = true } = options;\n return createScorer({\n id: 'check-equals',\n name: 'Equals Check',\n description: `Checks if output equals \"${expected}\"`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n let output = run.output\n .filter(m => m.role === 'assistant')\n .map(m => getTextContentFromMastraDBMessage(m))\n .join('');\n let target = expected;\n if (ignoreCase) {\n output = output.toLowerCase();\n target = target.toLowerCase();\n }\n return { output, target, isEqual: output === target };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.isEqual ? 1 : 0;\n });\n}\n\nexport interface MatchesOptions {\n /** If true, the output must match the pattern exactly (anchored). Default: false (substring match). */\n exact?: boolean;\n}\n\n/**\n * Scores 1 if the output matches the given regular expression, 0 otherwise.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.matches(/\\d{1,3}°[FC]/);\n * ```\n */\nexport function matches(pattern: RegExp, options: MatchesOptions = {}) {\n const { exact = false } = options;\n return createScorer({\n id: 'check-matches',\n name: 'Matches Check',\n description: `Checks if output matches pattern ${pattern}`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const output = run.output\n .filter(m => m.role === 'assistant')\n .map(m => getTextContentFromMastraDBMessage(m))\n .join('');\n const regex = exact ? new RegExp(`^${pattern.source}$`, pattern.flags) : pattern;\n const matched = regex.test(output);\n return { output, pattern: pattern.toString(), matched };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.matched ? 1 : 0;\n });\n}\n\nexport interface SimilarityOptions {\n /** Minimum similarity threshold (0-1) to score 1. Default: 0.7 */\n threshold?: number;\n /** Case-insensitive comparison (default: true) */\n ignoreCase?: boolean;\n}\n\n/**\n * Returns the string similarity score (0-1) between the output and an expected string.\n * Useful for fuzzy matching when exact equality is too strict.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.similarity('Sunny, 72°F');\n * ```\n */\nexport function similarity(expected: string, options: SimilarityOptions = {}) {\n const { ignoreCase = true, threshold } = options;\n return createScorer({\n id: 'check-similarity',\n name: 'Similarity Check',\n description: `Checks string similarity to \"${expected}\"`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n let output = run.output\n .filter(m => m.role === 'assistant')\n .map(m => getTextContentFromMastraDBMessage(m))\n .join(' ');\n let target = expected;\n if (ignoreCase) {\n output = output.toLowerCase();\n target = target.toLowerCase();\n }\n const score = stringSimilarity.compareTwoStrings(output, target);\n return { output, target, score, threshold };\n })\n .generateScore(({ results }) => {\n const score = results.preprocessStepResult?.score ?? 0;\n const t = results.preprocessStepResult?.threshold;\n return t !== undefined ? (score >= t ? 1 : 0) : score;\n });\n}\n\n// ─── Tool Call Checks ─────────────────────────────────────────────────────────\n\nexport interface CalledToolOptions {\n /** Minimum number of times the tool must be called. Default: 1 */\n times?: number;\n}\n\n/**\n * Scores 1 if the agent called the specified tool (at least `times` times).\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.calledTool('get_weather');\n * const twice = checks.calledTool('search', { times: 2 });\n * ```\n */\nexport function calledTool(toolName: string, options: CalledToolOptions = {}) {\n const { times = 1 } = options;\n return createScorer({\n id: 'check-called-tool',\n name: 'Called Tool Check',\n description: `Checks that \"${toolName}\" was called${times > 1 ? ` at least ${times} times` : ''}`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const { tools } = extractToolCalls(run.output);\n const count = tools.filter(t => t === toolName).length;\n return { toolName, expectedTimes: times, actualCount: count, passed: count >= times };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.passed ? 1 : 0;\n });\n}\n\n/**\n * Scores 1 if the agent did NOT call the specified tool.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.didNotCall('delete_user');\n * ```\n */\nexport function didNotCall(toolName: string) {\n return createScorer({\n id: 'check-did-not-call',\n name: 'Did Not Call Check',\n description: `Checks that \"${toolName}\" was NOT called`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const { tools } = extractToolCalls(run.output);\n const count = tools.filter(t => t === toolName).length;\n return { toolName, count, passed: count === 0 };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.passed ? 1 : 0;\n });\n}\n\n/**\n * Scores 1 if the tools were called in the specified order (relaxed: allows other calls in between).\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.toolOrder(['search', 'summarize', 'respond']);\n * ```\n */\nexport function toolOrder(expectedOrder: string[]) {\n return createScorer({\n id: 'check-tool-order',\n name: 'Tool Order Check',\n description: `Checks tool call order: [${expectedOrder.join(' → ')}]`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const { tools } = extractToolCalls(run.output);\n // Check that expectedOrder appears as a subsequence of tools\n let orderIndex = 0;\n for (const tool of tools) {\n if (orderIndex < expectedOrder.length && tool === expectedOrder[orderIndex]) {\n orderIndex++;\n }\n }\n const passed = orderIndex === expectedOrder.length;\n return { actualTools: tools, expectedOrder, passed };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.passed ? 1 : 0;\n });\n}\n\n/**\n * Scores 1 if the agent used no more than `max` tool calls.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.maxToolCalls(5);\n * ```\n */\nexport function maxToolCalls(max: number) {\n return createScorer({\n id: 'check-max-tool-calls',\n name: 'Max Tool Calls Check',\n description: `Checks that no more than ${max} tool calls were made`,\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const { tools } = extractToolCalls(run.output);\n return { count: tools.length, max, passed: tools.length <= max };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.passed ? 1 : 0;\n });\n}\n\n/**\n * Scores 1 if the agent made no tool calls at all.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.usedNoTools();\n * ```\n */\nexport function usedNoTools() {\n return createScorer({\n id: 'check-used-no-tools',\n name: 'Used No Tools Check',\n description: 'Checks that no tools were called',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const { tools } = extractToolCalls(run.output);\n return { count: tools.length, passed: tools.length === 0 };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.passed ? 1 : 0;\n });\n}\n\n/**\n * Scores 1 if none of the tool invocations resulted in an error state.\n * Checks for tool invocations with state other than 'result' (i.e., missing results).\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n * const scorer = checks.noToolErrors();\n * ```\n */\nexport function noToolErrors() {\n return createScorer({\n id: 'check-no-tool-errors',\n name: 'No Tool Errors Check',\n description: 'Checks that no tool calls resulted in errors',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const invocations = extractRawInvocations(run.output);\n const errorCount = invocations.filter(inv => inv.state === 'call' || (inv.result && inv.result.error)).length;\n return { errorCount, totalCalls: invocations.length, passed: errorCount === 0 };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.passed ? 1 : 0;\n });\n}\n\n// ─── Internal helpers ──────────────────────────────────────────────────────────\n\nfunction extractRawInvocations(output: Parameters<typeof extractToolCalls>[0]) {\n const invocations: any[] = [];\n for (const message of output) {\n const legacy = message?.content?.toolInvocations;\n const fromParts = legacy\n ? undefined\n : (message?.content as any)?.parts\n ?.filter((p: any) => p.type === 'tool-invocation')\n .map((p: any) => p.toolInvocation);\n for (const inv of legacy ?? fromParts ?? []) {\n if (inv) invocations.push(inv);\n }\n }\n return invocations;\n}\n\n// ─── Convenience namespace ────────────────────────────────────────────────────\n\n/**\n * Quick Checks — composable micro-scorers for common assertions.\n *\n * These are zero-LLM, zero-ceremony scorers that plug into the existing\n * `scorers: [...]` array anywhere scorers are used. Internally they are\n * standard `createScorer()` instances with the same observability, storage,\n * and pipeline integration as any other scorer.\n *\n * @example\n * ```ts\n * import { checks } from '@mastra/evals';\n *\n * await runEvals({\n * data: [...],\n * target: myAgent,\n * scorers: [\n * checks.includes('sunny'),\n * checks.calledTool('get_weather'),\n * checks.toolOrder(['search', 'summarize']),\n * checks.noToolErrors(),\n * ],\n * });\n * ```\n */\nexport const checks = {\n includes,\n excludes,\n equals,\n matches,\n similarity,\n calledTool,\n didNotCall,\n toolOrder,\n maxToolCalls,\n usedNoTools,\n noToolErrors,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,SAAS,UAAkB,UAA2B,CAAC,GAAG;CACxE,MAAM,EAAE,aAAa,SAAS;CAC9B,QAAA,GAAA,mBAAA,aAAA,CAAoB;EAClB,IAAI;EACJ,MAAM;EACN,aAAa,8BAA8B,SAAS;EACpD,MAAM;CACR,CAAC,CAAC,CACC,WAAW,OAAO,EAAE,UAAU;EAC7B,IAAI,SAAS,IAAI,OACd,QAAO,MAAK,EAAE,SAAS,WAAW,CAAC,CACnC,KAAI,MAAKA,sBAAAA,kCAAkC,CAAC,CAAC,CAAC,CAC9C,KAAK,GAAG;EACX,IAAI,SAAS;EACb,IAAI,YAAY;GACd,SAAS,OAAO,YAAY;GAC5B,SAAS,OAAO,YAAY;EAC9B;EACA,OAAO;GAAE;GAAQ;GAAQ,OAAO,OAAO,SAAS,MAAM;EAAE;CAC1D,CAAC,CAAC,CACD,eAAe,EAAE,cAAc;EAC9B,OAAO,QAAQ,sBAAsB,QAAQ,IAAI;CACnD,CAAC;AACL;;;;;;;;;;AAWA,SAAgB,S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;;AAYA,SAAgB,eAAe;CAC7B,QAAA,GAAA,mBAAA,aAAA,CAAoB;EAClB,IAAI;EACJ,MAAM;EACN,aAAa;EACb,MAAM;CACR,CAAC,CAAC,CACC,WAAW,OAAO,EAAE,UAAU;EAC7B,MAAM,cAAc,sBAAsB,IAAI,MAAM;EACpD,MAAM,aAAa,YAAY,QAAO,QAAO,IAAI,UAAU,UAAW,IAAI,UAAU,IAAI,OAAO,KAAM,CAAC,CAAC;EACvG,OAAO;GAAE;GAAY,YAAY,YAAY;GAAQ,QAAQ,eAAe;EAAE;CAChF,CAAC,CAAC,CACD,eAAe,EAAE,cAAc;EAC9B,OAAO,QAAQ,sBAAsB,SAAS,IAAI;CACpD,CAAC;AACL;AAIA,SAAS,sBAAsB,QAAgD;CAC7E,MAAM,cAAqB,CAAC;CAC5B,KAAK,MAAM,WAAW,QAAQ;EAC5B,MAAM,SAAS,SAAS,SAAS;EACjC,MAAM,YAAY,SACd,KAAA,KACC,SAAS,QAAA,EAAiB,OACvB,QAAQ,MAAW,EAAE,SAAS,iBAAiB,CAAC,CACjD,KAAK,MAAW,EAAE,cAAc;EACvC,KAAK,MAAM,OAAO,UAAU,aAAa,CAAC,GACxC,IAAI,KAAK,YAAY,KAAK,GAAG;CAEjC;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,SAAS;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
package/dist/checks.cjs CHANGED
@@ -1,56 +1,14 @@
1
- 'use strict';
2
-
3
- var chunkGGHVFNVI_cjs = require('./chunk-GGHVFNVI.cjs');
4
-
5
-
6
-
7
- Object.defineProperty(exports, "calledTool", {
8
- enumerable: true,
9
- get: function () { return chunkGGHVFNVI_cjs.calledTool; }
10
- });
11
- Object.defineProperty(exports, "checks", {
12
- enumerable: true,
13
- get: function () { return chunkGGHVFNVI_cjs.checks; }
14
- });
15
- Object.defineProperty(exports, "didNotCall", {
16
- enumerable: true,
17
- get: function () { return chunkGGHVFNVI_cjs.didNotCall; }
18
- });
19
- Object.defineProperty(exports, "equals", {
20
- enumerable: true,
21
- get: function () { return chunkGGHVFNVI_cjs.equals; }
22
- });
23
- Object.defineProperty(exports, "excludes", {
24
- enumerable: true,
25
- get: function () { return chunkGGHVFNVI_cjs.excludes; }
26
- });
27
- Object.defineProperty(exports, "includes", {
28
- enumerable: true,
29
- get: function () { return chunkGGHVFNVI_cjs.includes; }
30
- });
31
- Object.defineProperty(exports, "matches", {
32
- enumerable: true,
33
- get: function () { return chunkGGHVFNVI_cjs.matches; }
34
- });
35
- Object.defineProperty(exports, "maxToolCalls", {
36
- enumerable: true,
37
- get: function () { return chunkGGHVFNVI_cjs.maxToolCalls; }
38
- });
39
- Object.defineProperty(exports, "noToolErrors", {
40
- enumerable: true,
41
- get: function () { return chunkGGHVFNVI_cjs.noToolErrors; }
42
- });
43
- Object.defineProperty(exports, "similarity", {
44
- enumerable: true,
45
- get: function () { return chunkGGHVFNVI_cjs.similarity; }
46
- });
47
- Object.defineProperty(exports, "toolOrder", {
48
- enumerable: true,
49
- get: function () { return chunkGGHVFNVI_cjs.toolOrder; }
50
- });
51
- Object.defineProperty(exports, "usedNoTools", {
52
- enumerable: true,
53
- get: function () { return chunkGGHVFNVI_cjs.usedNoTools; }
54
- });
55
- //# sourceMappingURL=checks.cjs.map
56
- //# sourceMappingURL=checks.cjs.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_checks = require("./checks-DGTgg-nW.cjs");
3
+ exports.calledTool = require_checks.calledTool;
4
+ exports.checks = require_checks.checks;
5
+ exports.didNotCall = require_checks.didNotCall;
6
+ exports.equals = require_checks.equals;
7
+ exports.excludes = require_checks.excludes;
8
+ exports.includes = require_checks.includes;
9
+ exports.matches = require_checks.matches;
10
+ exports.maxToolCalls = require_checks.maxToolCalls;
11
+ exports.noToolErrors = require_checks.noToolErrors;
12
+ exports.similarity = require_checks.similarity;
13
+ exports.toolOrder = require_checks.toolOrder;
14
+ exports.usedNoTools = require_checks.usedNoTools;
package/dist/checks.js CHANGED
@@ -1,3 +1,2 @@
1
- export { calledTool, checks, didNotCall, equals, excludes, includes, matches, maxToolCalls, noToolErrors, similarity, toolOrder, usedNoTools } from './chunk-WEADJCUA.js';
2
- //# sourceMappingURL=checks.js.map
3
- //# sourceMappingURL=checks.js.map
1
+ import { a as excludes, c as maxToolCalls, d as toolOrder, f as usedNoTools, i as equals, l as noToolErrors, n as checks, o as includes, r as didNotCall, s as matches, t as calledTool, u as similarity } from "./checks-64AonnEK.js";
2
+ export { calledTool, checks, didNotCall, equals, excludes, includes, matches, maxToolCalls, noToolErrors, similarity, toolOrder, usedNoTools };
@@ -3,7 +3,7 @@ name: mastra-evals
3
3
  description: Documentation for @mastra/evals. Use when working with @mastra/evals APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/evals"
6
- version: "1.6.0"
6
+ version: "1.7.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -38,6 +38,7 @@ Read the individual reference documents for detailed explanations and code examp
38
38
  - [Reference: Prompt alignment scorer](references/reference-evals-prompt-alignment.md) - Documentation for the Prompt Alignment Scorer in Mastra. Evaluates how well agent responses align with user prompt intent, requirements, completeness, and appropriateness using multi-dimensional analysis.
39
39
  - [Reference: Rubric scorer](references/reference-evals-rubric.md) - Documentation for the Rubric Scorer in Mastra. An LLM-as-judge scorer that grades an agent output against a checklist of criteria and returns a binary verdict with per-criterion feedback, designed to drive isTaskComplete loops.
40
40
  - [Reference: Scorer utils](references/reference-evals-scorer-utils.md) - Utility functions for extracting data from scorer run inputs and outputs, including text content, reasoning, system messages, and tool calls.
41
+ - [Reference: Summarization scorer](references/reference-evals-summarization.md) - Documentation for the Summarization Scorer in Mastra. Evaluates whether a summary stays faithful to its source text and preserves the information the source states.
41
42
  - [Reference: Textual difference scorer](references/reference-evals-textual-difference.md) - Documentation for the Textual Difference Scorer in Mastra, which measures textual differences between strings using sequence matching.
42
43
  - [Reference: Tone consistency scorer](references/reference-evals-tone-consistency.md) - Documentation for the Tone Consistency Scorer in Mastra, which evaluates emotional tone and sentiment consistency in text.
43
44
  - [Reference: Tool call accuracy scorers](references/reference-evals-tool-call-accuracy.md) - Documentation for the Tool Call Accuracy Scorers in Mastra, which evaluate whether LLM outputs call the correct tools from available options.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.0",
2
+ "version": "1.7.0",
3
3
  "package": "@mastra/evals",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Built-in scorers
4
4
 
5
- Mastra provides a comprehensive 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.
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
6
 
7
7
  To create your own scorers, see the [Custom Scorers](https://mastra.ai/docs/evals/custom-scorers) guide.
8
8
 
@@ -20,15 +20,15 @@ These scorers evaluate how correct, truthful, and complete your agent's answers
20
20
  - [`content-similarity`](https://mastra.ai/reference/evals/content-similarity): Measures textual similarity using character-level matching (`0-1`, higher is better)
21
21
  - [`textual-difference`](https://mastra.ai/reference/evals/textual-difference): Measures textual differences between strings (`0-1`, higher means more similar)
22
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 whether an agent follows the expected sequence of actions (tool calls, model generations, workflow steps, and other span types) (`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
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
25
 
26
26
  ### Context quality
27
27
 
28
28
  These scorers evaluate the quality and relevance of context used in generating responses:
29
29
 
30
- - [`context-precision`](https://mastra.ai/reference/evals/context-precision): Evaluates context relevance and ranking using Mean Average Precision, rewarding early placement of relevant context (`0-1`, higher is better)
31
- - [`context-relevance`](https://mastra.ai/reference/evals/context-relevance): Measures context utility with nuanced relevance levels, usage tracking, and missing context detection (`0-1`, higher is better)
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
32
 
33
33
  > **Context Scorer Selection:**
34
34
  >