@mastra/evals 1.4.0 → 1.5.0-alpha.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scorers/code/checks/index.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,QAAA,CAAS,QAAA,EAAkB,OAAA,GAA2B,EAAC,EAAG;AACxE,EAAA,MAAM,EAAE,UAAA,GAAa,IAAA,EAAK,GAAI,OAAA;AAC9B,EAAA,OAAO,YAAA,CAAa;AAAA,IAClB,EAAA,EAAI,gBAAA;AAAA,IACJ,IAAA,EAAM,gBAAA;AAAA,IACN,WAAA,EAAa,8BAA8B,QAAQ,CAAA,CAAA,CAAA;AAAA,IACnD,IAAA,EAAM;AAAA,GACP,CAAA,CACE,UAAA,CAAW,OAAO,EAAE,KAAI,KAAM;AAC7B,IAAA,IAAI,SAAS,GAAA,CAAI,MAAA,CACd,MAAA,CAAO,CAAA,CAAA,KAAK,EAAE,IAAA,KAAS,WAAW,CAAA,CAClC,GAAA,CAAI,OAAK,iCAAA,CAAkC,CAAC,CAAC,CAAA,CAC7C,KAAK,GAAG,CAAA;AACX,IAAA,IAAI,MAAA,GAAS,QAAA;AACb,IAAA,IAAI,UAAA,EAAY;AACd,MAAA,MAAA,GAAS,OAAO,WAAA,EAAY;AAC5B,MAAA,MAAA,GAAS,OAAO,WAAA,EAAY;AAAA,IAC9B;AACA,IAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,OAAO,MAAA,CAAO,QAAA,CAAS,MAAM,CAAA,EAAE;AAAA,EAC1D,CAAC,CAAA,CACA,aAAA,CAAc,CAAC,EAAE,SAAQ,KAAM;AAC9B,IAAA,OAAO,OAAA,CAAQ,oBAAA,EAAsB,KAAA,GAAQ,CAAA,GAAI,CAAA;AAAA,EACnD,CAAC,CAAA;AACL;AAWO,SAAS,QAAA,CAAS,QAAA,EAAkB,OAAA,GAA2B,EAAC,EAAG;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AW,WAAW,MAAA,EAAQ;AAC5B,IAAA,MAAM,MAAA,GAAS,SAAS,OAAA,EAAS,eAAA;AACjC,IAAA,MAAM,YAAY,MAAA,GACd,MAAA,GACC,OAAA,EAAS,OAAA,EAAiB,OACvB,MAAA,CAAO,CAAC,CAAA,KAAW,CAAA,CAAE,SAAS,iBAAiB,CAAA,CAChD,IAAI,CAAC,CAAA,KAAW,EAAE,cAAc,CAAA;AACvC,IAAA,KAAA,MAAW,GAAA,IAAO,MAAA,IAAU,SAAA,IAAa,EAAC,EAAG;AAC3C,MAAA,IAAI,GAAA,EAAK,WAAA,CAAY,IAAA,CAAK,GAAG,CAAA;AAAA,IAC/B;AAAA,EACF;AACA,EAAA,OAAO,WAAA;AACT;AA4BO,IAAM,MAAA,GAAS;AAAA,EACpB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF","file":"chunk-QRAONHNV.js","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"]}
@@ -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.4.0"
6
+ version: "1.5.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -18,12 +18,14 @@ Read the individual reference documents for detailed explanations and code examp
18
18
 
19
19
  - [Built-in scorers](references/docs-evals-built-in-scorers.md) - Overview of Mastra's ready-to-use scorers for evaluating AI outputs across quality, safety, and performance dimensions.
20
20
  - [Scorers overview](references/docs-evals-overview.md) - Overview of scorers in Mastra, detailing their capabilities for evaluating AI outputs and measuring performance.
21
+ - [Quick Checks](references/docs-evals-quick-checks.md) - Zero-LLM micro-scorers for fast, deterministic assertions on agent output text and tool usage.
21
22
 
