Sub topic 3
Running an Agentforce Test Suite
Assume you know Agentforce topics and actions, can read YAML, and have a Salesforce org with Testing Center enabled. A test suite checks whether an agent routes requests correctly, invokes the intended actions, and produces an acceptable result.
Run the suite and read results
In Testing Center, select a test suite and run it against the target agent version. Review each case, not only the overall pass rate. A result usually shows:
- The utterance that was tested.
- The topic selected by the agent.
- The actions that ran.
- The response or outcome.
- Which expectation failed.
A case can fail even when the final response sounds reasonable. For example, the agent might answer correctly but select the wrong topic or skip a required action.
flowchart TD
A[Run test suite] --> B[Review each case]
B --> C{What failed?}
C -->|Topic| D[Check routing and topic descriptions]
C -->|Action| E[Check action inputs and instructions]
C -->|Outcome| F[Check response requirements]
D --> G[Update agent or test]
E --> G
F --> Gcaption: Test result diagnosis flow alt: A flowchart from running a suite to checking topic, action, or outcome failures and updating the agent or test.
Diagnose failures
First compare the test utterance with the agent transcript. Then decide whether the agent or the test is wrong.
- The agent is likely wrong when the utterance clearly belongs to the expected topic, but routing or action behavior is incorrect.
- The test may be wrong when the expected topic is ambiguous, the action is optional, or the expected outcome demands wording rather than behavior.
- An environment problem may cause failures when required data, permissions, or connected services differ between runs.
Record the failure reason before changing the test. Otherwise, weakening an assertion can hide a real regression.
> callout warning > Keep expected outcomes observable. Test that the agent confirms an order status, rather than requiring one exact sentence.
Use Salesforce CLI
A YAML specification makes the suite repeatable and reviewable in source control.
name: Order_Support_Agent_Tests
description: Core routing and action checks
subjectType: AGENT
subjectName: Order_Support_Agent
testCases:
- utterance: Where is my order 1001?
expectedTopic: Order_Status
expectedActions:
- Get_Order_Status
expectedOutcome: The agent tells the customer the current status.Create and run the suite with Salesforce CLI:
sf agent test create --spec specs/order-support-tests.yaml --api-name Order_Support_Agent_Tests --target-org my-org
sf agent test run --api-name Order_Support_Agent_Tests --wait 10 --result-format human --target-org my-org
sf agent test results --job-id <JOB_ID> --result-format json --target-org my-orgHandle variation and regression
Agent responses can vary because language models may choose different valid wording or action paths. Prefer stable assertions about topics, required actions, and business outcomes. Avoid tests that depend on punctuation or one exact phrase.
Include normal requests, missing or unusual inputs, boundary cases, and out-of-scope requests. Keep the suite when you change topics, actions, or instructions. Run it before release and in automation after agent changes. Investigate failures instead of automatically updating expected results.
Exercise
A test expects Order_Status, but the agent selects Refunds and gives a plausible answer. Should you mark the test as passed?
Show answer
No. Review the routing and topic descriptions. The incorrect topic can cause failures on later requests even if this response appears plausible.