To define turn-level tests, use the AiTestingDefinition Metadata API type. To learn how to use Metadata API, see Quick Start: Metadata API.
An AiTestingDefinition names the subject you’re testing (an agent or a prompt template) and lists test cases. Each test case has an input and one or more scorers.
Define a Test
Create package.xml that lists AiTestingDefinition and sets the version to 66.0 or later.
Create an aiTestingDefinitions folder.
Add a file named <TestName>.aiTestingDefinition to the folder.
Add a scorer for each check you want on a test case. Some scorers need an expectedValue, and some don’t. See the scorer list in the reference. To use a custom scorer, set the scorer name to its developer name.
Deploy the metadata with Salesforce CLI. Run the command from the folder that contains package.xml, and pass the path to that folder.
Can I change pass thresholds for built-in scorers?
No, the pass thresholds for built-in scorers are fixed. If you want to configure pass thresholds, use a custom scorer.
Are all legacy expectations supported as built-in scorers in AiTestingDefinition?
No, string_comparison and numeric_comparison are legacy expectations from AiEvaluationDefinition and aren’t valid in AiTestingDefinition. Deploying them fails with a “not a valid evaluation type” error.
When should I use agent_handoff_match?
Only use agent_handoff_match with multi-agent orchestrators. If you use it on a single agent, the deployment is rejected. On a multi-agent orchestrator, every test case must include this scorer with a non-empty expectedValue. Before comparing, the API strips the namespace prefix from expectedValue and the namespace and record ID suffix from the actual handoff. For example, c__GeneralCRM_16jRZ... is compared as GeneralCRM.
What is the difference between bot_response_rating and response_match?
Both compare the agent’s response to expectedValue, but they use different evaluators. We recommend bot_response_rating for answer quality. The bot_response_rating evaluator uses an LLM judge that considers the utterance, the expected response, and the actual response, and then scores overall quality and correctness. response_match measures how close the wording and meaning are using embedding cosine similarity. It doesn’t judge correctness, so a correct answer worded differently can score low.