22
23
  ### Reference
23
24
 
24
25
  - [Reference: Answer relevancy scorer](references/reference-evals-answer-relevancy.md) - Documentation for the Answer Relevancy Scorer in Mastra, which evaluates how well LLM outputs address the input query.
25
26
  - [Reference: Answer similarity scorer](references/reference-evals-answer-similarity.md) - Documentation for the Answer Similarity Scorer in Mastra, which compares agent outputs against ground truth answers for CI/CD testing.
26
27
  - [Reference: Bias scorer](references/reference-evals-bias.md) - Documentation for the Bias Scorer in Mastra, which evaluates LLM outputs for various forms of bias, including gender, political, racial/ethnic, or geographical bias.
28
+ - [Reference: Quick Checks](references/reference-evals-checks.md) - API reference for Quick Checks, zero-LLM composable micro-scorers for common assertions like text matching, tool usage, and tool ordering.
27
29
  - [Reference: Completeness scorer](references/reference-evals-completeness.md) - Documentation for the Completeness Scorer in Mastra, which evaluates how thoroughly LLM outputs cover key elements present in the input.
28
30
  - [Reference: Content similarity scorer](references/reference-evals-content-similarity.md) - Documentation for the Content Similarity Scorer in Mastra, which measures textual similarity between strings and provides a matching score.
29
31
  - [Reference: Context precision scorer](references/reference-evals-context-precision.md) - Documentation for the Context Precision Scorer in Mastra. Evaluates the relevance and precision of retrieved context for generating expected outputs using Mean Average Precision.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.0",
2
+ "version": "1.5.0-alpha.0",
3
3
  "package": "@mastra/evals",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -45,4 +45,20 @@ These scorers evaluate adherence to format, style, and safety requirements:
