testing-agentforce

Write, run, and analyze structured test suites for Salesforce Agentforce agents.

1|Updated May 7, 2026
One-click install
npx skills add https://github.com/amanpraaj/sf-skill-hub --skill testing-agentforce-amanpraaj
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: testing-agentforce
Source: https://github.com/amanpraaj/sf-skill-hub/tree/main/skills/salesforce/testing-agentforce
Command: npx skills add https://github.com/amanpraaj/sf-skill-hub --skill testing-agentforce-amanpraaj

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve? Testing Agentforce agents manually is slow and error-prone: you need to verify subagent routing, action invocation, grounding, and safety behavior across many utterances, and the sf CLI output contains quirks like control characters and topic hash drift that break naive automation. This Skill provides structured workflows for ad-hoc preview testing, Testing Center batch suites, and direct action execution with trace-based diagnosis and fix loops. ## Core Features & Use Cases - Ad-Hoc Preview Testing (Mode A): Run smoke tests via sf agent preview with auto-derived utterances from the .agent file, local trace analysis, safety probes, and an iterative fix loop (max 3 iterations). - Testing Center Batch Testing (Mode B): Author test spec YAML, deploy it as an AiEvaluationDefinition with sf agent test create, run regression suites, and parse topic/action/outcome assertions for CI/CD pipelines. - Direct Action Execution: Invoke Flow and Apex actions via the Salesforce REST API with a mandatory safety gate (production org check, DML warning, synthetic data enforcement). - Use Case: After modifying a .agent file, auto-generate a test plan covering every subagent and action, run safety probes against prompt injection, get a SAFE/UNSAFE verdict, and deploy a persistent regression suite for your CI pipeline. ## Quick Start Ask the agent to run a smoke test of your Agentforce agent against your org alias, for example: "Run a preview smoke test of the OrderService agent on my dev org and report routing, action, and safety results."

Frequently Asked Questions about testing-agentforce

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test an Agentforce agent with the sf CLI?▼

Use sf agent preview for quick ad-hoc smoke tests during development, or sf agent test create and sf agent test run to deploy and execute persistent Testing Center suites. Preview mode with --authoring-bundle generates local trace files for detailed diagnosis.

What is the difference between sf agent preview and sf agent test?▼

sf agent preview runs interactive sessions against a local .agent file and produces trace JSON for deep analysis, best for development iteration. sf agent test deploys a YAML spec as an AiEvaluationDefinition to the org and runs structured assertions, best for regression suites and CI/CD.

Why do my expectedActions assertions fail in Testing Center?▼

Testing Center reports Level 2 invocation names from the reasoning: actions: block, not Level 1 definition names from subagent: actions:. Use the invocation name (e.g. check_order) in expectedActions, and remember assertions use superset matching.

Why does jq fail to parse sf agent preview output?▼

The CLI output contains control characters that break jq and json.loads. Sanitize the raw output with Python re.sub to strip control characters before parsing, since tr through bash pipes is unreliable.

How do I handle topic name mismatches in Agentforce test results?▼

Run the test with best-guess names, then read the actual runtime names from generatedData.topic in the results JSON and update the YAML. Note that promoted topic hash suffixes change after each agent republish, so re-run discovery after publishing.

Can I run Agentforce tests in a CI/CD pipeline?▼

Yes, use Mode B Testing Center suites in CI: authenticate the org, deploy the spec with sf agent test create --force-overwrite, run with --result-format junit, and upload results as pipeline artifacts. Exit codes 0-3 signal pass, failure, critical failure, or infrastructure error.