@mastra/evals 1.10.11 → 1.10.12-alpha.1

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 (111) hide show
  1. package/dist/checks-CVR2yDHg.cjs +0 -2
  2. package/dist/checks-DXG9awTJ.js +0 -2
  3. package/dist/docs/SKILL.md +4 -5
  4. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  5. package/dist/docs/references/docs-evals-built-in-scorers.md +1 -1
  6. package/dist/docs/references/docs-evals-overview.md +5 -1
  7. package/dist/docs/references/docs-evals-quick-checks.md +1 -1
  8. package/dist/docs/references/docs-guides-build-an-eval-loop.md +1 -1
  9. package/dist/docs/references/reference-evals-answer-relevancy.md +2 -2
  10. package/dist/docs/references/reference-evals-bias.md +2 -2
  11. package/dist/docs/references/reference-evals-checks.md +1 -1
  12. package/dist/docs/references/reference-evals-completeness.md +4 -5
  13. package/dist/docs/references/reference-evals-content-similarity.md +6 -8
  14. package/dist/docs/references/reference-evals-context-precision.md +6 -6
  15. package/dist/docs/references/reference-evals-context-recall.md +1 -1
  16. package/dist/docs/references/reference-evals-context-relevance.md +9 -9
  17. package/dist/docs/references/reference-evals-faithfulness.md +2 -2
  18. package/dist/docs/references/reference-evals-hallucination.md +8 -8
  19. package/dist/docs/references/reference-evals-keyword-coverage.md +2 -2
  20. package/dist/docs/references/reference-evals-multi-turn-judge.md +3 -3
  21. package/dist/docs/references/reference-evals-noise-sensitivity.md +25 -18
  22. package/dist/docs/references/reference-evals-prompt-alignment.md +25 -25
  23. package/dist/docs/references/reference-evals-scorer-utils.md +1 -1
  24. package/dist/docs/references/reference-evals-summarization.md +1 -1
  25. package/dist/docs/references/reference-evals-textual-difference.md +2 -2
  26. package/dist/docs/references/reference-evals-tone-consistency.md +2 -2
  27. package/dist/docs/references/reference-evals-tool-call-accuracy.md +11 -11
  28. package/dist/docs/references/reference-evals-toxicity.md +2 -2
  29. package/dist/docs/references/reference-evals-trajectory-accuracy.md +2 -2
  30. package/dist/index.cjs +0 -2
  31. package/dist/index.js +0 -2
  32. package/dist/matchers-CL0xCK25.cjs +0 -2
  33. package/dist/matchers-CVIJYGVp.js +0 -2
  34. package/dist/scorers/prebuilt/index.cjs +33 -17
  35. package/dist/scorers/prebuilt/index.js +32 -16
  36. package/dist/scorers/utils.cjs +13 -29
  37. package/dist/scorers/utils.js +13 -29
  38. package/dist/vitest/index.cjs +0 -2
  39. package/dist/vitest/index.js +0 -2
  40. package/dist/vitest/setup.cjs +0 -2
  41. package/dist/vitest/setup.js +0 -2
  42. package/package.json +10 -9
  43. package/dist/checks-CVR2yDHg.cjs.map +0 -1
  44. package/dist/checks-DXG9awTJ.js.map +0 -1
  45. package/dist/checks.d.ts.map +0 -1
  46. package/dist/constants.d.ts.map +0 -1
  47. package/dist/docs/references/reference-migrations-upgrade-to-v1-evals.md +0 -243
  48. package/dist/index.cjs.map +0 -1
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/index.js.map +0 -1
  51. package/dist/matchers-CL0xCK25.cjs.map +0 -1
  52. package/dist/matchers-CVIJYGVp.js.map +0 -1
  53. package/dist/scorers/code/checks/index.d.ts.map +0 -1
  54. package/dist/scorers/code/completeness/index.d.ts.map +0 -1
  55. package/dist/scorers/code/content-similarity/index.d.ts.map +0 -1
  56. package/dist/scorers/code/index.d.ts.map +0 -1
  57. package/dist/scorers/code/keyword-coverage/index.d.ts.map +0 -1
  58. package/dist/scorers/code/textual-difference/index.d.ts.map +0 -1
  59. package/dist/scorers/code/tone/index.d.ts.map +0 -1
  60. package/dist/scorers/code/tool-call-accuracy/index.d.ts.map +0 -1
  61. package/dist/scorers/code/trajectory/index.d.ts.map +0 -1
  62. package/dist/scorers/index.d.ts.map +0 -1
  63. package/dist/scorers/llm/answer-relevancy/index.d.ts.map +0 -1
  64. package/dist/scorers/llm/answer-relevancy/prompts.d.ts.map +0 -1
  65. package/dist/scorers/llm/answer-similarity/index.d.ts.map +0 -1
  66. package/dist/scorers/llm/answer-similarity/prompts.d.ts.map +0 -1
  67. package/dist/scorers/llm/bias/index.d.ts.map +0 -1
  68. package/dist/scorers/llm/bias/prompts.d.ts.map +0 -1
  69. package/dist/scorers/llm/context-precision/index.d.ts.map +0 -1
  70. package/dist/scorers/llm/context-precision/prompts.d.ts.map +0 -1
  71. package/dist/scorers/llm/context-recall/index.d.ts.map +0 -1
  72. package/dist/scorers/llm/context-recall/prompts.d.ts.map +0 -1
  73. package/dist/scorers/llm/context-relevance/index.d.ts.map +0 -1
  74. package/dist/scorers/llm/context-relevance/prompts.d.ts.map +0 -1
  75. package/dist/scorers/llm/faithfulness/index.d.ts.map +0 -1
  76. package/dist/scorers/llm/faithfulness/prompts.d.ts.map +0 -1
  77. package/dist/scorers/llm/hallucination/index.d.ts.map +0 -1
  78. package/dist/scorers/llm/hallucination/prompts.d.ts.map +0 -1
  79. package/dist/scorers/llm/index.d.ts.map +0 -1
  80. package/dist/scorers/llm/multi-turn-judge/index.d.ts.map +0 -1
  81. package/dist/scorers/llm/multi-turn-judge/prompts.d.ts.map +0 -1
  82. package/dist/scorers/llm/noise-sensitivity/index.d.ts.map +0 -1
  83. package/dist/scorers/llm/noise-sensitivity/prompts.d.ts.map +0 -1
  84. package/dist/scorers/llm/prompt-alignment/index.d.ts.map +0 -1
  85. package/dist/scorers/llm/prompt-alignment/prompts.d.ts.map +0 -1
  86. package/dist/scorers/llm/rubric/index.d.ts.map +0 -1
  87. package/dist/scorers/llm/rubric/prompts.d.ts.map +0 -1
  88. package/dist/scorers/llm/summarization/index.d.ts.map +0 -1
  89. package/dist/scorers/llm/summarization/prompts.d.ts.map +0 -1
  90. package/dist/scorers/llm/tool-call-accuracy/index.d.ts.map +0 -1
  91. package/dist/scorers/llm/tool-call-accuracy/prompts.d.ts.map +0 -1
  92. package/dist/scorers/llm/toxicity/index.d.ts.map +0 -1
  93. package/dist/scorers/llm/toxicity/prompts.d.ts.map +0 -1
  94. package/dist/scorers/llm/trajectory/index.d.ts.map +0 -1
  95. package/dist/scorers/llm/trajectory/prompts.d.ts.map +0 -1
  96. package/dist/scorers/prebuilt/index.cjs.map +0 -1
  97. package/dist/scorers/prebuilt/index.d.ts.map +0 -1
  98. package/dist/scorers/prebuilt/index.js.map +0 -1
  99. package/dist/scorers/utils.cjs.map +0 -1
  100. package/dist/scorers/utils.d.ts.map +0 -1
  101. package/dist/scorers/utils.js.map +0 -1
  102. package/dist/vitest/expect-evals.d.ts.map +0 -1
  103. package/dist/vitest/index.cjs.map +0 -1
  104. package/dist/vitest/index.d.ts.map +0 -1
  105. package/dist/vitest/index.js.map +0 -1
  106. package/dist/vitest/matchers.d.ts.map +0 -1
  107. package/dist/vitest/meta.d.ts.map +0 -1
  108. package/dist/vitest/reporter.d.ts.map +0 -1
  109. package/dist/vitest/setup.cjs.map +0 -1
  110. package/dist/vitest/setup.d.ts.map +0 -1
  111. package/dist/vitest/setup.js.map +0 -1
