Let us know so we can improve!
The Trailblazer Community in Slack is now in Open Beta—join and connect in real time. [Join us in Slack]
To define tests that run on the /einstein/ai-testing Connect API resources, use the AiTestingDefinition Metadata API type.
AiTestingDefinition is the successor to AiEvaluationDefinition. If you have tests that use the legacy type, see the legacy Metadata API reference.
Note
Represents a test suite: the agent or prompt template being tested, the test cases to run, and the scorers that grade each test case.
In Metadata API, you create test definitions, including inputs and scorers, and deploy them to different orgs. In Connect API, you run the tests, poll for status, and retrieve results.
This type extends the Metadata metadata type and inherits its fullName field.
AiTestingDefinition components have the suffix .aiTestingDefinition and are stored in the aiTestingDefinitions folder.
AiTestingDefinition components are available in API version 66.0 and later. Deploying with an earlier version in package.xml fails.
| Field Name | Type | Description |
|---|---|---|
description | string | The purpose of the test suite. |
name | string | Required. The API name of the test suite. Must be unique in your org, begin with a letter, and not end with an underscore or contain consecutive underscores. Can contain only alphanumeric characters and underscores. |
subjectName | string | Required. The API name of the agent or prompt template being tested. For an agent, find the API name on the agent details page in Setup. |
subjectType | string | Required. The type of subject being tested. Valid values are AGENT and PROMPT. The type determines the shape of each test case’s inputs and which scorers you can use. |
subjectVersion | string | The version of the subject to test. If not provided, the latest active version is used. For agents, you can find the version in the BotVersion metadata type. |
testCase | AiTestCase[] or AiPromptTestCase[] | A list of test cases. Use AiTestCase when subjectType is AGENT. Use AiPromptTestCase when subjectType is PROMPT. |
Represents a test case for an agent.
| Field Name | Type | Description |
|---|---|---|
inputs | AiTestCaseInput | Required. The input sent to the agent. |
number | int | The number that identifies the test case, unique within the test suite. If not provided, the value is automatically calculated. |
scorer | AiTestCaseScorer[] | Required. The scorers that grade the agent’s response to this test case. |
Represents the input for an agent test case.
| Field Name | Type | Description |
|---|---|---|
utterance | string | Required. The request sent to the agent. |
contextVariable | AiTestCaseContextVariable[] | The context variables sent to the agent. Repeat the element for each variable. Use the variable names defined for your agent. |
conversationHistory | AiTestCaseConversationTurn[] | The earlier messages in the conversation, sent to the agent before utterance. Repeat the element for each message. |
Represents a context variable sent to the agent.
| Field Name | Type | Description |
|---|---|---|
variableName | string | Required. The name of the context variable. |
variableValue | string | Required. The value of the context variable. |
Represents one message in the conversation history sent to the agent.
| Field Name | Type | Description |
|---|---|---|
role | string | The role associated with the message. Valid values are user and agent. A conversation must begin with a message from the user. |
message | string | The text from the user or agent. |
topic | string | Required when role is agent. The API name of the subagent the agent used to generate the response. |
index | int | A zero-based index for this conversation message. |
Represents a test case for a prompt template.
| Field Name | Type | Description |
|---|---|---|
inputs | AiPromptTestCaseInput | Required. The values sent to the prompt template. |
number | int | The number that identifies the test case, unique within the test suite. If not provided, the value is automatically calculated. |
scorer | AiTestCaseScorer[] | Required. The scorers that grade the prompt template’s response to this test case. |
Represents the input for a prompt template test case.
| Field Name | Type | Description |
|---|---|---|
promptInput | AiPromptInputValue[] | Required. The values for the prompt template’s input slots. Repeat for each input. |
Represents the value for one input slot of the prompt template.
| Field Name | Type | Description |
|---|---|---|
referenceName | string | Required. The name of the prompt template input. |
value | string | Required. The value to send for that input. |
Represents a scorer that grades the response to a test case. A test case can have several scorers.
| Field Name | Type | Description |
|---|---|---|
name | string | Required. The name of the scorer. For a built-in scorer, see Built-In Scorers. For a custom scorer, use its developer name. See Custom Scorers. |
expectedValue | string | The value to compare the response against. Required by scorers that compare against an expected result, such as topic_sequence_match. Omit it for scorers that grade the response on its own, such as conciseness. See Built-In Scorers. |
| Scorer Name | Subject Types | Expected Value | Result |
|---|---|---|---|
topic_sequence_match | AGENT | Required. The API name of the expected subagent. | Pass or fail. |
action_sequence_match | AGENT | Required. The expected actions, as an array such as ['IdentifyRecordByName']. Use [] for no actions. | Pass or fail. |
agent_handoff_match | AGENT | Required. The API name of the agent that you expect the orchestrator to hand off to, such as GeneralCRM. Exact match. | Pass or fail. |
bot_response_rating | AGENT | Required. A description of the expected response. | Score from 0 to 5, graded by an LLM. Passes at 3.0 or higher. |
response_match | AGENT, PROMPT | Required. A description of the expected response. | Score from 0 to 1, based on embedding cosine similarity. Passes at 0.6 or higher. |
coherence | AGENT, PROMPT | Not used. | Score from 0 to 5, graded by an LLM. Passes at 3.0 or higher. |
conciseness | AGENT, PROMPT | Not used. | Score from 0 to 5, graded by an LLM. Passes at 3.0 or higher. |
factuality | AGENT, PROMPT | Not used. | Score from 0 to 5, graded by an LLM. Passes at 3.0 or higher. |
completeness | AGENT, PROMPT | Not used. | Score from 0 to 5, graded by an LLM. Passes at 3.0 or higher. |
task_resolution | AGENT | Not used. Requires conversationHistory in the test case input. | Score from 0 to 5, graded by an LLM. |
output_latency_milliseconds | AGENT | Not used. | Response time in milliseconds. |
Here’s an example of an AiTestingDefinition component for an agent.
1<?xml version="1.0" encoding="UTF-8"?>
2<AiTestingDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
3 <description>My Sample Tests</description>
4 <name>my_test_n1</name>
5 <subjectName>Agentforce_Service_Agent</subjectName>
6 <subjectType>AGENT</subjectType>
7 <subjectVersion>v1</subjectVersion>
8 <testCase>
9 <number>1</number>
10 <inputs>
11 <utterance>Summarize the Global Media account</utterance>
12 </inputs>
13 <scorer>
14 <name>topic_sequence_match</name>
15 <expectedValue>OOTBSingleRecordSummary</expectedValue>
16 </scorer>
17 <scorer>
18 <name>action_sequence_match</name>
19 <expectedValue>['IdentifyRecordByName']</expectedValue>
20 </scorer>
21 <scorer>
22 <name>bot_response_rating</name>
23 <expectedValue>Summarization of the Global Media account</expectedValue>
24 </scorer>
25 <scorer>
26 <name>conciseness</name>
27 </scorer>
28 </testCase>
29 <testCase>
30 <number>2</number>
31 <inputs>
32 <utterance>give me a pizza recipe</utterance>
33 </inputs>
34 <scorer>
35 <name>topic_sequence_match</name>
36 <expectedValue>Small_Talk</expectedValue>
37 </scorer>
38 <scorer>
39 <name>action_sequence_match</name>
40 <expectedValue>[]</expectedValue>
41 </scorer>
42 <scorer>
43 <name>bot_response_rating</name>
44 <expectedValue>the agent cannot answer this</expectedValue>
45 </scorer>
46 </testCase>
47</AiTestingDefinition>To deploy or retrieve a test definition, include AiTestingDefinition in package.xml and set the version to 66.0 or later.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3 <types>
4 <members>my_test_n1</members>
5 <name>AiTestingDefinition</name>
6 </types>
7 <version>66.0</version>
8</Package>