Quick Checks
Quick Checks は、一般的なアサーションに使える、LLM を使用しない合成可能なマイクロ Scorer です。既存の scorers: [...] 配列に追加でき、Scorer を使用できる場所なら runEvals、ライブスコアリング、実験、Studio のいずれでも利用できます。
内部的には標準の createScorer() インスタンスであるため、他の Scorer と同じ可観測性、ストレージ、パイプライン統合を備えています。
使用例使用例への直接リンク
import { checks } from '@mastra/evals/checks'
import { runEvals } from '@mastra/core/evals'
import { myAgent } from '../agents'
const result = await runEvals({
data: [{ input: 'What is the weather in Brooklyn?' }],
target: myAgent,
scorers: [
checks.includes('sunny'),
checks.calledTool('get_weather'),
checks.toolOrder(['get_weather', 'summarize']),
checks.noToolErrors(),
],
})
console.log(result.scores)
テキストチェックテキストチェックへの直接リンク
checks.includes(expected, options?)checksincludesexpected-optionsへの直接リンク
Agent の出力テキストに指定した部分文字列が含まれる場合は 1、それ以外は 0 をスコアとして返します。
checks.includes('sunny')
checks.includes('Sunny', { ignoreCase: false })
expected:
options.ignoreCase?:
戻り値:見つかった場合は 1、それ以外は 0。
checks.excludes(unwanted, options?)checksexcludesunwanted-optionsへの直接リンク
Agent の出力テキストに指定した部分文字列が含まれない場合は 1、それ以外は 0 をスコアとして返します。
checks.excludes('error')
checks.excludes('Error', { ignoreCase: false })
unwanted:
options.ignoreCase?:
戻り値:含まれない場合は 1、それ以外は 0。
checks.equals(expected, options?)checksequalsexpected-optionsへの直接リンク
任意の正規化後に、出力テキストが指定した文字列と完全に一致する場合は 1、それ以外は 0 をスコアとして返します。
checks.equals('Hello, world!')
checks.equals('Hello', { ignoreCase: false })
expected:
options.ignoreCase?:
戻り値:一致する場合は 1、それ以外は 0。
checks.matches(pattern, options?)checksmatchespattern-optionsへの直接リンク
出力が正規表現に一致する場合は 1 をスコアとして返します。
checks.matches(/\d+°[FC]/)
checks.matches(/^hello$/, { exact: true })
pattern:
options.exact?:
戻り値:一致する場合は 1、それ以外は 0。
checks.similarity(expected, options?)checkssimilarityexpected-optionsへの直接リンク
Dice 係数を使い、出力と指定した文字列の類似度スコア(0〜1)を返します。二値の 1 または 0 を返すようにするには、threshold を設定します。
checks.similarity('Sunny, 72°F')
checks.similarity('Sunny, 72°F', { threshold: 0.7 })
expected:
options.threshold?:
options.ignoreCase?:
戻り値:未加工の類似度スコア(0〜1)、または二値の 1 / 0(threshold 設定時)。
Tool 呼び出しチェックTool 呼び出しチェックへの直接リンク
checks.calledTool(toolName, options?)checkscalledtooltoolname-optionsへの直接リンク
Agent が指定した Tool を必要な回数以上呼び出した場合は 1 をスコアとして返します。
checks.calledTool('get_weather')
checks.calledTool('search', { times: 2 })
toolName:
options.times?:
戻り値:1(times 回以上呼び出された場合)、それ以外は 0。
checks.didNotCall(toolName)checksdidnotcalltoolnameへの直接リンク
Agent が指定した Tool を呼び出さなかった場合は 1 をスコアとして返します。
checks.didNotCall('delete_user')
toolName:
戻り値:Tool が呼び出されなかった場合は 1、それ以外は 0。
checks.toolOrder(expectedOrder)checkstoolorderexpectedorderへの直接リンク
Tool が指定した順序で呼び出された場合は 1 をスコアとして返します。緩和された照合を使用するため、指定した Tool の間に別の Tool 呼び出しがあっても構いません。
checks.toolOrder(['search', 'summarize', 'respond'])
expectedOrder:
戻り値:指定した順序を満たす場合は 1、それ以外は 0。
checks.maxToolCalls(max)checksmaxtoolcallsmaxへの直接リンク
Agent による Tool 呼び出しが max 回以下の場合は 1 をスコアとして返します。
checks.maxToolCalls(5)
max:
戻り値:上限以内の場合は 1、それ以外は 0。
checks.usedNoTools()checksusednotoolsへの直接リンク
Agent が Tool を一度も呼び出さなかった場合は 1 をスコアとして返します。
checks.usedNoTools()
戻り値:Tool が呼び出されなかった場合は 1、それ以外は 0。
checks.noToolErrors()checksnotoolerrorsへの直接リンク
どの Tool 呼び出しもエラー状態にならなかった場合は 1 をスコアとして返します。エラー結果(result.error が存在する場合)と未完了の Tool 呼び出し(state === 'call')の両方を検出します。
checks.noToolErrors()
戻り値:すべての Tool 呼び出しが成功した場合は 1、それ以外は 0。
他の Scorer との組み合わせ他の Scorer との組み合わせへの直接リンク
Checks は、同じ scorers 配列内で LLM ベースおよびコードベースの Scorer と組み合わせられます。
import { checks } from '@mastra/evals/checks'
import { createAnswerRelevancyScorer } from '@mastra/evals/scorers/prebuilt'
import { runEvals } from '@mastra/core/evals'
import { myAgent } from '../agents'
const result = await runEvals({
data: [{ input: 'What is the weather in Brooklyn?' }],
target: myAgent,
scorers: [
// Zero-LLM checks
checks.includes('Brooklyn'),
checks.calledTool('get_weather'),
checks.noToolErrors(),
// LLM-based scorer
createAnswerRelevancyScorer({ model: 'openai/gpt-5-mini' }),
],
})