# Standard Agent Test Specification Template # Compatible with: sf agent test create --spec --api-name # # Usage: # 1. Replace with actual values # 2. Create: sf agent test create --spec this-file.yaml --api-name --target-org # 3. Run: sf agent test run --api-name --wait 10 --result-format json --target-org # # IMPORTANT: This YAML is parsed by @salesforce/agents — NOT a generic AiEvaluationDefinition format. # Only use the fields documented below. # # NOTE: The Testing Center API uses "topic" terminology. In Agent Script, topics are called # "subagents" (e.g., the `subagent` block). When writing tests, use "topic" to match the API, # but understand that each expectedTopic value maps to a subagent in your .agent file. # Required: Display name for the test (MasterLabel) name: " Standard Tests" # Required: Must be AGENT subjectType: AGENT # Required: Agent BotDefinition DeveloperName (API name) subjectName: testCases: # ═══════════════════════════════════════════════════════════════════ # TOPIC ROUTING TESTS # Verify utterances route to the correct topic # ═══════════════════════════════════════════════════════════════════ - utterance: "User message that should trigger topic 1" expectedTopic: - utterance: "Alternative phrasing for topic 1" expectedTopic: - utterance: "User message that should trigger topic 2" expectedTopic: # ═══════════════════════════════════════════════════════════════════ # ACTION INVOCATION TESTS # Verify actions are invoked (flat list of action name strings) # ═══════════════════════════════════════════════════════════════════ - utterance: "Message that should trigger an action" expectedTopic: expectedActions: - - utterance: "Message for a second action" expectedTopic: expectedActions: - expectedOutcome: "Agent confirms the action and provides relevant details" # ═══════════════════════════════════════════════════════════════════ # CONTEXT VARIABLE TESTS # Pass runtime context to simulate authenticated sessions # ═══════════════════════════════════════════════════════════════════ - utterance: "Show me my account details" expectedTopic: contextVariables: - name: RoutableId value: "" - name: CaseId value: "" # ═══════════════════════════════════════════════════════════════════ # CONVERSATION HISTORY TESTS # Simulate multi-turn conversations (roles: user and agent) # ═══════════════════════════════════════════════════════════════════ - utterance: "Now process the return" expectedTopic: conversationHistory: - role: user message: "I need help with order #12345" - role: agent topic: message: "I found your order. It was delivered on March 1st. How can I help?" expectedActions: - # ═══════════════════════════════════════════════════════════════════ # ESCALATION TESTS # ═══════════════════════════════════════════════════════════════════ - utterance: "I want to talk to a real person" expectedTopic: Escalation # ═══════════════════════════════════════════════════════════════════════ # NOTES — AGENT SCRIPT ACTION TYPES # # Agent Script agents (.agent files / AiAuthoringBundle) have TWO types # of actions that appear in CLI test results: # # 1. TRANSITION ACTIONS (from start_agent reasoning.actions): # - Named: go_ # - Target: @utils.transition to @subagent. # - Captured by single-utterance tests # # 2. BUSINESS ACTIONS (from subagent.actions + reasoning.actions): # - Named: (Level 1 from subagent.actions block) # - Target: apex://ClassName or flow://FlowName # - May require conversationHistory to reach in multi-subagent agents # # Use expectedActions with the DEFINITION name (Level 1), not the # invocation name (Level 2). E.g., use get_order_status, not check_status. # ═══════════════════════════════════════════════════════════════════════ # ═══════════════════════════════════════════════════════════════════════ # NOTES — TOPIC NAME RESOLUTION # # The expectedTopic value depends on the topic type: # # Standard topics (Escalation, Off_Topic, etc.): # Use localDeveloperName: "Escalation" # # Promoted topics (created in Setup UI, prefixed with p_16j...): # MUST use the full runtime developerName with hash suffix # # To discover actual topic names: # 1. Run one test with a guess # 2. Check results JSON: .testCases[].generatedData.topic # 3. Update expectedTopic with the actual value # ═══════════════════════════════════════════════════════════════════════