
Testing Agentforce
Bootstrap Salesforce Agentforce evaluation YAML for topic routing tests and run them with sf agent test create and sf agent test run.
Overview
testing-agentforce is an agent skill for the Ship phase that provides a Salesforce Agentforce basic-test-spec.yaml template for topic routing tests via sf agent test create and sf agent test run.
Install
npx skills add https://github.com/forcedotcom/afv-library --skill testing-agentforceWhat is this skill?
- basic-test-spec.yaml compatible with sf agent test create --spec
- Documents Salesforce @salesforce/agents fields only—warns against generic AiEvaluationDefinition extras
- Topic routing testCases with utterance and expectedTopic (maps to subagents in .agent files)
- CLI run path: sf agent test run --wait 10 --result-format json
- Inline usage comments for target-org and api-name placeholders
- Documents sf agent test run with --wait 10 and --result-format json
- Includes dedicated topic routing testCases section in the template
Adoption & trust: 1.3k installs on skills.sh; 513 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have an Agentforce bot but no valid @salesforce/agents test spec, and generic evaluation YAML shapes fail deploy or do not assert correct topic routing.
Who is it for?
Solo builders on Salesforce Agent Script who already have an agent API name and org alias and need routing regression tests.
Skip if: Non-Salesforce agents, teams wanting UI-only manual chat checks, or evals that require unsupported AiEvaluationDefinition fields.
When should I use this skill?
User needs a Basic Test Specification Template for Salesforce Agentforce compatible with sf agent test create and run.
What do I get? / Deliverables
You deploy a named AGENT subject test with utterance/expectedTopic cases and run it in Testing Center JSON format to verify routing against your .agent subagents.
- basic-test-spec.yaml with name, subjectType, subjectName, and testCases
- Deployed and executed Agent test via Testing Center API
Recommended Skills
Journey fit
Agent Script bots need repeatable utterance expectations before production—canonical Ship QA for Salesforce agents. The spec template is built for sf agent test create/run and topic routing test cases, which is automated agent testing—not infra deploy or launch SEO.
How it compares
Salesforce CLI–native Agent test spec template—not a Playwright E2E pack or a generic LLM benchmark harness.
Common Questions / FAQ
Who is testing-agentforce for?
Developers using forcedotcom/afv-library and Salesforce CLI to validate Agentforce topic routing before shipping bot changes.
When should I use testing-agentforce?
In Ship/testing when you need to create and run Agent tests with sf agent test create and sf agent test run after defining utterances and expectedTopic values.
Is testing-agentforce safe to install?
Review the Security Audits panel on this Prism page; running agent tests targets your Salesforce org via CLI and should use least-privilege org aliases.
SKILL.md
READMESKILL.md - Testing Agentforce
# Basic Test Specification Template # Compatible with: sf agent test create --spec <file> --api-name <name> # # Usage: # 1. Replace <placeholders> with actual values # 2. Create: sf agent test create --spec basic-test-spec.yaml --api-name <Test_Name> --target-org <alias> # 3. Run: sf agent test run --api-name <Test_Name> --wait 10 --result-format json --target-org <alias> # # IMPORTANT: This YAML is parsed by @salesforce/agents — NOT a generic AiEvaluationDefinition format. # Only the fields below are recognized. Do NOT add apiVersion, kind, metadata, or settings. # # 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) — deploy FAILS without this name: "<Agent_Name> Basic Tests" # Required: Must be AGENT subjectType: AGENT # Required: Agent BotDefinition DeveloperName (API name) subjectName: <Agent_Name> testCases: # ═══════════════════════════════════════════════════════════════ # TOPIC ROUTING TESTS # Test that user messages route to the correct topic # ═══════════════════════════════════════════════════════════════ - utterance: "<User message that should trigger primary topic>" expectedTopic: <topic_name> - utterance: "<User message that should trigger secondary topic>" expectedTopic: <another_topic_name> # ═══════════════════════════════════════════════════════════════ # ACTION INVOCATION TESTS # expectedActions is a FLAT list of action name strings # ═══════════════════════════════════════════════════════════════ - utterance: "<User message that should trigger action>" expectedTopic: <topic_name> expectedActions: - <action_name> # ═══════════════════════════════════════════════════════════════ # OUTCOME VALIDATION TESTS # expectedOutcome is optional — omitting causes harmless ERROR # in output_validation (test still passes topic/action checks) # ═══════════════════════════════════════════════════════════════ - utterance: "<User message with expected outcome>" expectedTopic: <topic_name> expectedOutcome: "Agent should provide a helpful response about <topic>" # ═══════════════════════════════════════════════════════════════ # ESCALATION TEST # Standard topics like Escalation use localDeveloperName # ═══════════════════════════════════════════════════════════════ - utterance: "I want to talk to a real person" expectedTopic: Escalation # Guardrail and Boundary Test Specification Template # Compatible with: sf agent test create --spec <file> --api-name <name> # # Patterns covered: # 1. Standard platform topics — Inappropriate_Content, Prompt_Injection, Reverse_Engineering # 2. Off-topic deflection — agent should redirect gracefully # 3. Session management — agent should never prematurely end sessions # 4. Auth gate verification (if applicable) — business intents must route to auth first # # Usage: # 1. Replace <placeholders> with actual values # 2. Deploy: sf agent test create --spec guardrail-test-spec.yaml --api-name Guardrail_Tests --target-org <alias> # 3. Run: sf agent test run --api-name Guardrail_Tests --wait 10 --result-format json --target-org <alias> # # 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. name: "<Agent_Name> Guardrail Tests" subjectType: AGENT subjectName: <Agent_Name> testCases: # ═══════════════════════════════════════════════════════════════ # STANDARD PLATFORM TOPIC TESTS # These platform-level topics intercept BEFORE custom planner # routing. The custom planner never sees the utterance.