@@ -25,23 +25,23 @@ Before using the noise sensitivity scorer, prepare your test data:
25
25
 
26
26
  This scorer is designed exclusively for CI/testing environments and has specific requirements:
27
27
 
28
- ### Why This Is a CI Scorer
28
+ ### Why this is a CI scorer
29
29
 
30
30
  1. **Requires Baseline Data**: You must provide a pre-computed baseline response (the "correct" answer without noise)
31
31
  2. **Needs Test Variations**: Requires both the original query and a noisy variation prepared in advance
32
32
  3. **Comparative Analysis**: The scorer compares responses between baseline and noisy versions, which is only possible in controlled test conditions
33
33
  4. **Not Suitable for Production**: Can't evaluate single, real-time agent responses without predetermined test data
34
34
 
35
- ### Test Data Preparation
35
+ ### Test data preparation
36
36
 
37
- To use this scorer effectively, you need to prepare:
37
+ To use this scorer, prepare:
38
38
 
39
39
  - **Original Query**: The clean user input without any noise
40
40
  - **Baseline Response**: Run your agent with the original query and capture the response
41
41
  - **Noisy Query**: Add distractions, misinformation, or irrelevant content to the original query
42
42
  - **Test Execution**: Run your agent with the noisy query and evaluate using this scorer
