@salesforce/afv-skills 1.6.9 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/developing-agentforce/README.md +112 -0
- package/skills/{agentforce-development → developing-agentforce}/SKILL.md +109 -16
- package/skills/{agentforce-development → developing-agentforce}/assets/agents/README.md +2 -2
- package/skills/developing-agentforce/assets/agents/order-service.agent +272 -0
- package/skills/developing-agentforce/assets/agents/verification-gate.agent +280 -0
- package/skills/{agentforce-development → developing-agentforce}/assets/bundle-meta.xml +1 -1
- package/skills/{agentforce-development → developing-agentforce}/references/actions-reference.md +20 -0
- package/skills/{agentforce-development → developing-agentforce}/references/agent-design-and-spec-creation.md +1 -1
- package/skills/{agentforce-development → developing-agentforce}/references/agent-metadata-and-lifecycle.md +3 -3
- package/skills/{agentforce-development → developing-agentforce}/references/agent-script-core-language.md +40 -3
- package/skills/{agentforce-development → developing-agentforce}/references/agent-user-setup.md +60 -57
- package/skills/{agentforce-development → developing-agentforce}/references/agent-validation-and-debugging.md +22 -20
- package/skills/developing-agentforce/references/architecture-patterns.md +158 -0
- package/skills/developing-agentforce/references/complex-data-types.md +57 -0
- package/skills/developing-agentforce/references/deploy-reference.md +134 -0
- package/skills/developing-agentforce/references/discover-reference.md +102 -0
- package/skills/developing-agentforce/references/examples.md +350 -0
- package/skills/developing-agentforce/references/feature-validity.md +43 -0
- package/skills/developing-agentforce/references/instruction-resolution.md +545 -0
- package/skills/{agentforce-development → developing-agentforce}/references/known-issues.md +18 -18
- package/skills/{agentforce-development → developing-agentforce}/references/production-gotchas.md +24 -3
- package/skills/developing-agentforce/references/safety-review-reference.md +145 -0
- package/skills/{agentforce-development → developing-agentforce}/references/salesforce-cli-for-agents.md +9 -7
- package/skills/developing-agentforce/references/scaffold-reference.md +153 -0
- package/skills/developing-agentforce/references/scoring-rubric.md +24 -0
- package/skills/{agentforce-development → developing-agentforce}/references/version-history.md +2 -2
- package/skills/observing-agentforce/SKILL.md +368 -0
- package/skills/observing-agentforce/apex/AgentforceOptimizeService.cls +1262 -0
- package/skills/observing-agentforce/apex/AgentforceOptimizeService.cls-meta.xml +5 -0
- package/skills/observing-agentforce/references/improve-reference.md +359 -0
- package/skills/observing-agentforce/references/issue-classification.md +220 -0
- package/skills/observing-agentforce/references/reproduce-reference.md +131 -0
- package/skills/observing-agentforce/references/stdm-queries.md +381 -0
- package/skills/observing-agentforce/references/stdm-schema.md +189 -0
- package/skills/testing-agentforce/SKILL.md +335 -0
- package/skills/testing-agentforce/assets/basic-test-spec.yaml +59 -0
- package/skills/testing-agentforce/assets/guardrail-test-spec.yaml +101 -0
- package/skills/testing-agentforce/assets/standard-test-spec.yaml +123 -0
- package/skills/testing-agentforce/references/action-execution.md +241 -0
- package/skills/testing-agentforce/references/batch-testing.md +274 -0
- package/skills/testing-agentforce/references/preview-testing.md +353 -0
- package/skills/testing-agentforce/references/test-report-format.md +160 -0
- package/skills/testing-agentforce/references/troubleshooting.md +73 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/README-legacy.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agent-spec-template.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/hello-world.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/multi-topic.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/production-faq.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/production-faq.bundle-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/simple-qa.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/apex/models-api-queueable.cls +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/apex-action.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/error-handling.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/escalation-setup.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/flow-action.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/n-ary-conditions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/topic-with-actions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/deterministic-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/escalation-pattern.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/flow-action-lookup.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/hub-and-spoke.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/invocable-apex-template.cls +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/local-info-agent-annotated.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/genai-function-apex.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/genai-function-flow.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/genai-plugin.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/http-callout-flow.flow-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/minimal-starter.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/README.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/action-callbacks.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/advanced-input-bindings.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/bidirectional-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/critical-input-collection.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/delegation-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/lifecycle-events.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/llm-controlled-actions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/multi-step-workflow.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/open-gate-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/procedural-instructions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/prompt-template-action.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/system-instruction-overrides.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/prompt-rag-search.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/template-multi-topic.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/template-single-topic.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/verification-gate.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/action-prompt-templates.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/agent-access-guide.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/agent-topic-map-diagrams.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/minimal-examples.md +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Agentforce Development Skill
|
|
2
|
+
|
|
3
|
+
A Claude Code skill for building, modifying, debugging, and deploying Agentforce agents using Agent Script — Salesforce's scripting language for next-generation AI agents on the Atlas Reasoning Engine.
|
|
4
|
+
|
|
5
|
+
## What This Skill Does
|
|
6
|
+
|
|
7
|
+
Agent Script was introduced in 2025 with zero training data in any AI model. This skill bridges that gap by providing structured reference material, design patterns, CLI workflows, and debugging guidance so that AI coding assistants can work with Agent Script accurately.
|
|
8
|
+
|
|
9
|
+
The skill covers the full Agent Script lifecycle:
|
|
10
|
+
|
|
11
|
+
| Domain | What It Handles |
|
|
12
|
+
|--------|----------------|
|
|
13
|
+
| Create an Agent | Agent Spec design, environment validation, bundle generation, code authoring |
|
|
14
|
+
| Modify an Agent | Topic/action changes, instruction refinement, flow control updates |
|
|
15
|
+
| Create or Modify Backing Logic | Invocable Apex stubs, Flow wrappers, Prompt Templates |
|
|
16
|
+
| Deploy and Publish | Source deploy, agent activation, publishing to channels |
|
|
17
|
+
| Diagnose Compilation Errors | Compiler error interpretation, syntax fixes, metadata resolution |
|
|
18
|
+
| Diagnose Behavioral Issues | Trace-based debugging, topic routing, action I/O analysis |
|
|
19
|
+
| Diagnose Production Issues | Runtime failures, reserved keyword conflicts, deployment gotchas |
|
|
20
|
+
| Test an Agent | Utterance-based validation, preview with live actions, trace analysis |
|
|
21
|
+
| Generate Diagrams | Topic map visualizations, agent architecture diagrams |
|
|
22
|
+
|
|
23
|
+
## Skill Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
developing-agentforce/
|
|
27
|
+
├── SKILL.md # Router — maps user intent to task domains and reference files
|
|
28
|
+
├── references/ # Domain knowledge (14 files)
|
|
29
|
+
│ ├── agent-script-core-language.md
|
|
30
|
+
│ ├── agent-design-and-spec-creation.md
|
|
31
|
+
│ ├── agent-validation-and-debugging.md
|
|
32
|
+
│ ├── salesforce-cli-for-agents.md
|
|
33
|
+
│ ├── agent-metadata-and-lifecycle.md
|
|
34
|
+
│ ├── agent-access-guide.md
|
|
35
|
+
│ ├── agent-user-setup.md
|
|
36
|
+
│ ├── actions-reference.md
|
|
37
|
+
│ ├── action-prompt-templates.md
|
|
38
|
+
│ ├── agent-topic-map-diagrams.md
|
|
39
|
+
│ ├── minimal-examples.md
|
|
40
|
+
│ ├── known-issues.md
|
|
41
|
+
│ ├── production-gotchas.md
|
|
42
|
+
│ └── version-history.md
|
|
43
|
+
├── assets/ # Templates, examples, and starter agents
|
|
44
|
+
│ ├── agent-spec-template.md
|
|
45
|
+
│ ├── invocable-apex-template.cls
|
|
46
|
+
│ ├── bundle-meta.xml
|
|
47
|
+
│ ├── patterns/ # Reusable Agent Script patterns
|
|
48
|
+
│ ├── agents/ # Annotated example agents
|
|
49
|
+
│ ├── apex/ # Apex backing logic examples
|
|
50
|
+
│ ├── components/ # LWC components for agent channels
|
|
51
|
+
│ ├── metadata/ # Metadata templates
|
|
52
|
+
│ └── *.agent # Starter agent templates
|
|
53
|
+
└── staging/ # Unmerged reference material awaiting review
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## How It Works
|
|
57
|
+
|
|
58
|
+
SKILL.md acts as a router. It detects user intent from task descriptions, maps to a task domain, and instructs the AI assistant to read the relevant reference files before starting work. Reference files are loaded on demand — the assistant only reads what the current task requires.
|
|
59
|
+
|
|
60
|
+
Three rules apply across all domains:
|
|
61
|
+
|
|
62
|
+
1. **Always `--json`** on every `sf` CLI command
|
|
63
|
+
2. **Diagnose before you fix** — preview with live actions and read traces before modifying code
|
|
64
|
+
3. **Spec approval is a hard gate** — never proceed past Agent Spec creation without user approval
|
|
65
|
+
|
|
66
|
+
## Prerequisites
|
|
67
|
+
|
|
68
|
+
- Salesforce org with Agentforce license
|
|
69
|
+
- API version 66.0+ (Spring '26)
|
|
70
|
+
- Einstein Agent User (for service agents)
|
|
71
|
+
- Salesforce CLI v2.x (`sf` command)
|
|
72
|
+
- Claude Code (or compatible AI coding agent)
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
Copy the `developing-agentforce` folder into your project's `.claude/skills/` directory:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
your-project/
|
|
80
|
+
└── .claude/
|
|
81
|
+
└── skills/
|
|
82
|
+
└── developing-agentforce/
|
|
83
|
+
├── SKILL.md
|
|
84
|
+
├── references/
|
|
85
|
+
└── assets/
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Restart Claude Code after installation.
|
|
89
|
+
|
|
90
|
+
## Version
|
|
91
|
+
|
|
92
|
+
Current version: **0.4.9** (2026-03-20). See [references/version-history.md](references/version-history.md) for the full changelog.
|
|
93
|
+
|
|
94
|
+
## Credits
|
|
95
|
+
|
|
96
|
+
This skill integrates knowledge from the following sources:
|
|
97
|
+
|
|
98
|
+
**Jag Valaiyapathy** ([sf-skills](https://github.com/Jaganpro/sf-skills), MIT License)
|
|
99
|
+
— Known issues catalog, production gotchas, agent access and permissions guide, and deployment patterns. Integrated starting in v0.4.2.
|
|
100
|
+
|
|
101
|
+
**Hua Xu** (Salesforce APAC FDE team)
|
|
102
|
+
— Open-gate routing pattern from Kogan agent deployment.
|
|
103
|
+
|
|
104
|
+
**Salesforce DevRel** ([agent-script-recipes](https://github.com/trailheadapps/agent-script-recipes))
|
|
105
|
+
— Canonical Agent Script examples used as grounding material.
|
|
106
|
+
|
|
107
|
+
**Dylan Zeigler, AI Platform** (llm-utils)
|
|
108
|
+
— Agent Script playground used as reference source.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
Apache-2.0
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: agentforce
|
|
3
|
-
description: "
|
|
2
|
+
name: developing-agentforce
|
|
3
|
+
description: "Build, modify, debug, and deploy agents with Agentforce Agent Script. TRIGGER when: user creates, modifies, or asks about .agent files or aiAuthoringBundle metadata; changes agent behavior, responses, or conversation logic; designs agent topics, actions, tools, sub-agents, or flow control; writes or reviews an Agent Spec; previews, debugs, deploys, publishes, or tests agents; uses Agent Script CLI commands (sf agent generate/preview/publish/test). DO NOT TRIGGER when: Apex development, Flow building, Prompt Template authoring, Experience Cloud configuration, or general Salesforce CLI tasks unrelated to Agent Script."
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
compatibility: "Requires Agentforce license, API v66.0+, Einstein Agent User"
|
|
6
6
|
metadata:
|
|
7
|
-
version: "0.
|
|
8
|
-
last_updated: "2026-
|
|
7
|
+
version: "0.5.1"
|
|
8
|
+
last_updated: "2026-04-08"
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
# Agent Script Skill
|
|
@@ -32,9 +32,11 @@ Identify user intent from task descriptions. ALWAYS read indicated reference fil
|
|
|
32
32
|
|
|
33
33
|
## Rules That Always Apply
|
|
34
34
|
|
|
35
|
-
1. **Always `--json`.** ALWAYS include `--json` on EVERY `sf` CLI command.
|
|
35
|
+
1. **Always `--json`.** ALWAYS include `--json` on EVERY `sf` CLI command. Do NOT pipe CLI output through `jq` or `2>/dev/null`. Read the full JSON response directly — LLMs parse JSON natively.
|
|
36
36
|
|
|
37
|
-
2. **
|
|
37
|
+
2. **Verify target org.** Before any org interaction, run `sf config get target-org --json` to confirm a target org is set. If none configured, ask the user to set one with `sf config set target-org <alias>`.
|
|
38
|
+
|
|
39
|
+
3. **Diagnose before you fix.** When validating/debugging agent behavior,
|
|
38
40
|
ALWAYS `--use-live-actions` to preview authoring bundles. Send utterances
|
|
39
41
|
then read resulting session traces to ground your understanding of the
|
|
40
42
|
agent's behavior. Trace files reveal topic selection, action I/O, and
|
|
@@ -42,7 +44,7 @@ Identify user intent from task descriptions. ALWAYS read indicated reference fil
|
|
|
42
44
|
this grounding. See [Validation & Debugging](references/agent-validation-and-debugging.md)
|
|
43
45
|
for trace file locations and diagnostic patterns.
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
4. **Spec approval is a hard gate.** Never proceed past Agent Spec
|
|
46
48
|
creation without explicit user approval.
|
|
47
49
|
|
|
48
50
|
## Task Domains
|
|
@@ -57,10 +59,10 @@ User wants to build new agent from scratch. ALWAYS use Agent Script. Work with U
|
|
|
57
59
|
|
|
58
60
|
Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
|
|
59
61
|
|
|
60
|
-
1. **Design** — Read [Design & Agent Spec](references/agent-design-and-spec-creation.md) to draft an Agent Spec. Always ask if you should scan for existing backing logic. Unless instructed otherwise, scan by reading `sfdx-project.json` to identify package directories, then search each for `@InvocableMethod` in `classes/`, `AutoLaunchedFlow` in `flows/`, and template metadata in `promptTemplates/`. Mark matches `EXISTS`; unmatched actions `NEEDS STUB`. **Always save Agent Spec as file.**
|
|
62
|
+
1. **Design** — Read [Design & Agent Spec](references/agent-design-and-spec-creation.md) to draft an Agent Spec. Always ask if you should scan for existing backing logic. Unless instructed otherwise, scan by reading `sfdx-project.json` to identify package directories, then search each for `@InvocableMethod` in `classes/`, `AutoLaunchedFlow` in `flows/`, and template metadata in `promptTemplates/`. Mark matches `EXISTS`; unmatched actions `NEEDS STUB`. Also scan `objects/` for `.object-meta.xml` to discover custom objects — related objects often contain data the agent should expose even when not mentioned in the prompt. **Always save Agent Spec as file.**
|
|
61
63
|
2. **STOP for user approval of Agent Spec.** Present to user. Ask for approval or feedback. **Do not proceed** without approval. Once approved, proceed without stopping unless a step fails.
|
|
62
64
|
3. **Validate environment prerequisites** — Read [Design & Agent Spec](references/agent-design-and-spec-creation.md), Section 3 (Environment Prerequisites). Based on agent type from design, validate org environment:
|
|
63
|
-
- **Employee agent**: Confirm config block does NOT include `default_agent_user
|
|
65
|
+
- **Employee agent**: Confirm config block does NOT include `default_agent_user`, `connection messaging:`, or MessagingSession linked variables. Remove if present. See [Examples](references/examples.md) for a complete employee agent example.
|
|
64
66
|
- **Service agent**: Query org for Einstein Agent User. If one exists, confirm username with user. If none, guide user through creation. See [CLI for Agents](references/salesforce-cli-for-agents.md), Section 12 for creation steps and [Agent User Setup](references/agent-user-setup.md) for required permissions.
|
|
65
67
|
**Do not proceed to code generation until environment is validated.**
|
|
66
68
|
4. **Generate authoring bundle** —
|
|
@@ -81,7 +83,12 @@ Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command
|
|
|
81
83
|
Send test utterances with:
|
|
82
84
|
`sf agent preview send --json --authoring-bundle <Developer_Name> --session-id <ID> -u "<message>"`
|
|
83
85
|
Confirm topic routing, gating, and action invocations match Agent Spec. If behavior diverges, switch to **Diagnose Behavioral Issues** workflow. Return AFTER correcting issues.
|
|
84
|
-
|
|
86
|
+
**CHECKPOINT — Do NOT proceed to Publish unless ALL are true:**
|
|
87
|
+
- `validate authoring-bundle` passes with zero errors
|
|
88
|
+
- Live preview (`--use-live-actions`) tested with representative utterances per topic
|
|
89
|
+
- Traces confirm correct topic routing and action invocation
|
|
90
|
+
- User explicitly approves deployment
|
|
91
|
+
9. **Publish** — Publish validates metadata structure, not agent behavior. Every publish creates permanent version number.
|
|
85
92
|
`sf agent publish authoring-bundle --json --api-name <Developer_Name>`
|
|
86
93
|
If publish fails, follow troubleshooting checklist in [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md), Section 5 before retrying.
|
|
87
94
|
10. **Activate** — Makes new version available to users.
|
|
@@ -113,6 +120,12 @@ Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command
|
|
|
113
120
|
access permissions, visibility troubleshooting
|
|
114
121
|
9. [Known Issues](references/known-issues.md) — only load when errors
|
|
115
122
|
persist after code fixes
|
|
123
|
+
10. [Architecture Patterns](references/architecture-patterns.md) — hub-and-spoke, verification gate, post-action loop
|
|
124
|
+
11. [Complex Data Types](references/complex-data-types.md) — type mapping decision tree
|
|
125
|
+
12. [Safety Review](references/safety-review-reference.md) — 7-category safety review
|
|
126
|
+
13. [Discover Reference](references/discover-reference.md) — target discovery CLI
|
|
127
|
+
14. [Scaffold Reference](references/scaffold-reference.md) — stub generation CLI
|
|
128
|
+
15. [Deploy Reference](references/deploy-reference.md) — deployment lifecycle, error recovery
|
|
116
129
|
|
|
117
130
|
### Comprehend an Existing Agent
|
|
118
131
|
|
|
@@ -168,7 +181,12 @@ Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command
|
|
|
168
181
|
Send test utterances with:
|
|
169
182
|
`sf agent preview send --json --authoring-bundle <Developer_Name> --session-id <ID> -u "<message>"`
|
|
170
183
|
Test changed paths first, then adjacent paths to catch regressions in existing behavior.
|
|
171
|
-
|
|
184
|
+
**CHECKPOINT — Do NOT proceed to Publish unless ALL are true:**
|
|
185
|
+
- `validate authoring-bundle` passes with zero errors
|
|
186
|
+
- Live preview (`--use-live-actions`) tested with representative utterances per topic
|
|
187
|
+
- Traces confirm correct topic routing and action invocation
|
|
188
|
+
- User explicitly approves deployment
|
|
189
|
+
8. **Publish** — Publish validates metadata structure, not agent behavior. Every publish creates permanent version number.
|
|
172
190
|
`sf agent publish authoring-bundle --json --api-name <Developer_Name>`
|
|
173
191
|
If publish fails, follow troubleshooting checklist in [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md), Section 5 before retrying.
|
|
174
192
|
9. **Activate** — Makes new version available to users.
|
|
@@ -270,8 +288,13 @@ Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command
|
|
|
270
288
|
`sf agent preview start --json --use-live-actions --authoring-bundle <Developer_Name>`
|
|
271
289
|
then send test utterances with:
|
|
272
290
|
`sf agent preview send --json --authoring-bundle <Developer_Name> --session-id <ID> -u "<message>"`
|
|
273
|
-
Test key conversation paths to validate agent behavior when backed by live actions.
|
|
274
|
-
|
|
291
|
+
Test key conversation paths to validate agent behavior when backed by live actions.
|
|
292
|
+
**CHECKPOINT — Do NOT proceed to Publish unless ALL are true:**
|
|
293
|
+
- `validate authoring-bundle` passes with zero errors
|
|
294
|
+
- Live preview (`--use-live-actions`) tested with representative utterances per topic
|
|
295
|
+
- Traces confirm correct topic routing and action invocation
|
|
296
|
+
- User explicitly approves deployment
|
|
297
|
+
4. **Publish** — Publish validates metadata structure, not agent behavior. DO NOT publish as part of a dev/test inner loop. ONLY publish as the FINAL step prior to activating the agent and surfacing it to end users.
|
|
275
298
|
`sf agent publish authoring-bundle --json --api-name <Developer_Name>`
|
|
276
299
|
If publish fails, follow *Troubleshooting Publish Failures* in [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) before retrying.
|
|
277
300
|
5. **Activate** — Makes new version available to users.
|
|
@@ -357,8 +380,8 @@ User wants to create automated tests for Agent Script agent. Involves writing `A
|
|
|
357
380
|
Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
|
|
358
381
|
|
|
359
382
|
1. **Establish coverage baseline** — Read Agent Spec. If no Agent Spec exists, reverse-engineer first by following Comprehend steps. Map every topic, action, and flow control path to identify what needs test coverage.
|
|
360
|
-
2. **Design test scenarios** — For test design methodology, expectations, metrics, test spec YAML format, and templates, use **agentforce
|
|
361
|
-
3. **Write test spec YAML** — Use template and reference files from **agentforce
|
|
383
|
+
2. **Design test scenarios** — For test design methodology, expectations, metrics, test spec YAML format, and templates, use **testing-agentforce** skill. That skill owns all testing content. For each coverage target, write one or more test scenarios: user utterance, expected topic routing, expected action invocations, and expected agent response. Include both happy paths and edge cases.
|
|
384
|
+
3. **Write test spec YAML** — Use template and reference files from **testing-agentforce** skill. Save to `specs/<Agent_API_Name>-testSpec.yaml` in SFDX project.
|
|
362
385
|
4. **Create test metadata** — Generate `AiEvaluationDefinition` from test spec using CLI.
|
|
363
386
|
5. **Deploy test** — Deploy `AiEvaluationDefinition` to org.
|
|
364
387
|
6. **Run tests** — Execute test run using CLI. Capture results.
|
|
@@ -373,7 +396,7 @@ Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command
|
|
|
373
396
|
structure for designing meaningful tests
|
|
374
397
|
3. [Design & Agent Spec](references/agent-design-and-spec-creation.md) —
|
|
375
398
|
Agent Spec as test coverage baseline
|
|
376
|
-
4. **agentforce
|
|
399
|
+
4. **testing-agentforce** skill — test spec YAML format, expectations,
|
|
377
400
|
metrics, test design methodology, and test spec template
|
|
378
401
|
|
|
379
402
|
## The Agent Spec
|
|
@@ -425,3 +448,73 @@ Planner validates ALL actions across ALL topics at startup. One missing permissi
|
|
|
425
448
|
|
|
426
449
|
**Apex action returns empty results in live preview but works in simulated:**
|
|
427
450
|
`WITH USER_MODE` + missing object permissions = silent failure (0 rows, no error). See [Agent User Setup & Permissions](references/agent-user-setup.md), Section 6.2.
|
|
451
|
+
|
|
452
|
+
## Syntax Quick Reference
|
|
453
|
+
|
|
454
|
+
- Block order: `system:` → `config:` → `variables:` → `connection:` → `knowledge:` → `language:` → `start_agent topic_selector:` → `topic:` blocks
|
|
455
|
+
- Indentation: **4 spaces** per indent level. Never use tabs. Mixing spaces and tabs breaks the parser.
|
|
456
|
+
- Booleans: `True`/`False` (capitalized)
|
|
457
|
+
- Strings: always double-quoted
|
|
458
|
+
- Numeric action I/O: bare `number` works for variables but **fails at publish** in action I/O. Use `object` + `complex_data_type_name` for numeric action parameters. See [Complex Data Types](references/complex-data-types.md) for the full decision tree.
|
|
459
|
+
- `after_reasoning:` has NO `instructions:` wrapper
|
|
460
|
+
- No `else if` — use compound `if x and y:` or sequential flat ifs
|
|
461
|
+
- Reserved `@InvocableVariable` names: `model`, `description`, `label` — cannot be used as Apex parameter names
|
|
462
|
+
- `@inputs` and `@outputs` are ephemeral: `@inputs` only in `with`; `@outputs` only in `set`/`if` immediately after the action. `@inputs` in `set` = silent failure.
|
|
463
|
+
|
|
464
|
+
See [Complex Data Types](references/complex-data-types.md) for the full Lightning type mapping decision tree. See [Instruction Resolution](references/instruction-resolution.md) for the 3-phase runtime model.
|
|
465
|
+
|
|
466
|
+
## Architecture Patterns
|
|
467
|
+
|
|
468
|
+
Three primary FSM patterns. Full details with code in [Architecture Patterns](references/architecture-patterns.md).
|
|
469
|
+
|
|
470
|
+
- **Hub-and-Spoke** (most common): `start_agent` routes to specialized topics. Each topic has "back to hub" transition. Do NOT create a separate routing topic.
|
|
471
|
+
- **Verification Gate**: Identity verification before protected topics. `available when` guards on protected transitions.
|
|
472
|
+
- **Post-Action Loop**: Post-action checks at TOP of `instructions: ->` trigger on re-resolution after action completes.
|
|
473
|
+
|
|
474
|
+
## Scoring Rubric
|
|
475
|
+
|
|
476
|
+
Score every generated agent on 100 points across 7 categories: Structure (15), Safety (15), Deterministic Logic (20), Instruction Resolution (20), FSM Architecture (10), Action Configuration (10), Deployment Readiness (10).
|
|
477
|
+
|
|
478
|
+
See [Scoring Rubric](references/scoring-rubric.md) for the complete rubric.
|
|
479
|
+
|
|
480
|
+
## Review Mode
|
|
481
|
+
|
|
482
|
+
When user provides an existing `.agent` file (e.g., `review path/to/file.agent`):
|
|
483
|
+
|
|
484
|
+
1. Read the file
|
|
485
|
+
2. Score against the 100-point rubric
|
|
486
|
+
3. List every issue grouped by category
|
|
487
|
+
4. Provide corrected code snippets
|
|
488
|
+
5. Offer to apply fixes
|
|
489
|
+
|
|
490
|
+
## Safety Review
|
|
491
|
+
|
|
492
|
+
7-category LLM-driven safety review for `.agent` files. Integrated into Phase 0 of authoring and deployment. Categories: Identity & Transparency, User Safety, Data Handling, Content Safety, Fairness, Deception, Scope & Boundaries.
|
|
493
|
+
|
|
494
|
+
See [Safety Review](references/safety-review-reference.md) for the complete framework, severity levels, false positive guidance, and adversarial test prompts.
|
|
495
|
+
|
|
496
|
+
## Discover & Scaffold
|
|
497
|
+
|
|
498
|
+
Validate action targets exist in org and generate stubs for missing ones.
|
|
499
|
+
|
|
500
|
+
See [Discover Reference](references/discover-reference.md) and [Scaffold Reference](references/scaffold-reference.md).
|
|
501
|
+
|
|
502
|
+
**CRITICAL:** Stubs must return realistic data, not `'TODO'`. Placeholder responses cause SMALL_TALK grounding because the LLM falls back to training data.
|
|
503
|
+
|
|
504
|
+
## Deploy Lifecycle
|
|
505
|
+
|
|
506
|
+
Validate → deploy metadata → publish bundle → activate. See [Deploy Reference](references/deploy-reference.md) for phases, error recovery, CI/CD, and rollback.
|
|
507
|
+
|
|
508
|
+
## Template Assets
|
|
509
|
+
|
|
510
|
+
Ready-to-use `.agent` templates in `assets/agents/` (hello-world, simple-qa, multi-topic, production-faq, order-service, verification-gate). See also `assets/patterns/` for 11+ reusable design patterns and [Examples](references/examples.md) for inline walkthroughs.
|
|
511
|
+
|
|
512
|
+
## Additional References
|
|
513
|
+
|
|
514
|
+
| Topic | File |
|
|
515
|
+
|-------|------|
|
|
516
|
+
| Architecture patterns | [architecture-patterns.md](references/architecture-patterns.md) |
|
|
517
|
+
| Type mapping decision tree | [complex-data-types.md](references/complex-data-types.md) |
|
|
518
|
+
| Feature validity by context | [feature-validity.md](references/feature-validity.md) |
|
|
519
|
+
| Instruction resolution model | [instruction-resolution.md](references/instruction-resolution.md) |
|
|
520
|
+
| Complete agent examples | [examples.md](references/examples.md) |
|
|
@@ -22,8 +22,8 @@ Templates for building complete, deployable agents.
|
|
|
22
22
|
|
|
23
23
|
2. Validate and deploy:
|
|
24
24
|
```bash
|
|
25
|
-
sf agent validate authoring-bundle --api-name My_Agent --target-org your-org
|
|
26
|
-
sf agent publish authoring-bundle --api-name My_Agent --target-org your-org
|
|
25
|
+
sf agent validate authoring-bundle --json --api-name My_Agent --target-org your-org
|
|
26
|
+
sf agent publish authoring-bundle --json --api-name My_Agent --target-org your-org
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Required Blocks
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Order Service Agent
|
|
2
|
+
# ========================
|
|
3
|
+
#
|
|
4
|
+
# A complex real-world agent for e-commerce customer service featuring:
|
|
5
|
+
# - Verification gate before order access
|
|
6
|
+
# - Multiple specialized topics (order status, tracking, returns)
|
|
7
|
+
# - Two-level action system with Flow targets
|
|
8
|
+
# - after_reasoning for post-action routing
|
|
9
|
+
# - available when guards for conditional action visibility
|
|
10
|
+
|
|
11
|
+
system:
|
|
12
|
+
instructions: |
|
|
13
|
+
You are an AI Customer Service Assistant helping customers with their orders.
|
|
14
|
+
Be helpful, empathetic, and efficient in resolving order-related issues.
|
|
15
|
+
Always verify customer identity before sharing order details.
|
|
16
|
+
Do not fabricate data — always use action results.
|
|
17
|
+
messages:
|
|
18
|
+
welcome: "Hello! I'm here to help you with your orders. How can I assist you today?"
|
|
19
|
+
error: "I apologize for the inconvenience. Let me try a different approach."
|
|
20
|
+
|
|
21
|
+
config:
|
|
22
|
+
developer_name: "OrderServiceAgent"
|
|
23
|
+
agent_label: "Order Service Assistant"
|
|
24
|
+
description: "Helps customers check order status, process returns, and track shipments"
|
|
25
|
+
default_agent_user: "einsteinagent@00dxx000001234.ext"
|
|
26
|
+
|
|
27
|
+
variables:
|
|
28
|
+
EndUserId: linked string
|
|
29
|
+
source: @MessagingSession.MessagingEndUserId
|
|
30
|
+
description: "Messaging End User ID"
|
|
31
|
+
visibility: "External"
|
|
32
|
+
RoutableId: linked string
|
|
33
|
+
source: @MessagingSession.Id
|
|
34
|
+
description: "Messaging Session ID"
|
|
35
|
+
visibility: "External"
|
|
36
|
+
ContactId: linked string
|
|
37
|
+
source: @MessagingEndUser.ContactId
|
|
38
|
+
description: "Contact ID"
|
|
39
|
+
visibility: "External"
|
|
40
|
+
customer_email: mutable string = ""
|
|
41
|
+
description: "Customer email for verification"
|
|
42
|
+
customer_verified: mutable boolean = False
|
|
43
|
+
description: "Whether customer identity has been verified"
|
|
44
|
+
order_number: mutable string = ""
|
|
45
|
+
description: "Current order number"
|
|
46
|
+
order_status: mutable string = ""
|
|
47
|
+
description: "Current order status"
|
|
48
|
+
tracking_number: mutable string = ""
|
|
49
|
+
description: "Shipment tracking number"
|
|
50
|
+
return_reason: mutable string = ""
|
|
51
|
+
description: "Reason for return"
|
|
52
|
+
return_initiated: mutable boolean = False
|
|
53
|
+
description: "Whether a return has been initiated"
|
|
54
|
+
return_label_url: mutable string = ""
|
|
55
|
+
description: "URL for return shipping label"
|
|
56
|
+
|
|
57
|
+
language:
|
|
58
|
+
default_locale: "en_US"
|
|
59
|
+
additional_locales: ""
|
|
60
|
+
all_additional_locales: False
|
|
61
|
+
|
|
62
|
+
start_agent topic_selector:
|
|
63
|
+
description: "Route customers through verification then to the right topic"
|
|
64
|
+
reasoning:
|
|
65
|
+
instructions: |
|
|
66
|
+
You are a router only. Do NOT answer questions or provide help directly.
|
|
67
|
+
Route all users to identity verification first.
|
|
68
|
+
If already verified, route to the appropriate topic:
|
|
69
|
+
- Order questions -> use to_orders
|
|
70
|
+
- Returns -> use to_returns
|
|
71
|
+
- Tracking -> use to_tracking
|
|
72
|
+
actions:
|
|
73
|
+
to_verify: @utils.transition to @topic.verification
|
|
74
|
+
description: "Begin identity verification"
|
|
75
|
+
to_orders: @utils.transition to @topic.order_status
|
|
76
|
+
description: "Check order status"
|
|
77
|
+
available when @variables.customer_verified == True
|
|
78
|
+
to_returns: @utils.transition to @topic.returns
|
|
79
|
+
description: "Process a return"
|
|
80
|
+
available when @variables.customer_verified == True
|
|
81
|
+
to_tracking: @utils.transition to @topic.shipment_tracking
|
|
82
|
+
description: "Track a shipment"
|
|
83
|
+
available when @variables.customer_verified == True
|
|
84
|
+
|
|
85
|
+
topic verification:
|
|
86
|
+
label: "Identity Verification"
|
|
87
|
+
description: "Verify customer identity before accessing order information"
|
|
88
|
+
|
|
89
|
+
actions:
|
|
90
|
+
verify_customer:
|
|
91
|
+
description: "Verify customer identity by email"
|
|
92
|
+
target: "flow://Verify_Customer_Identity"
|
|
93
|
+
inputs:
|
|
94
|
+
email: string
|
|
95
|
+
description: "Customer email address"
|
|
96
|
+
outputs:
|
|
97
|
+
verified: boolean
|
|
98
|
+
description: "Whether verification succeeded"
|
|
99
|
+
customer_name: string
|
|
100
|
+
description: "Verified customer name"
|
|
101
|
+
|
|
102
|
+
reasoning:
|
|
103
|
+
instructions: ->
|
|
104
|
+
if @variables.customer_verified == True:
|
|
105
|
+
| Welcome back! How can I help you today?
|
|
106
|
+
|
|
107
|
+
if @variables.customer_verified == False:
|
|
108
|
+
| To help you with your order, I need to verify your identity.
|
|
109
|
+
| What is the email address associated with your account?
|
|
110
|
+
|
|
111
|
+
actions:
|
|
112
|
+
verify: @actions.verify_customer
|
|
113
|
+
description: "Verify customer identity by email"
|
|
114
|
+
with email = ...
|
|
115
|
+
set @variables.customer_verified = @outputs.verified
|
|
116
|
+
set @variables.customer_email = @outputs.customer_name
|
|
117
|
+
|
|
118
|
+
proceed_to_orders: @utils.transition to @topic.order_status
|
|
119
|
+
description: "Move to order lookup"
|
|
120
|
+
available when @variables.customer_verified == True
|
|
121
|
+
|
|
122
|
+
escalate_now: @utils.escalate
|
|
123
|
+
description: "Transfer to human agent"
|
|
124
|
+
|
|
125
|
+
topic order_status:
|
|
126
|
+
label: "Order Status"
|
|
127
|
+
description: "Look up order details and provide status updates"
|
|
128
|
+
|
|
129
|
+
actions:
|
|
130
|
+
lookup_order:
|
|
131
|
+
description: "Look up order by order number"
|
|
132
|
+
target: "flow://Lookup_Order"
|
|
133
|
+
inputs:
|
|
134
|
+
order_number: string
|
|
135
|
+
description: "Order number to look up"
|
|
136
|
+
customer_email: string
|
|
137
|
+
description: "Customer email for validation"
|
|
138
|
+
outputs:
|
|
139
|
+
status: string
|
|
140
|
+
description: "Order status"
|
|
141
|
+
is_displayable: True
|
|
142
|
+
tracking_number: string
|
|
143
|
+
description: "Shipment tracking number"
|
|
144
|
+
is_displayable: True
|
|
145
|
+
estimated_delivery: string
|
|
146
|
+
description: "Estimated delivery date"
|
|
147
|
+
is_displayable: True
|
|
148
|
+
|
|
149
|
+
reasoning:
|
|
150
|
+
instructions: ->
|
|
151
|
+
if @variables.order_status != "":
|
|
152
|
+
| Order {!@variables.order_number} status: {!@variables.order_status}
|
|
153
|
+
| Would you like to track your shipment or initiate a return?
|
|
154
|
+
|
|
155
|
+
if @variables.order_status == "":
|
|
156
|
+
| What is your order number? You can find it in your confirmation email.
|
|
157
|
+
| Use the find_order action to look up order details.
|
|
158
|
+
|
|
159
|
+
actions:
|
|
160
|
+
find_order: @actions.lookup_order
|
|
161
|
+
description: "Look up order details"
|
|
162
|
+
with order_number = ...
|
|
163
|
+
with customer_email = @variables.customer_email
|
|
164
|
+
set @variables.order_status = @outputs.status
|
|
165
|
+
set @variables.tracking_number = @outputs.tracking_number
|
|
166
|
+
|
|
167
|
+
to_returns: @utils.transition to @topic.returns
|
|
168
|
+
description: "Start a return"
|
|
169
|
+
available when @variables.order_status != ""
|
|
170
|
+
|
|
171
|
+
to_tracking: @utils.transition to @topic.shipment_tracking
|
|
172
|
+
description: "Track shipment"
|
|
173
|
+
available when @variables.tracking_number != ""
|
|
174
|
+
|
|
175
|
+
back: @utils.transition to @topic.topic_selector
|
|
176
|
+
description: "Route to a different topic"
|
|
177
|
+
|
|
178
|
+
topic shipment_tracking:
|
|
179
|
+
label: "Shipment Tracking"
|
|
180
|
+
description: "Track shipment status and estimated delivery"
|
|
181
|
+
|
|
182
|
+
actions:
|
|
183
|
+
get_tracking_details:
|
|
184
|
+
description: "Get detailed tracking information"
|
|
185
|
+
target: "flow://Get_Tracking_Details"
|
|
186
|
+
inputs:
|
|
187
|
+
tracking_number: string
|
|
188
|
+
description: "Shipment tracking number"
|
|
189
|
+
outputs:
|
|
190
|
+
current_location: string
|
|
191
|
+
description: "Current package location"
|
|
192
|
+
is_displayable: True
|
|
193
|
+
estimated_delivery: string
|
|
194
|
+
description: "Estimated delivery date"
|
|
195
|
+
is_displayable: True
|
|
196
|
+
delivery_status: string
|
|
197
|
+
description: "Delivery status"
|
|
198
|
+
is_displayable: True
|
|
199
|
+
|
|
200
|
+
reasoning:
|
|
201
|
+
instructions: |
|
|
202
|
+
Look up the tracking information for the customer's shipment.
|
|
203
|
+
Use the track action with the tracking number.
|
|
204
|
+
Do not fabricate tracking details — always use the action result.
|
|
205
|
+
|
|
206
|
+
actions:
|
|
207
|
+
track: @actions.get_tracking_details
|
|
208
|
+
description: "Get tracking details"
|
|
209
|
+
with tracking_number = @variables.tracking_number
|
|
210
|
+
|
|
211
|
+
back: @utils.transition to @topic.topic_selector
|
|
212
|
+
description: "Route to a different topic"
|
|
213
|
+
|
|
214
|
+
topic returns:
|
|
215
|
+
label: "Returns"
|
|
216
|
+
description: "Process return requests and generate return labels"
|
|
217
|
+
|
|
218
|
+
actions:
|
|
219
|
+
initiate_return:
|
|
220
|
+
description: "Initiate a return for an order"
|
|
221
|
+
target: "flow://Initiate_Return"
|
|
222
|
+
inputs:
|
|
223
|
+
order_number: string
|
|
224
|
+
description: "Order number to return"
|
|
225
|
+
reason: string
|
|
226
|
+
description: "Reason for return"
|
|
227
|
+
outputs:
|
|
228
|
+
return_label_url: string
|
|
229
|
+
description: "URL for return shipping label"
|
|
230
|
+
is_displayable: True
|
|
231
|
+
return_deadline: string
|
|
232
|
+
description: "Deadline to ship return"
|
|
233
|
+
is_displayable: True
|
|
234
|
+
|
|
235
|
+
reasoning:
|
|
236
|
+
instructions: ->
|
|
237
|
+
if @variables.return_initiated == True:
|
|
238
|
+
| Your return has been initiated!
|
|
239
|
+
| Return label: {!@variables.return_label_url}
|
|
240
|
+
|
|
241
|
+
if @variables.return_initiated == False:
|
|
242
|
+
| I can help you with a return for order {!@variables.order_number}.
|
|
243
|
+
| What is the reason for your return?
|
|
244
|
+
| Use the process_return action to start the return.
|
|
245
|
+
|
|
246
|
+
actions:
|
|
247
|
+
process_return: @actions.initiate_return
|
|
248
|
+
description: "Process the return request"
|
|
249
|
+
with order_number = @variables.order_number
|
|
250
|
+
with reason = ...
|
|
251
|
+
set @variables.return_initiated = True
|
|
252
|
+
set @variables.return_label_url = @outputs.return_label_url
|
|
253
|
+
|
|
254
|
+
back: @utils.transition to @topic.topic_selector
|
|
255
|
+
description: "Route to a different topic"
|
|
256
|
+
|
|
257
|
+
after_reasoning: ->
|
|
258
|
+
if @variables.return_initiated == True:
|
|
259
|
+
transition to @topic.follow_up
|
|
260
|
+
|
|
261
|
+
topic follow_up:
|
|
262
|
+
label: "Follow Up"
|
|
263
|
+
description: "Handle follow-up actions and next steps"
|
|
264
|
+
reasoning:
|
|
265
|
+
instructions: |
|
|
266
|
+
The customer's request has been processed.
|
|
267
|
+
Ask if there is anything else you can help with.
|
|
268
|
+
actions:
|
|
269
|
+
new_order: @utils.transition to @topic.order_status
|
|
270
|
+
description: "Look up another order"
|
|
271
|
+
back: @utils.transition to @topic.topic_selector
|
|
272
|
+
description: "Start over"
|