agentforce-test

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

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/padjei/SF_Build --skill agentforce-test-padjei
Or copy as Structured Prompt for Agentā–¼
Please help me install this Agent Skill.
Skill: agentforce-test
Source: https://github.com/padjei/SF_Build/tree/main/.claude/skills/agentforce-test
Command: npx skills add https://github.com/padjei/SF_Build --skill agentforce-test-padjei

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 must verify subagent routing, action invocation, grounding, and safety behavior across many utterances, then diagnose failures from raw execution traces. This Skill automates that entire loop using the Salesforce CLI. ## Core Features & Use Cases - Ad-hoc preview testing (Mode A): Run quick smoke tests against a local .agent authoring bundle with sf agent preview, then analyze local trace files for routing, grounding, safety scores, and variable updates. - Testing Center batch testing (Mode B): Author YAML test specs, deploy them as AiEvaluationDefinition metadata with sf agent test create, run suites, and parse pass/fail results for topic, action, and outcome assertions. - 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). - Iterative fix loop: Diagnose failures (TOPIC_NOT_MATCHED, UNGROUNDED, LOW_SAFETY, etc.) from traces and apply targeted fixes to the .agent file, up to 3 iterations. - Use Case: After building an order-management agent, auto-derive a test plan from its subagents, run safety probes (prompt injection, PII handling), get a SAFE/UNSAFE verdict, and deploy a regression suite for CI/CD. ## Quick Start Ask the assistant to run a smoke test of your Agentforce agent against a specific org alias using its authoring bundle, and review the auto-generated test plan before execution.

Frequently Asked Questions about agentforce-test

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

FAQPage Schema
How do I test a Salesforce Agentforce agent with the sf CLI?ā–¼

Use sf agent preview for quick smoke tests against a local authoring bundle, or sf agent test create and sf agent test run to deploy and execute persistent Testing Center suites. This Skill automates both modes, including utterance derivation, trace analysis, and result parsing.

How do I write a test spec YAML for Agentforce Testing Center?ā–¼

Create a YAML file with name, subjectType AGENT, subjectName set to the agent's BotDefinition API name, and a testCases array. Each case takes an utterance plus optional expectedTopic, expectedActions (flat list of Level 2 invocation names), and expectedOutcome for LLM-as-judge validation.

Why do my Agentforce action assertions fail even when the action runs?ā–¼

Testing Center reports Level 2 invocation names from the reasoning: actions: block, not Level 1 definition names from subagent: actions:. Using Level 1 names in expectedActions causes failures even when the agent behaves correctly.

Why is my sf agent preview trace file empty or unparsable?ā–¼

Empty traces usually mean the sf CLI is older than 2.121.7, and jq parse errors come from control characters in CLI output. Strip control characters with a Python re.sub before json.loads, or fall back to transcript.jsonl or Mode B Testing Center.

Can I run Agentforce tests in a CI/CD pipeline?ā–¼

Yes. Deploy the suite with sf agent test create --force-overwrite, run it with sf agent test run --result-format junit, and upload the results as pipeline artifacts. Exit codes 0-3 signal pass, failure, critical failure, or infrastructure error.

Is it safe to execute Flow or Apex actions directly against an org?ā–¼

The Skill enforces a safety gate first: it checks IsSandbox to warn on production orgs, flags actions performing DML writes, and requires synthetic test data instead of real PII before executing any REST API action call.