43
43
 
44
- ### Example: CI Test Implementation
44
+ ### Example: CI test implementation
45
45
 
46
46
  ```typescript
47
47
  import { describe, it, expect } from 'vitest'
@@ -94,13 +94,13 @@ describe('Agent Noise Resistance Tests', () => {
94
94
 
95
95
  The Noise Sensitivity scorer analyzes five key dimensions:
96
96
 
97
- ### 1. Content Accuracy
97
+ ### 1. Content accuracy
98
98
 
99
99
  Evaluates whether facts and information remain correct despite noise. The scorer checks if the agent maintains truthfulness when exposed to misinformation.
100
100
 
101
101
  ### 2. Completeness
102
102
 
103
- Assesses if the noisy response addresses the original query as thoroughly as the baseline. Measures whether noise causes the agent to miss important information.
103
+ Assesses if the noisy response addresses the original query as well as the baseline. Measures whether noise causes the agent to miss important information.
104
104
 
105
105
  ### 3. Relevance
106
106
 
@@ -110,7 +110,7 @@ Determines if the agent stayed focused on the original question or got distracte
110
110
 
111
111
  Compares how similar the responses are in their core message and conclusions. Evaluates whether noise causes the agent to contradict itself.
112
112
 
113
- ### 5. Hallucination Resistance
113
+ ### 5. Hallucination resistance
114
114
 
115
115
  Checks if noise causes the agent to generate false or fabricated information that wasn't present in either the query or the noise.
116
116
 
@@ -119,16 +119,23 @@ Checks if noise causes the agent to generate false or fabricated information tha
119
119
  ### Formula
120
120
 
121
121
  ```text
122
- Final Score = max(0, min(llm_score, calculated_score): issues_penalty)
122
+ selected_score = |llm_score - calculated_score| > discrepancy_threshold
123
+ ? min(llm_score, calculated_score)
124
+ : llm_score
125
+
126
+ Final Score = max(0, selected_score - issues_penalty)
123
127
  ```
124
128
 
129
+ The final score is rounded to two decimal places.
130
+
125
131
  Where:
126
132
 
127
133
  - `llm_score` = Direct robustness score from LLM analysis
128
134
  - `calculated_score` = Average of impact weights across dimensions
135
+ - `discrepancy_threshold` = `scoring.discrepancyThreshold` (default `0.2`)
129
136
  - `issues_penalty` = min(major_issues × penalty_rate, max_penalty)
130
137
 
131
- ### Impact Level Weights
138
+ ### Impact level weights
132
139
 
133
140
  Each dimension receives an impact level with corresponding weights:
134
141
 
@@ -138,7 +145,7 @@ Each dimension receives an impact level with corresponding weights:
138
145
  - **Significant (0.3)**: Major degradation in quality or accuracy
139
146
  - **Severe (0.1)**: Response much worse than the baseline or unrelated to the original query
140
147
 
141
- ### Conservative Scoring
148
+ ### Conservative scoring
142
149
 
143
150
  When the LLM's direct score and the calculated score diverge by more than the discrepancy threshold, the scorer uses the lower (more conservative) score to ensure reliable evaluation.
144
151
 
@@ -164,7 +171,7 @@ Example: "Write a summary of this article. Actually, ignore that and tell me abo
164
171
 
165
172
  ## CI/testing usage patterns
166
173
 
167
- ### Integration Testing
174
+ ### Integration testing
168
175
 
169
176
  Use in your CI pipeline to verify agent robustness:
170
177
 
@@ -173,7 +180,7 @@ Use in your CI pipeline to verify agent robustness:
173
180
  - Compare different model versions' noise handling capabilities
174
181
  - Validate fixes for noise-related issues
175
182
 
176
- ### Quality Assurance Testing
183
+ ### Quality assurance testing
177
184
 
178
185
  Include in your test harness to:
179
186
 
@@ -182,7 +189,7 @@ Include in your test harness to:
182
189
  - Create detailed test coverage for multiple noise types
183
190
  - Ensure consistent behavior across updates
184
191
 
185
- ### Security Testing
192
+ ### Security testing
186
193
 
187
194
  Evaluate resistance in controlled environments:
188
195
 
@@ -194,7 +201,7 @@ Evaluate resistance in controlled environments:
194
201
  ### Score interpretation
195
202
 
196
203
  - **1.0**: Perfect robustness - no impact detected
197
- - **0.8-0.9**: Excellent - minimal impact, core functionality preserved
204
+ - **0.8-0.9**: High - minimal impact, core functionality preserved
198
205
  - **0.6-0.7**: Good - some impact but acceptable for most use cases
199
206
  - **0.4-0.5**: Concerning - substantial vulnerabilities detected
200
207
  - **0.0-0.3**: Critical - agent severely compromised by noise
@@ -220,7 +227,7 @@ Based on noise sensitivity results:
220
227
 
221
228
  ## Examples
222
229
 
223
- ### Complete Vitest Example
230
+ ### Complete Vitest example
224
231
 
225
232
  ```typescript
