Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,15 @@
"alias": [],
"command": "agent:test:run",
"flagAliases": [],
"flagChars": ["d", "n", "o", "w"],
"flagChars": ["d", "n", "o", "s", "w"],
"flags": [
"api-name",
"api-version",
"flags-dir",
"json",
"output-dir",
"result-format",
"spec",
"target-org",
"test-runner",
"verbose",
Expand Down
43 changes: 43 additions & 0 deletions messages/agent.test.run.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ By default, this command starts the agent test in your org, but it doesn't wait

By default, this command outputs test results in human-readable tables for each test case, if the test completes in time. The tables show whether the test case passed, the expected and actual values, the test score, how long the test took, and more. Use the --result-format to display the test results in JSON or Junit format. Use the --output-dir flag to write the results to a file rather than to the terminal.

To run a conversation-level test without saving it to your org, use the --spec flag instead of --api-name, and specify a YAML test spec that has `testScope: CONVERSATION_LEVEL`. A simulated user holds a multi-turn conversation with the agent for each test case's `conversationGoal`, and the scorers in the spec grade it. The command waits for the run to finish and displays the results; nothing is saved to the org. The --wait and --test-runner flags don't apply to --spec.

# flags.api-name.summary

API name of the agent test to run; corresponds to the name of the AiEvaluationDefinition metadata component that implements the agent test.
Expand All @@ -18,6 +20,14 @@ API name of the agent test to run; corresponds to the name of the AiEvaluationDe

API name of the agent test to run

# flags.spec.summary

Path to a conversation-level test spec (YAML) to run without saving it to the org.

# flags.spec.description

The spec must set `testScope: CONVERSATION_LEVEL`, and name the agent with `subjectName` (a published agent's API name, plus an optional `subjectVersion` such as v3; the latest version is used if omitted) or `project` (a draft agent's projectId and projectVersionId). Each test case needs a `conversationGoal`. Supported scorers when running without saving: task_resolution (the default), acceptance_criteria, topic_sequence_match and action_sequence_match. A run accepts up to 10 test cases (more if your org has a higher limit) and `maxTurns` from 1 to 30. The command checks the spec's structure before calling the org; a scorer, persona or limit it doesn't recognize produces a warning, and the org makes the final check.

# flags.wait.summary

Number of minutes to wait for the command to complete and display results to the terminal window.
Expand All @@ -36,6 +46,39 @@ Number of minutes to wait for the command to complete and display results to the

<%= config.bin %> <%= command.id %> --api-name Resort_Manager_Test --wait 10 --output-dir ./test-results --result-format json

- Run the conversation-level test spec in the file specs/order-status-clt.yaml without saving it, using the org with alias "my-org":

<%= config.bin %> <%= command.id %> --spec specs/order-status-clt.yaml --target-org my-org

- Run a conversation-level test spec and write the JUnit-formatted results into a directory called "test-results":

<%= config.bin %> <%= command.id %> --spec specs/order-status-clt.yaml --output-dir ./test-results --result-format junit

# progress.conversationRun

Running conversation-level test "%s" (%s test cases) without saving

# error.specFileNotFound

Spec file not found: %s

# error.specNotConversationLevel

The spec %s isn't a conversation-level test spec.

# error.specNotConversationLevel.actions

- Add `testScope: CONVERSATION_LEVEL` to the spec to run it with --spec.
- To run a saved turn-level test, deploy it and use --api-name instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: a turn-level spec doesn't have to be deployed to run.

Suggested change
- To run a saved turn-level test, deploy it and use --api-name instead.
- To run a turn-level test spec without saving it, use `agent test run-eval --spec`. To run a saved turn-level test, use --api-name.


# error.invalidSpec

The spec %s isn't valid: %s

# error.agentVersionNotFound

Version '%s' of agent '%s' not found. Set `subjectVersion` to a BotVersion API name such as v1, or remove it to use the latest version.

# error.missingRequiredFlags

When using --json, you must also specify the required flag(s): %s.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@inquirer/prompts": "^7.10.1",
"@oclif/core": "^5.0.0",
"@oclif/multi-stage-output": "^1.0.0",
"@salesforce/agents": "^2.5.4",
"@salesforce/agents": "^2.6.0",
"@salesforce/core": "^9.1.9",
"@salesforce/kit": "^4.0.0",
"@salesforce/sf-plugins-core": "^13.0.0",
Expand Down
187 changes: 122 additions & 65 deletions schemas/agent-test-run.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/AgentTestRunResult",
"$ref": "#/definitions/AgentTestRunCommandResult",
"definitions": {
"AgentTestRunCommandResult": {
"anyOf": [
{
"$ref": "#/definitions/AgentTestRunResult"
},
{
"$ref": "#/definitions/ConversationTestRunResult"
}
],
"description": "`--api-name` starts (and with `--wait`, polls) a saved test; `--spec` runs a conversation-level spec without saving."
},
"AgentTestRunResult": {
"anyOf": [
{
Expand Down Expand Up @@ -33,10 +44,7 @@
}
}
},
"required": [
"runId",
"status"
]
"required": ["runId", "status"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to the Trust Agent note: most of this file is a formatting change. Regenerating it without the reflow would shrink the diff down to the new ConversationTestRunResult.

},
{
"type": "object",
Expand Down Expand Up @@ -67,13 +75,7 @@
}
}
},
"required": [
"runId",
"startTime",
"status",
"subjectName",
"testCases"
]
"required": ["runId", "startTime", "status", "subjectName", "testCases"]
},
{
"type": "object",
Expand All @@ -93,23 +95,13 @@
}
}
},
"required": [
"runId",
"status",
"testCases"
]
"required": ["runId", "status", "testCases"]
}
]
},
"TestStatus": {
"type": "string",
"enum": [
"NEW",
"IN_PROGRESS",
"COMPLETED",
"ERROR",
"TERMINATED"
]
"enum": ["NEW", "IN_PROGRESS", "COMPLETED", "ERROR", "TERMINATED"]
},
"TestCaseResult": {
"type": "object",
Expand All @@ -130,9 +122,7 @@
"type": "string"
}
},
"required": [
"utterance"
],
"required": ["utterance"],
"additionalProperties": false
},
"generatedData": {
Expand All @@ -157,13 +147,7 @@
"type": "string"
}
},
"required": [
"actionsSequence",
"invokedActions",
"sessionId",
"outcome",
"topic"
],
"required": ["actionsSequence", "invokedActions", "sessionId", "outcome", "topic"],
"additionalProperties": false
},
"testResults": {
Expand All @@ -184,22 +168,12 @@
"type": "number"
},
"result": {
"type": [
"null",
"string"
],
"enum": [
null,
"PASS",
"FAILURE"
]
"type": ["null", "string"],
"enum": [null, "PASS", "FAILURE"]
},
"metricLabel": {
"type": "string",
"enum": [
"Accuracy",
"Precision"
]
"enum": ["Accuracy", "Precision"]
},
"metricExplainability": {
"type": "string"
Expand Down Expand Up @@ -238,14 +212,7 @@
"type": "number"
}
},
"required": [
"status",
"startTime",
"inputs",
"generatedData",
"testResults",
"testNumber"
],
"required": ["status", "startTime", "inputs", "generatedData", "testResults", "testNumber"],
"additionalProperties": false
},
"AgentforceStudioTestCaseResult": {
Expand All @@ -264,11 +231,7 @@
}
}
},
"required": [
"subjectResponse",
"testNumber",
"testScorerResults"
],
"required": ["subjectResponse", "testNumber", "testScorerResults"],
"additionalProperties": false
},
"TestScorerResult": {
Expand All @@ -281,11 +244,105 @@
"type": "string"
}
},
"required": [
"scorerName",
"scorerResponse"
],
"required": ["scorerName", "scorerResponse"],
"additionalProperties": false
},
"ConversationTestRunResult": {
"type": "object",
"additionalProperties": false,
"properties": {
"status": {
"type": "string",
"const": "COMPLETED"
},
"testScope": {
"type": "string",
"const": "CONVERSATION_LEVEL"
},
"runStatus": {
"type": "string",
"description": "The server's run status: `Completed` or `Failed`."
},
"errorRepresentation": {
"type": "object",
"properties": {
"errorCode": {
"type": "string"
},
"errorMessage": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
},
"additionalProperties": false
},
"summary": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"not": {}
},
{
"type": "number"
}
]
},
"properties": {
"totalNumberOfTestCases": {
"type": "number"
},
"taskResolutionPassPercent": {
"type": "number"
},
"acceptanceCriteriaPassPercent": {
"type": "number"
}
},
"description": "Omitted until the run is complete."
},
"testCases": {
"type": "array",
"items": {
"$ref": "#/definitions/ConversationTestCaseResult"
}
}
},
"required": ["runStatus", "status", "testCases", "testScope"],
"description": "`agent test run --spec` result: a conversation-level run without saving a suite."
},
"ConversationTestCaseResult": {
"type": "object",
"properties": {
"testNumber": {
"type": "number",
"description": "The 1-based `number` sent in the request."
},
"subjectResponse": {
"type": "string",
"description": "JSON string: the simulated conversation (turns, topics, actions, completion reason)."
},
"testScorerResults": {
"type": "array",
"items": {
"type": "object",
"properties": {
"scorerName": {
"type": "string"
},
"scorerResponse": {
"type": "string"
}
},
"required": ["scorerName"],
"additionalProperties": false
}
}
},
"required": ["testNumber"],
"additionalProperties": false
}
}
}
}
Loading
Loading