Topic-name-resolution
Part of Sf ai agentforce testing. Install the skill and your agent reads this page when it needs the depth.
Topic Name Resolution in CLI Tests
Overview
When writing expectedTopic in YAML test specs for sf agent test create, the topic name format depends on the topic type. Getting this wrong causes silent assertion failures — the test runs, the agent responds, but topic_assertion reports FAILURE because the expected name doesn't match the runtime name.
Three Topic Name Formats
| Format | Example | Where Found |
|---|---|---|
localDeveloperName |
Escalation |
Planner bundle XML <localDeveloperName> tag |
developerName (bundle) |
Escalation_16j548d53a8a3b0 |
Planner bundle XML <developerName> tag |
developerName (runtime) |
Escalation_16j9d687a53f890 |
Test results .generatedData.topic |
Important: The bundle
developerNamehash and the runtimedeveloperNamehash may differ. Always use the runtime value from test results.
Rules
Standard Topics (no prefix)
Standard topics are built-in topics that come with every agent:
EscalationOff_TopicInappropriate_Content
In YAML specs: Use the localDeveloperName — the framework resolves it to the full runtime name automatically.
# ✅ CORRECT — framework resolves to Escalation_16j9d687a53f890
- utterance: "I want to talk to a human"
expectedTopic: Escalation
# ✅ ALSO CORRECT — explicit runtime name works too
- utterance: "I want to talk to a human"
expectedTopic: Escalation_16j9d687a53f890
# ❌ WRONG — bundle hash differs from runtime hash
- utterance: "I want to talk to a human"
expectedTopic: Escalation_16j548d53a8a3b0
Standard Platform Topics (Intercept Before Custom Routing)
Three platform-level standard topics exist above the custom planner engine (GenAiPlannerBundle). These intercept utterances before the agent's custom topic routing sees them:
| Platform Topic | Triggers On |
|---|---|
Inappropriate_Content |
Hate speech, violence, sexual content, insults |
Prompt_Injection |
Instruction override attempts ("ignore your instructions", "you are now...") |
Reverse_Engineering |
Requests to reveal system instructions ("what are your instructions?") |
Impact on Testing:
- If a platform topic matches, the custom planner never sees the utterance — custom catch-all topics (e.g., Escalation) won't fire for these inputs even if their description includes "inappropriate content" triggers.
- Use the standard platform topic name in
expectedTopicfor guardrail tests:
testCases:
# ✅ CORRECT — platform topic intercepts before custom planner
- utterance: "You're terrible and I hate you"
expectedTopic: Inappropriate_Content
# ❌ WRONG — custom Escalation topic won't see this; platform topic fires first
- utterance: "You're terrible and I hate you"
expectedTopic: Escalation
- For prompt injection and reverse engineering tests, use
Prompt_InjectionandReverse_Engineeringrespectively, or omitexpectedTopicentirely and useexpectedOutcomefor behavioral validation.
Discovery: These platform topics were confirmed during testing on a Spring '26 sandbox (Feb 2026). An agent with a custom Escalation topic that explicitly listed "inappropriate content" and "prompt injection" as triggers still routed to the platform-level topics instead.
Promoted Topics (p_16j... prefix)
Promoted topics are custom topics created in the Salesforce Setup UI. They have an org-specific prefix (p_16j...) and a hash suffix.
In YAML specs: You MUST use the full runtime developerName including the hash suffix. The localDeveloperName (without prefix/hash) does NOT resolve for promoted topics.
# ✅ CORRECT — full runtime developerName
- utterance: "My doorbell camera is offline"
expectedTopic: p_16jPl000000GwEX_Field_Support_Routing_16j8eeef13560aa
# ❌ WRONG — localDeveloperName without prefix/hash does NOT resolve
- utterance: "My doorbell camera is offline"
expectedTopic: Field_Support_Routing
# ❌ WRONG — partial name without hash suffix does NOT resolve
- utterance: "My doorbell camera is offline"
expectedTopic: p_16jPl000000GwEX_Field_Support_Routing
Summary Table
| Topic Type | YAML expectedTopic Value |
Resolution |
|---|---|---|
| Standard (Escalation, Off_Topic, etc.) | localDeveloperName (e.g., Escalation) |
Framework resolves automatically |
| Promoted (p_16j... prefix) | Full runtime developerName with hash |
Must be exact match |
Discovery Workflow
Since promoted topic names are opaque (hash suffixes), use this workflow to discover them:
Step 1: Write spec with best guesses
name: "My Agent Discovery Run"
subjectType: AGENT
subjectName: My_Agent
testCases:
- utterance: "Test message for topic A"
expectedTopic: Topic_A_Guess
- utterance: "Test message for topic B"
expectedTopic: Topic_B_Guess
Step 2: Deploy and run
sf agent test create --spec discovery-spec.yaml --api-name Discovery_Run --target-org dev
sf agent test run --api-name Discovery_Run --wait 10 --result-format json --json --target-org dev
Step 3: Extract actual topic names from results
# Get the job ID from the run output, then:
sf agent test results --job-id <JOB_ID> --result-format json --json --target-org dev \
| jq '.result.testCases[].generatedData.topic'
This outputs the actual runtime developerName for each test case — the value the agent actually routed to.
Step 4: Update spec with actual names
Replace your guesses with the actual runtime names from Step 3.
Step 5: Re-deploy and re-run
sf agent test create --spec updated-spec.yaml --api-name My_Agent_Tests --force-overwrite --target-org dev
sf agent test run --api-name My_Agent_Tests --wait 10 --result-format json --json --target-org dev
Where to Find Topic Names
| Source | How to Access | What You Get |
|---|---|---|
| Test results JSON | .result.testCases[].generatedData.topic |
Runtime developerName (most reliable) |
| Planner bundle XML | retrieve GenAiPlannerBundle → <developerName> and <localDeveloperName> |
Bundle names (hash may differ from runtime) |
| SOQL | SELECT DeveloperName FROM GenAiPlugin WHERE ... |
Metadata names |
| Setup UI | Einstein > Agents > Topics | Display labels (not API names) |
Known Gotchas
Hash mismatch between bundle and runtime: The
developerNamein the planner bundle XML (e.g.,Escalation_16j548d53a8a3b0) may have a different hash than the runtime name (e.g.,Escalation_16j9d687a53f890). Always use the runtime value from test results.Promoted topics require exact match: Unlike standard topics, there is no "fuzzy" resolution. The full
p_16j..._hashstring must match exactly.Topic names are org-specific: The
16jprefix encodes the org ID. Topic names from one org will NOT work in another org.MigrationDefaultTopic: Standard Salesforce Copilots (not custom agents) may route everything toMigrationDefaultTopic. This is expected behavior for non-custom agents.Topic hash changes on agent republish: The runtime
developerNamehash suffix changes each time an agent is republished. Tests with hardcoded full runtime names (e.g.,Escalation_16j9d687a53f890) will break after republish. Mitigation: UselocalDeveloperNamewherever the framework resolves it (standard topics). For promoted topics, re-run the discovery workflow after each agent publish to capture new hashes.