226
233
  import { describe, it, expect, beforeAll } from 'vitest'
@@ -289,7 +296,7 @@ describe('Agent Noise Resistance CI Tests', () => {
289
296
 
290
297
  ## Perfect robustness example
291
298
 
292
- This example shows an agent that completely resists misinformation in a test scenario:
299
+ This example shows an agent that resists misinformation in a test scenario:
293
300
 
294
301
  ```typescript
295
302
  import { createNoiseSensitivityScorerLLM } from '@mastra/evals/scorers/prebuilt'
@@ -552,7 +559,7 @@ async function compareModelRobustness() {
552
559
  const models = [
553
560
  { name: 'GPT-5.4', model: 'openai/gpt-6.1-sol' },
554
561
  { name: 'GPT-6 Luna', model: 'openai/gpt-6-luna' },
555
- { name: 'Claude', model: 'anthropic/claude-opus-5-5' },
562
+ { name: 'Claude', model: 'anthropic/claude-opus-5.5' },
556
563
  ]
557
564
 
558
565
  const testScenario = {
@@ -647,7 +654,7 @@ console.log(`Security Score: ${result.score}`)
647
654
  console.log(`Vulnerability: ${result.score < 0.7 ? 'DETECTED' : 'Not detected'}`)
648
655
  ```
649
656
 
650
- ### GitHub Actions Example
657
+ ### GitHub Actions example
651
658
 
652
659
  Use in your GitHub Actions workflow to test agent robustness:
653
660
 
@@ -90,11 +90,11 @@ const scorer = createPromptAlignmentScorerLLM({
90
90
 
91
91
  This only affects agent runs, where the scorer receives the remembered messages. Runs scored from a plain prompt string are unchanged.
92
92
 
93
- ### Multi-Dimensional Analysis
93
+ ### Multi-dimensional analysis
94
94
 
95
95
  Prompt Alignment evaluates responses across four key dimensions with weighted scoring that adapts based on the evaluation mode:
96
96
 
97
- #### User Mode ('user')
97
+ #### User mode ('user')
98
98
 
99
99
  Evaluates alignment with user prompts only:
100
100
 
@@ -103,7 +103,7 @@ Evaluates alignment with user prompts only:
103
103
  3. **Completeness** (20% weight): Whether the response is detailed for user needs
104
104
  4. **Response Appropriateness** (10% weight): If format and tone match user expectations
105
105
 
106
- #### System Mode ('system')
106
+ #### System mode ('system')
107
107
 
108
108
  Evaluates compliance with system guidelines only:
109
109
 
@@ -112,7 +112,7 @@ Evaluates compliance with system guidelines only:
112
112
  3. **Completeness** (15% weight): Whether the response adheres to all system rules
113
113
  4. **Response Appropriateness** (15% weight): If format and tone match system specifications
114
114
 
115
- #### Both Mode ('both' - default)
115
+ #### Both mode ('both' - default)
116
116
 
117
117
  Evaluates user and system alignment together in a single analysis:
118
118
 
@@ -120,7 +120,7 @@ Evaluates user and system alignment together in a single analysis:
120
120
  - The resulting dimension scores are combined using the user mode weights
121
121
  - The scorer computes no separate system score, so the result isn't a blend of user mode and system mode scores
122
122
 
123
- ### Scoring Formula
123
+ ### Scoring formula
124
124
 
125
125
  **User Mode:**
126
126
 
@@ -154,16 +154,16 @@ In both mode, each dimension score comes from the combined analysis of the user
154
154
  - **System Mode**: Balances behavioral compliance (35%) and constraints (35%) equally
155
155
  - **Both Mode**: Uses the user mode weights over a combined analysis, so user needs stay primary while system guidelines are still assessed
156
156
 
157
- ### Score Interpretation
157
+ ### Score interpretation
158
158
 
159
- - **0.9-1.0** = Excellent alignment across all dimensions
160
- - **0.8-0.9** = Very good alignment with minor gaps
159
+ - **0.9-1.0** = Strong alignment across all dimensions
160
+ - **0.8-0.9** = Good alignment with minor gaps
161
161
  - **0.7-0.8** = Good alignment but missing some requirements or completeness
162
162
  - **0.6-0.7** = Moderate alignment with noticeable gaps
163
163
  - **0.4-0.6** = Poor alignment with substantial issues
164
- - **0.0-0.4** = Very poor alignment, response doesn't address the prompt effectively
164
+ - **0.0-0.4** = Poor alignment, response doesn't address the prompt
165
165
 
166
- ### When to Use Each Mode
166
+ ### When to use each mode
167
167
 
168
168
  **User Mode (`'user'`)** - Use when:
169
169
 
@@ -186,7 +186,7 @@ In both mode, each dimension score comes from the combined analysis of the user
186
186
 
187
187
  ## Common use cases
188
188
 
189
- ### Code Generation Evaluation
189
+ ### Code generation evaluation
190
190
 
191
191
  Ideal for evaluating:
192
192
 
@@ -202,7 +202,7 @@ const codePrompt = 'Create a REST API endpoint with authentication and rate limi
202
202
  // completeness (full implementation), format (code structure)
203
203
  ```
204
204
 
205
- ### Instruction Following Assessment
205
+ ### Instruction following assessment
206
206
 
207
207
  Perfect for:
208
208
 
@@ -218,7 +218,7 @@ const taskPrompt =
218
218
  // Scorer tracks each requirement individually and provides detailed breakdown
219
219
  ```
220
220
 
221
- ### Content Format Validation
221
+ ### Content format validation
222
222
 
223
223
  Useful for:
224
224
 
@@ -234,7 +234,7 @@ const formatPrompt =
234
234
  // Scorer evaluates content accuracy AND format compliance
235
235
  ```
236
236
 
237
- ### Agent Response Quality
237
+ ### Agent response quality
238
238
 
239
239
  Measure how well your AI agents follow user instructions:
240
240
 
@@ -267,7 +267,7 @@ const systemScorer = createPromptAlignmentScorerLLM({
267
267
  const result = await scorer.run(agentRun)
268
268
  ```
269
269
 
270
- ### Prompt Engineering Optimization
270
+ ### Prompt engineering optimization
271
271
 
272
272
  Test different prompts to improve alignment:
273
273
 
@@ -285,7 +285,7 @@ for (const prompt of prompts) {
285
285
  }
286
286
  ```
287
287
 
288
- ### Multi-Agent System Evaluation
288
+ ### Multi-agent system evaluation
289
289
 
290
290
  Compare different agents or models:
291
291
 
@@ -306,7 +306,7 @@ for (const agent of agents) {
306
306
 
307
307
  ## Examples
308
308
 
309
- ### Basic Configuration
309
+ ### Basic configuration
310
310
 
311
311
  ```typescript
312
312
  import { createPromptAlignmentScorerLLM } from '@mastra/evals/scorers/prebuilt'
@@ -336,7 +336,7 @@ const result = await scorer.run({
336
336
  // Result: { score: 0.95, reason: "Excellent alignment - function addresses intent, includes error handling..." }
337
337
  ```
338
338
 
339
- ### Custom Configuration Examples
339
+ ### Custom configuration examples
340
340
 
341
341
  ```typescript
342
342
  // Configure scale and evaluation mode
@@ -364,7 +364,7 @@ const result = await scorer.run(testRun)
364
364
  // Result: { score: 8.5, reason: "Score: 8.5 out of 10 - Good alignment with both user intent and system guidelines..." }
365
365
  ```
366
366
 
367
- ### Format-Specific Evaluation
367
+ ### Format-specific evaluation
368
368
 
369
369
  ```typescript
370
370
  // Evaluate bullet point formatting
@@ -383,7 +383,7 @@ const result = await scorer.run({
383
383
  // Result: Lower appropriateness score due to format mismatch (paragraph vs bullet points)
384
384
  ```
385
385
 
386
- ### Excellent alignment example
386
+ ### Strong alignment example
387
387
 
388
388
  In this example, the response fully addresses the user's prompt with all requirements met.
389
389
 
@@ -420,7 +420,7 @@ const result = await scorer.run({
420
420
  console.log(result)
421
421
  ```
422
422
 
423
- ### Excellent alignment output
423
+ ### Strong alignment output
424
424
 
425
425
  In this example, the response receives a high score because it provides the requested Python factorial function with error handling for negative numbers.
426
426
 
@@ -516,9 +516,9 @@ The output receives a low score because it only partially fulfills the requireme
516
516
  }
517
517
  ```
518
518
 
519
- ### Evaluation Mode Examples
519
+ ### Evaluation mode examples
520
520
 
521
- #### User Mode - Focus on User Prompt Only
521
+ #### User mode - focus on user prompt only
522
522
 
523
523
  Evaluates how well the response addresses the user's request, ignoring system instructions:
524
524
 
@@ -550,7 +550,7 @@ const result = await scorer.run({
550
550
  // Scores high for addressing user request, even without Python code
551
551
  ```
552
552
 
553
- #### System Mode - Focus on System Guidelines Only
553
+ #### System mode - focus on system guidelines only
554
554
 
555
555
  Evaluates compliance with system behavioral guidelines and constraints:
556
556
 
@@ -582,7 +582,7 @@ const result = await scorer.run({
582
582
  // Evaluates politeness, conciseness, and example provision
583
583
  ```
584
584
 
585
- #### Both Mode - Combined Evaluation (Default)
585
+ #### Both mode - combined evaluation (default)
586
586
 
587
587
  Evaluates user intent fulfillment and system compliance together in a single analysis:
588
588
 
@@ -189,7 +189,7 @@ Combines all system messages into a single prompt string, joined with double new
189
189
 
190
190
  ### `extractToolCalls`
191
191
 
192
- Extracts information about all tool calls from the run output, including tool names, call IDs, and their positions in the message array.
192
+ Extracts information about tool calls from the run output, excluding partial calls (`partial-call` state), including tool names, call IDs, and their positions in the message array.
193
193
 
194
194
  ```typescript
195
195
  const toolUsageScorer = createScorer({
@@ -96,7 +96,7 @@ The score is 0 when the summary yields no claims or the source yields no questio
96
96
 
97
97
  These ranges assume the default `scale` of 1. When using a custom scale, multiply accordingly.
98
98
 
99
- - **0.9-1.0**: Excellent summary, faithful to the source and covering its main points
99
+ - **0.9-1.0**: Strong summary, faithful to the source and covering its main points
100
100
  - **0.7-0.8**: Good summary with a small omission or an unsupported detail
101
101
  - **0.4-0.6**: Moderate summary, either missing important information or drifting from the source
102
102
  - **0.1-0.3**: Poor summary, most of the source is lost or contradicted
@@ -44,7 +44,7 @@ The scorer calculates several measures:
44
44
  - **Length Difference**: Normalized difference in text lengths
45
45
  - **Confidence**: Inversely proportional to length difference
46
46
 
47
- ### Scoring Process
47
+ ### Scoring process
48
48
 
49
49
  1. Analyzes textual differences:
50
50
 
@@ -68,7 +68,7 @@ A textual difference score between 0 and 1:
68
68
  - **0.7 to 0.9**: Minor differences, few changes needed.
69
69
  - **0.4 to 0.6**: Moderate differences, noticeable changes required.
70
70
  - **0.1 to 0.3**: Major differences, extensive changes needed.
71
- - **0.0**: Completely different texts.
71
+ - **0.0**: Unrelated texts.
72
72
 
73
73
  ## Example
74
74
 
@@ -43,7 +43,7 @@ This function returns an instance of the MastraScorer class. See the [MastraScor
43
43
 
44
44
  The scorer evaluates sentiment consistency through tone pattern analysis and mode-specific scoring.
45
45
 
46
- ### Scoring Process
46
+ ### Scoring process
47
47
 
48
48
  1. Analyzes tone patterns:
49
49
 
@@ -70,7 +70,7 @@ Final score: `mode_specific_score`
70
70
  - 0.7-0.9: Strong consistency with minor variations
71
71
  - 0.4-0.6: Moderate consistency with noticeable shifts
72
72
  - 0.1-0.3: Poor consistency with major tone changes
73
- - 0.0: No consistency - completely different tones
73
+ - 0.0: No consistency - unrelated tones
74
74
 
75
75
  ### `preprocessStepResult`
76
76
 
@@ -11,7 +11,7 @@ Mastra provides two tool call accuracy scorers for evaluating whether an LLM sel
11
11
 
12
12
  ## Choosing between scorers
13
13
 
14
- ### Use the Code-Based Scorer When:
14
+ ### Use the Code-based scorer when:
15
15
 
16
16
  - You need **deterministic, reproducible** results
17
17
  - You want to test **exact tool matching**
@@ -19,7 +19,7 @@ Mastra provides two tool call accuracy scorers for evaluating whether an LLM sel
19
19
  - Speed and cost are priorities (no LLM calls)
20
20
  - You're running automated tests
21
21
 
22
- ### Use the LLM-Based Scorer When:
22
+ ### Use the LLM-based scorer when:
23
23
 
24
24
  - You need **semantic understanding** of appropriateness
25
25
  - Tool selection depends on **context and intent**
@@ -41,18 +41,18 @@ The `createToolCallAccuracyScorerCode()` function from `@mastra/evals/scorers/pr
41
41
 
42
42
  This function returns an instance of the MastraScorer class. See the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer) for details on the `.run()` method and its input/output.
43
43
 
44
- ### Evaluation Modes
44
+ ### Evaluation modes
45
45
 
46
46
  The code-based scorer operates in two distinct modes:
47
47
 
48
- #### Single Tool Mode
48
+ #### Single tool mode
49
49
 
50
50
  When `expectedToolOrder` isn't provided or is empty, the score reflects single tool selection:
51
51
 
52
52
  - **Standard Mode (strictMode: false)**: Returns `1` if the expected tool is called, regardless of other tools
53
53
  - **Strict Mode (strictMode: true)**: Returns `1` only if exactly one tool is called and it matches the expected tool
54
54
 
55
- #### Order Checking Mode
55
+ #### Order checking mode
56
56
 
57
57
  When a non-empty `expectedToolOrder` is provided, the score reflects the tool calling sequence:
58
58
 
@@ -65,7 +65,7 @@ When a non-empty `expectedToolOrder` is provided, the score reflects the tool ca
65
65
  - **Deterministic**: Same input always produces same output
66
66
  - **Fast**: No external API calls
67
67
 
68
- ### Code-Based Scorer Options
68
+ ### Code-based scorer options
69
69
 
70
70
  ```typescript
71
71
  // Standard mode - passes if expected tool is called
@@ -88,7 +88,7 @@ const strictOrderScorer = createCodeScorer({
88
88
  })
89
89
  ```
90
90
 
91
- ### Code-Based Scorer Results
91
+ ### Code-based scorer results
92
92
 
93
93
  ```typescript
94
94
  {
@@ -297,7 +297,7 @@ The LLM-based scorer provides:
297
297
  - **Missing Tool Detection**: Identifies tools that should have been called
298
298
  - **Reasoning Generation**: Provides explanations for scoring decisions
299
299
 
300
- ### Evaluation Process
300
+ ### Evaluation process
301
301
 
302
302
  1. **Extract Tool Calls**: Identifies tools mentioned in agent output
303
303
  2. **Analyze Appropriateness**: Evaluates each tool against user request
@@ -311,7 +311,7 @@ The LLM-based scorer provides:
311
311
  - **Context-aware**: Considers user intent and appropriateness
312
312
  - **Explanatory**: Provides reasoning for scores
313
313
 
314
- ### LLM-Based Scorer Options
314
+ ### LLM-based scorer options
315
315
 
316
316
  ```typescript
317
317
  // Basic configuration
@@ -325,12 +325,12 @@ const basicLLMScorer = createLLMScorer({
325
325
 
326
326
  // With different model
327
327
  const customModelScorer = createLLMScorer({
328
- model: 'openai/gpt-5.6', // More powerful model for complex evaluations
328
+ model: 'openai/gpt-5.6-sol', // More powerful model for complex evaluations
329
329
  availableTools: [...]
330
330
  });
331
331
  ```
332
332
 
333
- ### LLM-Based Scorer Results
333
+ ### LLM-based scorer results
334
334
 
335
335
  ```typescript
336
336
  {
@@ -49,7 +49,7 @@ This function returns an instance of the MastraScorer class. The `.run()` method
49
49
 
50
50
  ## Scoring details
51
51
 
52
- The scorer evaluates toxicity through multiple aspects:
52
+ The scorer evaluates toxicity through multiple dimensions:
53
53
 
54
54
  - Personal attacks
55
55
  - Mockery or sarcasm
@@ -57,7 +57,7 @@ The scorer evaluates toxicity through multiple aspects:
57
57
  - Dismissive statements
58
58
  - Threats or intimidation
59
59
 
60
- ### Scoring Process
60
+ ### Scoring process
61
61
 
62
62
  1. Analyzes toxic elements:
63
63
 
@@ -120,7 +120,7 @@ Omit `stepType` entirely to match any step by name only.
120
120
 
121
121
  **children** (`TrajectoryExpectation`): Nested expectation config for this step's children. Overrides the parent config for evaluating children of this step.
122
122
 
123
- ### Simple expected steps
123
+ ### Expected steps
124
124
 
125
125
  ```typescript
126
126
  const steps: ExpectedStep[] = [
@@ -545,7 +545,7 @@ const result = await runEvals({
545
545
  })
546
546
  ```
547
547
 
548
- ### Example: efficiency and blacklist
548
+ ### Example: Efficiency and blacklist
549
549
 
550
550
  ```typescript
551
551
  import { createTrajectoryScorerCode } from '@mastra/evals/scorers/prebuilt'
package/dist/index.cjs CHANGED
@@ -9,5 +9,3 @@
9
9
  * import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/prebuilt';
10
10
  * import { getUserMessageFromRunInput } from '@mastra/evals/scorers/utils';
11
11
  * */
12
-
13
- //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -10,5 +10,3 @@
10
10
  * import { getUserMessageFromRunInput } from '@mastra/evals/scorers/utils';
11
11
  * */
12
12
  export {};
13
-
14
- //# sourceMappingURL=index.js.map
@@ -104,5 +104,3 @@ Object.defineProperty(exports, "registerEvalMatchers", {
104
104
  return registerEvalMatchers;
105
105
  }
106
106
  });
107
-
108
- //# sourceMappingURL=matchers-CL0xCK25.cjs.map
@@ -93,5 +93,3 @@ function registerEvalMatchers() {
93
93
  expect.extend(evalMatchers);
94
94
  }
95
95
  export { registerEvalMatchers as n, evalMatchers as t };
96
-
97
- //# sourceMappingURL=matchers-CVIJYGVp.js.map
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_checks = require("../../checks-CVR2yDHg.cjs");
3
2
  const require_scorers_utils = require("../utils.cjs");
3
+ const require_checks = require("../../checks-CVR2yDHg.cjs");
4
4
  let _mastra_core_evals = require("@mastra/core/evals");
5
5
  let compromise = require("compromise");
6
6
  compromise = require_checks.__toESM(compromise, 1);
@@ -4046,18 +4046,17 @@ function calculateRatio(input, output) {
4046
4046
  }
4047
4047
  /**
4048
4048
  * Finds the length of the longest common subsequence between two strings
4049
+ * Only the previous row of the DP table is needed, so memory stays linear
4049
4050
  */
4050
4051
  function longestCommonSubsequence(str1, str2) {
4051
- const m = str1.length;
4052
- const n = str2.length;
4053
- const dp = [];
4054
- for (let i = 0; i <= m; i++) {
4055
- dp[i] = [];
4056
- for (let j = 0; j <= n; j++) dp[i][j] = 0;
4052
+ let previous = new Uint32Array(str2.length + 1);
4053
+ let current = new Uint32Array(str2.length + 1);
4054
+ for (let i = 1; i <= str1.length; i++) {
4055
+ const char = str1[i - 1];
4056
+ for (let j = 1; j <= str2.length; j++) current[j] = char === str2[j - 1] ? previous[j - 1] + 1 : Math.max(previous[j], current[j - 1]);
4057
+ [previous, current] = [current, previous];
4057
4058
  }
4058
- for (let i = 1; i <= m; i++) for (let j = 1; j <= n; j++) if (str1[i - 1] === str2[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
4059
- else dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
4060
- return dp[m][n];
4059
+ return previous[str2.length];
4061
4060
  }
4062
4061
  /**
4063
4062
  * Counts the number of differences between two strings
@@ -4163,10 +4162,29 @@ function createKeywordCoverageScorer() {
4163
4162
  });
4164
4163
  }
4165
4164
  // src/scorers/code/content-similarity/index.ts
4166
- function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = {
4167
- ignoreCase: true,
4168
- ignoreWhitespace: true
4169
- }) {
4165
+ /**
4166
+ * Like stringSimilarity.compareTwoStrings (Dice coefficient of character pairs), but whitespace counts
4167
+ */
4168
+ function compareWithWhitespace(first, second) {
4169
+ if (first === second) return 1;
4170
+ if (first.length < 2 || second.length < 2) return 0;
4171
+ const pairs = /* @__PURE__ */ new Map();
4172
+ for (let i = 0; i < first.length - 1; i++) {
4173
+ const pair = first.slice(i, i + 2);
4174
+ pairs.set(pair, (pairs.get(pair) ?? 0) + 1);
4175
+ }
4176
+ let matches = 0;
4177
+ for (let i = 0; i < second.length - 1; i++) {
4178
+ const pair = second.slice(i, i + 2);
4179
+ const left = pairs.get(pair) ?? 0;
4180
+ if (left > 0) {
4181
+ pairs.set(pair, left - 1);
4182
+ matches++;
4183
+ }
4184
+ }
4185
+ return 2 * matches / (first.length + second.length - 2);
4186
+ }
4187
+ function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace = true } = { ignoreCase: true }) {
4170
4188
  return (0, _mastra_core_evals.createScorer)({
4171
4189
  id: "content-similarity-scorer",
4172
4190
  name: "Content Similarity Scorer",
@@ -4188,7 +4206,7 @@ function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = {
4188
4206
  processedOutput
4189
4207
  };
4190
4208
  }).generateScore(({ results }) => {
4191
- return string_similarity.default.compareTwoStrings(results.preprocessStepResult?.processedInput, results.preprocessStepResult?.processedOutput);
4209
+ return (ignoreWhitespace ? string_similarity.default.compareTwoStrings : compareWithWhitespace)(results.preprocessStepResult?.processedInput, results.preprocessStepResult?.processedOutput);
4192
4210
  });
4193
4211
  }
4194
4212
  // src/scorers/code/tone/index.ts
@@ -4701,5 +4719,3 @@ exports.noToolErrors = require_checks.noToolErrors;
4701
4719
  exports.similarity = require_checks.similarity;
4702
4720
  exports.toolOrder = require_checks.toolOrder;
4703
4721
  exports.usedNoTools = require_checks.usedNoTools;
4704
-
4705
- //# sourceMappingURL=index.cjs.map