Test an Agent with Agentforce DX
Testing an agent entails sending it questions, statements, or commands (utterances) and then ensuring that the agent behaves as you expected when it responds.
Using Agentforce DX to test an agent is the pro-code equivalent of using the Agentforce Testing Center UI in your development org. As with any software development, testing an agent is an iterative process; here’s the general flow, later sections of this guide go into details about some steps:
- Generate a test spec for your agent with the
agent generate test-spec
CLI command. A test spec is a local YAML file that describes one or more test cases for your agent. - Create the agent test in your development org with the
agent test create
command, passing it the test spec file. This command also automatically syncs the associated metadata back to your DX project. - Run the agent tests in your development org and view the results with the
agent test run
command. You can also use VS Code’s agent testing panel to view and run the tests. - If your tests all pass, then you’re golden! But if tests fail, use the conversation preview panel in the development org's Agent Builder UI to talk to the active agent and test the words and responses in a conversational way. Then use the information to fine-tune your agent instructions, actions, or topics.
- Iterate as needed over the preceding steps until you have perfected your set of agent tests. Then use the test results to update your agent to work correctly.
- Add the tests to a continuous integration (CI) system to ensure that your agent continues to work correctly in the future.
- Salesforce CLI Command Reference: agent Commands
- Salesforce Extensions for Visual Studio Code
- Salesforce Help: Agentforce Testing Center
- Testing API Developer Guide