Test an Agent with Agentforce DX
Testing an agent entails sending it questions, statements, or commands (utterances) and then making sure 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, and 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. - Customize the generated YAML test spec file. Add more testing items to the test spec file, such as setting context variables and including out-of-the-box metrics in the test output.
- 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 the VS Code agent testing panel to view and run the tests. - If your tests all pass, then you’re all set! But if tests fail, use the conversation preview panel in the development org's Agentforce 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've 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 make sure that your agent continues to work correctly in the future.