45
45
  - [`tone-consistency`](https://mastra.ai/reference/evals/tone-consistency): Measures consistency in formality, complexity, and style (`0-1`, higher is better)
46
46
  - [`toxicity`](https://mastra.ai/reference/evals/toxicity): Detects harmful or inappropriate content (`0-1`, lower is better)
47
47
  - [`bias`](https://mastra.ai/reference/evals/bias): Detects potential biases in the output (`0-1`, lower is better)
48
- - [`keyword-coverage`](https://mastra.ai/reference/evals/keyword-coverage): Assesses technical terminology usage (`0-1`, higher is better)
48
+ - [`keyword-coverage`](https://mastra.ai/reference/evals/keyword-coverage): Assesses technical terminology usage (`0-1`, higher is better)
49
+
50
+ ### Quick Checks
51
+
52
+ Zero-LLM micro-scorers for fast, deterministic assertions. See the [Quick Checks](https://mastra.ai/docs/evals/quick-checks) guide for usage details.
53
+
54
+ - [`checks.includes`](https://mastra.ai/reference/evals/checks): Scores 1 if output contains a substring (`0` or `1`)
55
+ - [`checks.excludes`](https://mastra.ai/reference/evals/checks): Scores 1 if output does not contain a substring (`0` or `1`)
56
+ - [`checks.equals`](https://mastra.ai/reference/evals/checks): Scores 1 if output exactly matches a string (`0` or `1`)
57
+ - [`checks.matches`](https://mastra.ai/reference/evals/checks): Scores 1 if output matches a regex (`0` or `1`)
58
+ - [`checks.similarity`](https://mastra.ai/reference/evals/checks): String similarity via Dice coefficient (`0-1`, or binary with threshold)
59
+ - [`checks.calledTool`](https://mastra.ai/reference/evals/checks): Scores 1 if a tool was called at least N times (`0` or `1`)
60
+ - [`checks.didNotCall`](https://mastra.ai/reference/evals/checks): Scores 1 if a tool was not called (`0` or `1`)
61
+ - [`checks.toolOrder`](https://mastra.ai/reference/evals/checks): Scores 1 if tools were called in order (`0` or `1`)
62
+ - [`checks.maxToolCalls`](https://mastra.ai/reference/evals/checks): Scores 1 if tool call count is within limit (`0` or `1`)
63
+ - [`checks.usedNoTools`](https://mastra.ai/reference/evals/checks): Scores 1 if no tools were called (`0` or `1`)
64
+ - [`checks.noToolErrors`](https://mastra.ai/reference/evals/checks): Scores 1 if no tool calls had errors (`0` or `1`)
@@ -135,6 +135,7 @@ Once registered, you can score traces interactively within Studio under the **Ob
135
135
 
136
136
  ## Next steps
137
137
 
138
+ - Use [Quick Checks](https://mastra.ai/docs/evals/quick-checks) for fast, deterministic assertions on text and tool usage
138
139
  - Learn how to create your own scorers in the [Creating Custom Scorers](https://mastra.ai/docs/evals/custom-scorers) guide
139
140
  - Explore built-in scorers in the [Built-in Scorers](https://mastra.ai/docs/evals/built-in-scorers) section
140
141
  - Test scorers with [Studio](https://mastra.ai/docs/studio/overview)
@@ -0,0 +1,136 @@
1
+ # Quick Checks
2
+
3
+ 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.
4
+
5
+ ## When to use Quick Checks
6
+
7
+ Use Quick Checks when you need fast, deterministic assertions:
8
+
9
+ - Verify output text contains or excludes specific strings
10
+ - Confirm an agent called (or avoided) specific tools
11
+ - Validate tool call ordering and count limits
12
+ - Gate CI pipelines with zero-cost binary checks
13
+ - Combine with LLM-based scorers for layered evaluation
14
+
15
+ For subjective or semantic evaluation, use [LLM-based scorers](https://mastra.ai/docs/evals/built-in-scorers) instead.
16
+
17
+ ## Quickstart
18
+
19
+ ```typescript
20
+ import { checks } from '@mastra/evals/checks'
21
+ import { runEvals } from '@mastra/core/evals'
22
+ import { weatherAgent } from '../agents'
23
+
24
+ const result = await runEvals({
25
+ data: [{ input: 'What is the weather in Brooklyn?' }],
26
+ target: weatherAgent,
27
+ scorers: [checks.includes('Brooklyn'), checks.calledTool('get_weather'), checks.noToolErrors()],
28
+ })
29
+
30
+ console.log(result.scores)
31
+ // { 'check-includes': 1, 'check-called-tool': 1, 'check-no-tool-errors': 1 }
32
+ ```
33
+
34
+ ## Available checks
35
+
36
+ Quick Checks fall into two categories:
37
+
38
+ ### Text checks
39
+
40
+ These scorers evaluate the agent's text output:
41
+
42
+ | Check | What it does | Score |
43
+ | ------------------------ | ------------------------------------- | -------------------------------- |
44
+ | `checks.includes(str)` | Output contains substring | 1 or 0 |
45
+ | `checks.excludes(str)` | Output does not contain substring | 1 or 0 |
46
+ | `checks.equals(str)` | Output exactly equals string | 1 or 0 |
47
+ | `checks.matches(regex)` | Output matches regular expression | 1 or 0 |
48
+ | `checks.similarity(str)` | Dice coefficient similarity to string | 0-1 (or binary with `threshold`) |
49
+
50
+ ### Tool call checks
51
+
52
+ These scorers evaluate tool usage from the agent's run:
53
+
54
+ | Check | What it does | Score |
55
+ | ------------------------- | -------------------------------- | ------ |
56
+ | `checks.calledTool(name)` | Tool was called at least N times | 1 or 0 |
57
+ | `checks.didNotCall(name)` | Tool was not called | 1 or 0 |
58
+ | `checks.toolOrder([...])` | Tools called in expected order | 1 or 0 |
59
+ | `checks.maxToolCalls(n)` | No more than N tool calls total | 1 or 0 |
60
+ | `checks.usedNoTools()` | No tools called at all | 1 or 0 |
61
+ | `checks.noToolErrors()` | No tool invocations had errors | 1 or 0 |
62
+
63
+ ## Combining checks with LLM scorers
64
+
65
+ Checks compose with LLM-based scorers in a single `runEvals` call. Use checks for deterministic gates and LLM scorers for qualitative evaluation:
66
+
67
+ ```typescript
68
+ import { checks } from '@mastra/evals/checks'
69
+ import { createFaithfulnessScorer } from '@mastra/evals/scorers/prebuilt'
70
+ import { runEvals } from '@mastra/core/evals'
71
+ import { myAgent } from '../agents'
72
+
73
+ const result = await runEvals({
74
+ data: [
75
+ {
76
+ input: 'What is the weather in Brooklyn?',
77
+ context: ['Brooklyn weather data: sunny, 72°F'],
78
+ },
79
+ ],
80
+ target: myAgent,
81
+ scorers: [
82
+ // Deterministic checks (instant, free)
83
+ checks.includes('Brooklyn'),
84
+ checks.calledTool('get_weather'),
85
+ checks.excludes('error'),
86
+ checks.noToolErrors(),
87
+
88
+ // LLM-based scorer (semantic, costs tokens)
89
+ createFaithfulnessScorer({ model: 'openai/gpt-5-mini' }),
90
+ ],
91
+ })
92
+ ```
93
+
94
+ ## Using checks in live scoring
95
+
96
+ Attach checks to agents for continuous monitoring:
97
+
98
+ ```typescript
99
+ import { Agent } from '@mastra/core/agent'
100
+ import { checks } from '@mastra/evals/checks'
101
+
102
+ export const weatherAgent = new Agent({
103
+ name: 'Weather Agent',
104
+ instructions: 'Answer weather questions using the get_weather tool.',
105
+ model: 'openai/gpt-5.5',
106
+ tools: { get_weather: weatherTool },
107
+ scorers: {
108
+ noErrors: {
109
+ scorer: checks.noToolErrors(),
110
+ sampling: { type: 'ratio', rate: 1 },
111
+ },
112
+ mentionCity: {
113
+ scorer: checks.includes('Brooklyn'),
114
+ sampling: { type: 'ratio', rate: 0.5 },
115
+ },
116
+ },
117
+ })
118
+ ```
119
+
120
+ ## How checks work
121
+
122
+ 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:
123
+
124
+ 1. **preprocess**: Extracts and normalizes relevant data from the agent run (text content, tool calls)
125
+ 2. **generateScore**: Converts the preprocessed result into a score (typically binary 1 or 0)
126
+
127
+ Because checks skip the `analyze` and `generateReason` steps and make no LLM calls, they run in microseconds.
128
+
129
+ > **Note:** Visit the [Quick Checks reference](https://mastra.ai/reference/evals/checks) for the full API, including all parameters and options for each check.
130
+
131
+ ## Related
132
+
133
+ - [Quick Checks reference](https://mastra.ai/reference/evals/checks)
134
+ - [Built-in Scorers](https://mastra.ai/docs/evals/built-in-scorers)
135
+ - [Custom Scorers](https://mastra.ai/docs/evals/custom-scorers)
136
+ - [`runEvals()` reference](https://mastra.ai/reference/evals/run-evals)
@@ -0,0 +1,210 @@
1
+ # Quick Checks
2
+
3
+ Quick Checks are zero-LLM, composable micro-scorers for common assertions. They plug into the existing `scorers: [...]` array anywhere scorers are used — in `runEvals`, live scoring, experiments, and Studio.
4
+
5
+ Internally they are standard `createScorer()` instances, so they have the same observability, storage, and pipeline integration as any other scorer.
6
+
7
+ ## Usage example
8
+
9
+ ```typescript
10
+ import { checks } from '@mastra/evals/checks'
11
+ import { runEvals } from '@mastra/core/evals'
12
+ import { myAgent } from '../agents'
13
+
14
+ const result = await runEvals({
15
+ data: [{ input: 'What is the weather in Brooklyn?' }],
16
+ target: myAgent,
17
+ scorers: [
18
+ checks.includes('sunny'),
19
+ checks.calledTool('get_weather'),
20
+ checks.toolOrder(['get_weather', 'summarize']),
21
+ checks.noToolErrors(),
22
+ ],
23
+ })
24
+
25
+ console.log(result.scores)
26
+ ```
27
+
28
+ ## Text checks
29
+
30
+ ### `checks.includes(expected, options?)`
31
+
32
+ Scores 1 if the agent's output text contains the expected substring, 0 otherwise.
33
+
34
+ ```typescript
35
+ checks.includes('sunny')
36
+ checks.includes('Sunny', { ignoreCase: false })
37
+ ```
38
+
39
+ **expected** (`string`): Substring to search for in the output.
40
+
41
+ **options.ignoreCase** (`boolean`): Case-insensitive matching. (Default: `true`)
42
+
43
+ Returns: `1` if found, `0` otherwise.
44
+
45
+ ### `checks.excludes(unwanted, options?)`
46
+
47
+ Scores 1 if the agent's output text does NOT contain the substring, 0 otherwise.
48
+
49
+ ```typescript
50
+ checks.excludes('error')
51
+ checks.excludes('Error', { ignoreCase: false })
52
+ ```
53
+
54
+ **unwanted** (`string`): Substring that must not appear in the output.
55
+
56
+ **options.ignoreCase** (`boolean`): Case-insensitive matching. (Default: `true`)
57
+
58
+ Returns: `1` if absent, `0` otherwise.
59
+
60
+ ### `checks.equals(expected, options?)`
61
+
62
+ Scores 1 if the output text exactly equals the expected string after optional normalization.
63
+
64
+ ```typescript
65
+ checks.equals('Hello, world!')
66
+ checks.equals('Hello', { ignoreCase: false })
67
+ ```
68
+
69
+ **expected** (`string`): Exact string the output must match.
70
+
71
+ **options.ignoreCase** (`boolean`): Case-insensitive matching. (Default: `true`)
72
+
73
+ Returns: `1` if equal, `0` otherwise.
74
+
75
+ ### `checks.matches(pattern, options?)`
76
+
77
+ Scores 1 if the output matches the given regular expression.
78
+
79
+ ```typescript
80
+ checks.matches(/\d+°[FC]/)
81
+ checks.matches(/^hello$/, { exact: true })
82
+ ```
83
+
84
+ **pattern** (`RegExp`): Regular expression to test against the output.
85
+
86
+ **options.exact** (`boolean`): Anchor the pattern to match the entire output (adds ^ and $). (Default: `false`)
87
+
88
+ Returns: `1` if matched, `0` otherwise.
89
+
90
+ ### `checks.similarity(expected, options?)`
91
+
92
+ Returns the string similarity score (0-1) between the output and an expected string using the Dice coefficient. When a `threshold` is set, returns binary 1/0 instead.
93
+
94
+ ```typescript
95
+ checks.similarity('Sunny, 72°F')
96
+ checks.similarity('Sunny, 72°F', { threshold: 0.7 })
97
+ ```
98
+
99
+ **expected** (`string`): Reference string to compare against.
100
+
101
+ **options.threshold** (`number`): Minimum similarity score (0-1) to return 1. When omitted, returns the raw similarity score.
102
+
103
+ **options.ignoreCase** (`boolean`): Case-insensitive comparison. (Default: `true`)
104
+
105
+ Returns: Raw similarity score (0-1), or binary `1`/`0` when `threshold` is set.
106
+
107
+ ## Tool call checks
108
+
109
+ ### `checks.calledTool(toolName, options?)`
110
+
111
+ Scores 1 if the agent called the specified tool at least the required number of times.
112
+
113
+ ```typescript
114
+ checks.calledTool('get_weather')
115
+ checks.calledTool('search', { times: 2 })
116
+ ```
117
+
118
+ **toolName** (`string`): Name of the tool to look for.
119
+
120
+ **options.times** (`number`): Minimum number of times the tool must be called. (Default: `1`)
121
+
122
+ Returns: `1` if called at least `times` times, `0` otherwise.
123
+
124
+ ### `checks.didNotCall(toolName)`
125
+
126
+ Scores 1 if the agent did NOT call the specified tool.
127
+
128
+ ```typescript
129
+ checks.didNotCall('delete_user')
130
+ ```
131
+
132
+ **toolName** (`string`): Name of the tool that must not appear.
133
+
134
+ Returns: `1` if the tool was not called, `0` otherwise.
135
+
136
+ ### `checks.toolOrder(expectedOrder)`
137
+
138
+ Scores 1 if the tools were called in the specified order. Uses relaxed matching — other tool calls between the expected tools are allowed.
139
+
140
+ ```typescript
141
+ checks.toolOrder(['search', 'summarize', 'respond'])
142
+ ```
143
+
144
+ **expectedOrder** (`string[]`): Tool names in the expected calling sequence. Must appear as a subsequence of the actual tool calls.
145
+
146
+ Returns: `1` if the expected order is satisfied, `0` otherwise.
147
+
148
+ ### `checks.maxToolCalls(max)`
149
+
150
+ Scores 1 if the agent used no more than `max` tool calls.
151
+
152
+ ```typescript
153
+ checks.maxToolCalls(5)
154
+ ```
155
+
156
+ **max** (`number`): Maximum number of tool calls allowed.
157
+
158
+ Returns: `1` if within the limit, `0` otherwise.
159
+
160
+ ### `checks.usedNoTools()`
161
+
162
+ Scores 1 if the agent made no tool calls at all.
163
+
164
+ ```typescript
165
+ checks.usedNoTools()
166
+ ```
167
+
168
+ Returns: `1` if no tools were called, `0` otherwise.
169
+
170
+ ### `checks.noToolErrors()`
171
+
172
+ Scores 1 if none of the tool invocations resulted in an error state. Detects both error results (`result.error` present) and incomplete tool calls (`state === 'call'`).
173
+
174
+ ```typescript
175
+ checks.noToolErrors()
176
+ ```
177
+
178
+ Returns: `1` if all tool calls succeeded, `0` otherwise.
179
+
180
+ ## Combining checks with other scorers
181
+
182
+ Checks compose with LLM-based and code-based scorers in the same `scorers` array:
183
+
184
+ ```typescript
185
+ import { checks } from '@mastra/evals/checks'
186
+ import { createAnswerRelevancyScorer } from '@mastra/evals/scorers/prebuilt'
187
+ import { runEvals } from '@mastra/core/evals'
188
+ import { myAgent } from '../agents'
189
+
190
+ const result = await runEvals({
191
+ data: [{ input: 'What is the weather in Brooklyn?' }],
192
+ target: myAgent,
193
+ scorers: [
194
+ // Zero-LLM checks
195
+ checks.includes('Brooklyn'),
196
+ checks.calledTool('get_weather'),
197
+ checks.noToolErrors(),
198
+ // LLM-based scorer
199
+ createAnswerRelevancyScorer({ model: 'openai/gpt-5-mini' }),
200
+ ],
201
+ })
202
+ ```
203
+
204
+ ## Related
205
+
206
+ - [Quick Checks overview](https://mastra.ai/docs/evals/quick-checks)
207
+ - [Built-in Scorers](https://mastra.ai/docs/evals/built-in-scorers)
208
+ - [`createScorer()` reference](https://mastra.ai/reference/evals/create-scorer)
209
+ - [`runEvals()` reference](https://mastra.ai/reference/evals/run-evals)
210
+ - [Custom Scorers](https://mastra.ai/docs/evals/custom-scorers)