Get Started with Agentforce Testing API

Use the Agentforce Testing API to test agents and prompt templates at two levels: a single request and response (turn-level) or a full multi-turn exchange (conversation-level).

To create and run tests in the Salesforce UI, see Set Up and Run Tests in Agentforce Studio (Beta) in Salesforce Help. This guide covers the metadata and API side.

Why Use Agentforce Testing API 

The Agentforce Testing API improves on the legacy Testing API in several ways. Conversational tests facilitate evaluations against a common goal over the course of an entire conversation. The new resources also cover multi-agent handoff scenarios, prompt template testing, voice agent quality, and custom scorers.

  • Scorers instead of expectations. Each test case lists scorers that grade the response. Built-in scorers cover subagent and action sequence, response quality, and latency.
  • Turn-level and conversation-level tests. Check a single response, or let the service run a whole conversation toward a goal.
  • Agents and prompt templates. Turn-level tests cover both.
  • New results. Results are grouped by scorer for each test case.

Choose Turn-Level or Conversation-Level Testing 

Turn-level and conversation-level tests use different resources, so decide which one you need before you start. You can use both for the same agent.

Turn-levelConversation-level
What a test case checksOne utterance and the agent’s responseA multi-turn exchange between a simulated caller and your agent
Where test cases liveIn an AiTestingDefinition XML file that you deploy to your org and rerunIn the request body. You send the goal, turn limit, and scorers with each run
How you run itConnect API /einstein/ai-testing/runsConnect API /einstein/ai-testing/conversational-test/run
SubjectsAgents and prompt templatesAgents
Custom scorersSupportedSupported
Use it forRegression tests on individual requests, such as the right subagent or actionWorkflows where the agent gathers information across turns, such as a password reset. Also voice agent quality

Metadata API and Connect API are separate. Metadata API holds the AiTestingDefinition type that defines turn-level tests. Connect API runs tests, checks their status, and gets their results.

Compare Legacy and Agentforce Testing API 

Legacy Testing APIAgentforce Testing API
Metadata typeAiEvaluationDefinition (v63.0+)AiTestingDefinition (v66.0+)
Test case checkexpectationscorer
Connect API resource/einstein/ai-evaluations/runs/einstein/ai-testing/runs
Start request fieldaiEvaluationDefinitionNametestDefinitionName
Status valuesNEW, IN_PROGRESS, COMPLETED, ERROR, TERMINATEDCREATED, IN_PROGRESS, SUCCESS, FAILED, TERMINATED
ResultstestCases[].testResults[]testCases[].testScorerResults[]
CLI--test-runner testing-center--test-runner agentforce-studio

The CLI row and the status values apply to turn-level tests.

Prerequisites 

  • An org with Agentforce enabled and at least one active agent.
  • For turn-level tests, API version 66.0 or later.
  • A user with the AI Testing User and AI Workbench User permissions. See User Permissions.
  • To call the Connect API, an external client app and an access token. See Set Up Authentication for Testing API.

See Also