scc-universal 1.2.2 → 1.3.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/.claude-plugin/plugin.json +1 -1
- package/.cursor/agents/sf-agentforce-agent.md +88 -40
- package/.cursor/skills/sf-2gp-security-review/SKILL.md +167 -0
- package/.cursor/skills/sf-agentforce-development/SKILL.md +385 -348
- package/.cursor/skills/sf-cli-reference/SKILL.md +221 -0
- package/.cursor-plugin/plugin.json +1 -1
- package/agents/sf-agentforce-agent.md +88 -40
- package/manifests/install-modules.json +3 -1
- package/package.json +1 -1
- package/skills/_reference/AGENTFORCE_PATTERNS.md +433 -51
- package/skills/_reference/APPEXCHANGE_REVIEW.md +427 -0
- package/skills/_reference/SF_CLI_COMMANDS.md +812 -0
- package/skills/sf-2gp-security-review/SKILL.md +168 -0
- package/skills/sf-agentforce-development/SKILL.md +385 -348
- package/skills/sf-cli-reference/SKILL.md +225 -0
|
@@ -1,40 +1,191 @@
|
|
|
1
1
|
# Agentforce Patterns — Reference
|
|
2
2
|
|
|
3
|
-
> Source: <https://developer.salesforce.com/docs/ai/agentforce/guide/
|
|
3
|
+
> Source: <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-script.html>
|
|
4
|
+
> Also: <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-dx.html>
|
|
5
|
+
> Also: <https://developer.salesforce.com/blogs/2026/02/agent-script-decoded-intro-to-agent-script-language-fundamentals>
|
|
4
6
|
> Also: <https://developer.salesforce.com/blogs/2025/07/best-practices-for-building-agentforce-apex-actions>
|
|
5
7
|
> Also: <https://developer.salesforce.com/blogs/2025/01/how-to-write-effective-natural-language-instructions-for-agentforce>
|
|
6
|
-
> Last verified: API v66.0, Spring '26 (2026-
|
|
8
|
+
> Last verified: API v66.0, Spring '26 (2026-04-09)
|
|
7
9
|
|
|
8
10
|
## Architecture
|
|
9
11
|
|
|
12
|
+
### Agent Script (Recommended — Spring '26+)
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
AiAuthoringBundle (.agent file)
|
|
16
|
+
+-- config (developer_name, agent_label, description)
|
|
17
|
+
+-- variables (mutable read/write, linked read-only)
|
|
18
|
+
+-- system (global instructions, welcome/error messages)
|
|
19
|
+
+-- start_agent (entry point — topic routing)
|
|
20
|
+
+-- topics (1..N conversation domains)
|
|
21
|
+
+-- description (routes user queries here)
|
|
22
|
+
+-- reasoning
|
|
23
|
+
| +-- instructions (-> procedural + | LLM prompts)
|
|
24
|
+
| +-- actions (tools exposed to LLM)
|
|
25
|
+
+-- after_reasoning (optional post-LLM deterministic logic)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Publishes to: `Bot/BotVersion → GenAiPlannerBundle → GenAiPlugin (topics) → GenAiFunction (actions)`
|
|
29
|
+
|
|
30
|
+
### Classic Setup (Pre-Agent Script / API < v65)
|
|
31
|
+
|
|
10
32
|
```
|
|
11
|
-
Agent
|
|
12
|
-
+-- Topic (
|
|
13
|
-
| +-- Classification Description
|
|
14
|
-
| +-- Scope (
|
|
15
|
-
| +-- Instructions (numbered guidelines
|
|
16
|
-
| +-- Actions (1..N
|
|
17
|
-
| +-- Action Instructions
|
|
18
|
-
| +-- Input Parameters
|
|
19
|
-
| +-- Output Parameters (with output instructions)
|
|
33
|
+
Agent (Bot)
|
|
34
|
+
+-- Topic (GenAiPlugin)
|
|
35
|
+
| +-- Classification Description
|
|
36
|
+
| +-- Scope (WILL / WILL NOT)
|
|
37
|
+
| +-- Instructions (numbered guidelines)
|
|
38
|
+
| +-- Actions (GenAiFunction, 1..N)
|
|
39
|
+
| +-- Action Instructions
|
|
40
|
+
| +-- Input/Output Parameters
|
|
20
41
|
+-- Topic ...
|
|
21
42
|
```
|
|
22
43
|
|
|
23
44
|
**Recommended limits**: max 10 topics per agent; 12-15 actions per topic. Exceeding causes context confusion in the Atlas reasoning engine.
|
|
24
45
|
|
|
46
|
+
## Agent Script Syntax
|
|
47
|
+
|
|
48
|
+
Files use `.agent` extension. Stored in `force-app/main/default/aiAuthoringBundles/<Name>/<Name>.agent`. Whitespace-sensitive (3 spaces per indent, no tabs).
|
|
49
|
+
|
|
50
|
+
### Operators
|
|
51
|
+
|
|
52
|
+
| Symbol | Purpose |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `#` | Single-line comment |
|
|
55
|
+
| `->` | Begins procedural/executable logic |
|
|
56
|
+
| `\|` | Begins natural language prompt text sent to LLM |
|
|
57
|
+
| `{!expression}` | Template expression (variable injection at runtime) |
|
|
58
|
+
| `...` | Slot-fill token (LLM extracts value from conversation) |
|
|
59
|
+
| `@actions.name` | Reference an action |
|
|
60
|
+
| `@outputs.name` | Access action output values |
|
|
61
|
+
| `@topic.name` | Delegate to another topic (returns to caller) |
|
|
62
|
+
| `@variables.name` | Reference a variable |
|
|
63
|
+
| `@utils.escalate` | Escalate to human agent |
|
|
64
|
+
| `@utils.setVariables` | Instruct LLM to set variable values |
|
|
65
|
+
| `@utils.transition to` | LLM-selected topic transition (in reasoning.actions) |
|
|
66
|
+
| `transition to` | Deterministic topic transition (in reasoning.instructions or after_reasoning) |
|
|
67
|
+
|
|
68
|
+
### Comparison & Logical Operators
|
|
69
|
+
|
|
70
|
+
| Type | Operators |
|
|
71
|
+
|---|---|
|
|
72
|
+
| Comparison | `==`, `!=`, `<`, `>`, `>=`, `<=`, `is None`, `is not None` |
|
|
73
|
+
| Logical | `&&`, `\|\|`, `!` |
|
|
74
|
+
| Arithmetic | `+`, `-` only (no `*`, `/`, `%`) |
|
|
75
|
+
| Conditionals | `if` / `else` (no `else if` — use separate `if` statements) |
|
|
76
|
+
| Booleans | Must be capitalized: `True`, `False` |
|
|
77
|
+
|
|
78
|
+
### Required Block Order
|
|
79
|
+
|
|
80
|
+
1. **config** — `developer_name` (required), `agent_label`, `description`, `default_agent_user`
|
|
81
|
+
2. **variables** — `mutable <type> = <default>` or `linked <type>` with `source: "..."` (read-only)
|
|
82
|
+
3. **system** — `instructions`, `messages.welcome`, `messages.error`
|
|
83
|
+
4. **start_agent** — Entry point; topic classification and routing
|
|
84
|
+
5. **topics** — Conversation domains with `reasoning` (required) and `after_reasoning` (optional)
|
|
85
|
+
|
|
86
|
+
### Variable Types
|
|
87
|
+
|
|
88
|
+
| Kind | Syntax | Use |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| Mutable | `name: mutable string = ""` | Read/write state (string, boolean, number) |
|
|
91
|
+
| Linked | `name: linked string` + `source: "EndUserLanguage"` | Read-only from external context (session, channel) |
|
|
92
|
+
|
|
93
|
+
### Action Invocation
|
|
94
|
+
|
|
95
|
+
**Deterministic (run)** — executes unconditionally in procedural logic:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
-> run @actions.get_order with
|
|
99
|
+
order_id: @variables.order_id
|
|
100
|
+
set
|
|
101
|
+
order_details: result
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**LLM-Driven (reasoning.actions)** — LLM decides when to call:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
reasoning:
|
|
108
|
+
actions:
|
|
109
|
+
lookup_order:
|
|
110
|
+
action: @actions.get_order
|
|
111
|
+
description: "Retrieves order details by ID"
|
|
112
|
+
inputs:
|
|
113
|
+
order_id: ...
|
|
114
|
+
set:
|
|
115
|
+
order_details: output
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Conditional Tool Display
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
actions:
|
|
122
|
+
refund_order:
|
|
123
|
+
action: @actions.process_refund
|
|
124
|
+
description: "Process a refund"
|
|
125
|
+
available when: @variables.is_verified == True && @variables.order_total > 0
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`available when` hides the action from the LLM until conditions are met. Use for gating sensitive operations behind authentication or state checks.
|
|
129
|
+
|
|
130
|
+
### Topic Transitions
|
|
131
|
+
|
|
132
|
+
| Method | Where | Syntax |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| Deterministic | `reasoning.instructions`, `after_reasoning` | `transition to <topic>` |
|
|
135
|
+
| LLM-selected | `reasoning.actions` | `@utils.transition to @topic.<name>` |
|
|
136
|
+
| Delegation | Anywhere | `@topic.<name>` (returns to caller after completion) |
|
|
137
|
+
|
|
138
|
+
### Execution Flow (Runtime Pipeline)
|
|
139
|
+
|
|
140
|
+
1. User message arrives
|
|
141
|
+
2. `start_agent` evaluates — routes to appropriate topic via `reasoning.instructions`
|
|
142
|
+
3. Selected topic's `reasoning.instructions` execute top-to-bottom (deterministic `->` lines)
|
|
143
|
+
4. All `|` (pipe) text accumulates into a single prompt sent to the LLM
|
|
144
|
+
5. LLM processes prompt and may invoke tools from `reasoning.actions`
|
|
145
|
+
6. Variables update from action outputs (`set` clauses)
|
|
146
|
+
7. `after_reasoning` executes (deterministic cleanup/mandatory transitions)
|
|
147
|
+
8. Cycle repeats for next user message
|
|
148
|
+
|
|
149
|
+
## Metadata Types
|
|
150
|
+
|
|
151
|
+
| Metadata Type | package.xml Name | Directory | API Version | Purpose |
|
|
152
|
+
|---|---|---|---|---|
|
|
153
|
+
| AiAuthoringBundle | `AiAuthoringBundle` | `aiAuthoringBundles/<Name>/` | v65+ | Agent Script container (`.agent` + `.bundle-meta.xml`) |
|
|
154
|
+
| Bot | `Bot` | `bots/` | v38+ | Top-level agent representation |
|
|
155
|
+
| BotVersion | `BotVersion` | `botVersions/` | v38+ | Agent version config (one active per agent) |
|
|
156
|
+
| GenAiPlannerBundle | `GenAiPlannerBundle` | `genAiPlannerBundles/` | v64+ | Reasoning engine container (replaces GenAiPlanner) |
|
|
157
|
+
| GenAiPlugin | `GenAiPlugin` | `genAiPlugins/` | v60+ | Agent topic (category of related actions) |
|
|
158
|
+
| GenAiFunction | `GenAiFunction` | `genAiFunctions/<Name>/` | v60+ | Agent action (input/output in schema.json) |
|
|
159
|
+
| GenAiPromptTemplate | `GenAiPromptTemplate` | `genAiPromptTemplates/` | v60+ | Prompt template for LLM guidance |
|
|
160
|
+
| AiEvaluationDefinition | `AiEvaluationDefinition` | `aiEvaluationDefinitions/` | v63+ | Agent test definitions |
|
|
161
|
+
| LightningTypeBundle | `LightningTypeBundle` | `lightningTypes/<Name>/` | v64+ | Rich UI type for agent responses |
|
|
162
|
+
| ConversationContextVariable | — | — | v60+ | Context variables (session, channel) |
|
|
163
|
+
| ConversationVariable | — | — | v60+ | Customer data collected during conversation |
|
|
164
|
+
|
|
165
|
+
**Deployment order** (strict): Bot/BotVersion → GenAiPromptTemplate → GenAiFunction → GenAiPlugin → GenAiPlannerBundle → Activate BotVersion
|
|
166
|
+
|
|
167
|
+
**Legacy**: GenAiPlanner (v60-63) replaced by GenAiPlannerBundle in v64+.
|
|
168
|
+
|
|
25
169
|
## Action Types
|
|
26
170
|
|
|
27
171
|
| Action Source | How It Works | When to Use |
|
|
28
172
|
|---|---|---|
|
|
29
173
|
| **Apex `@InvocableMethod`** | Annotated static method exposed to Agentforce Builder | Custom business logic, DML, callouts |
|
|
30
|
-
| **Apex REST** | `@RestResource` class registered via API catalog | External API wrappers |
|
|
31
|
-
| **AuraEnabled** | `@AuraEnabled` controller method with OpenAPI doc | Reusing existing LWC controller logic |
|
|
32
174
|
| **Autolaunched Flow** | Flow with no screens; invoked as action | Declarative orchestration, record ops |
|
|
33
175
|
| **Prompt Template** | Flex prompt template from Prompt Builder | LLM-generated text, summaries, classification |
|
|
34
|
-
| **
|
|
35
|
-
| **
|
|
176
|
+
| **MCP Server** | External tool via Model Context Protocol (JSON-RPC 2.0 over HTTP/SSE) | Third-party integrations; registered in MCP Server Registry |
|
|
177
|
+
| **Named Query (GA)** | Parameterized SOQL exposed as REST API and agent action | Read-only data retrieval without Apex/Flow |
|
|
178
|
+
| **AuraEnabled (Beta)** | `@AuraEnabled` method with auto-generated OpenAPI spec via API Catalog | Reusing existing LWC/Aura controller logic |
|
|
179
|
+
| **Apex REST** | `@RestResource` class registered via API Catalog | External API wrappers |
|
|
180
|
+
|
|
181
|
+
### Action Enhancements
|
|
36
182
|
|
|
37
|
-
|
|
183
|
+
| Enhancement | Purpose |
|
|
184
|
+
|---|---|
|
|
185
|
+
| **Apex Citations** | Source attribution via `GenAiCitationInput` (auto-placement) or `GenAiCitationOutput` (explicit control). Sources: knowledge articles, PDFs, external URLs |
|
|
186
|
+
| **Lightning Types** | `LightningTypeBundle` with `schema.json` + channel-specific `renderer.json`/`editor.json`. Custom LWC targets: `lightning__AgentforceInput`, `lightning__AgentforceOutput` |
|
|
187
|
+
| **Adaptive Response Formats** | Rich Choice (carousel, buttons, list selector) and Rich Link (media card). Available for Service Agents on messaging channels |
|
|
188
|
+
| **Global Copy** | Consistent copy-to-clipboard UI in agent responses |
|
|
38
189
|
|
|
39
190
|
## Apex Action Rules
|
|
40
191
|
|
|
@@ -46,67 +197,298 @@ All action types support enhancement via: Lightning Types (rich UI), Global Copy
|
|
|
46
197
|
| Error handling | Use `try-catch`; return user-friendly messages; use `Database` class for partial processing |
|
|
47
198
|
| Decomposition | Break complex actions into smaller ones to avoid CPU timeout (10s sync limit) |
|
|
48
199
|
| Async work | Use Queueable Apex for long-running tasks; return a requestId for status tracking |
|
|
49
|
-
| Labels | Keep Apex `label`/`description` in sync with Agentforce Builder action config |
|
|
200
|
+
| Labels | Keep Apex `label`/`description` in sync with Agentforce Builder action config — LLM reads these for routing |
|
|
201
|
+
| Return type | Return a result object (not void); agent needs structured confirmation to continue reasoning |
|
|
50
202
|
|
|
51
203
|
## Instruction Guidelines
|
|
52
204
|
|
|
205
|
+
Applies to both Agent Script (in `|` prompt blocks, `description` fields) and Classic Setup.
|
|
206
|
+
|
|
53
207
|
| Instruction Type | Rules |
|
|
54
208
|
|---|---|
|
|
55
|
-
| **Topic Classification** | Concise; describes what queries route here. E.g. "Manages customer inquiries about order status and returns." |
|
|
209
|
+
| **Topic Classification** | Concise; describes what queries route here. Eliminate semantic overlap between topics. E.g. "Manages customer inquiries about order status and returns." |
|
|
56
210
|
| **Topic Scope** | Explicit WILL/WILL NOT. E.g. "Handle resending confirmations, but do not create new reservations." |
|
|
57
|
-
| **Topic Instructions** | Numbered list
|
|
58
|
-
| **Action Instructions** | 1-3 sentences: purpose, goal, scope. Specify dependent actions. Use varied verb names
|
|
59
|
-
| **Input Instructions** | Specify field name, data type, format. E.g. "accountId
|
|
211
|
+
| **Topic Instructions** | Numbered list, positive framing ("always do X" not "don't do Y"). No deterministic business rules — put those in action code or Agent Script `->` logic |
|
|
212
|
+
| **Action Instructions** | 1-3 sentences: purpose, goal, scope. Specify dependent actions. Use varied verb names ("Locate", "Retrieve", "Calculate" — not "Get X", "Get Y") |
|
|
213
|
+
| **Input Instructions** | Specify field name, data type, format. E.g. "accountId — The 18-digit unique Account record ID" |
|
|
60
214
|
| **Output Instructions** | Describe return value with type. E.g. "balance: numeric value representing current account balance" |
|
|
61
215
|
|
|
62
|
-
**Anti-patterns**: Overusing "must"/"never"/"always" (agent gets stuck); relying on
|
|
216
|
+
**Anti-patterns**: Overusing "must"/"never"/"always" (agent gets stuck); relying on instructions for input validation (use action code); similar action names (use varied verbs); overscripting every conversational turn (stifles LLM reasoning).
|
|
63
217
|
|
|
64
|
-
##
|
|
218
|
+
## Context Engineering
|
|
65
219
|
|
|
66
|
-
|
|
220
|
+
### Five Levels of Determinism
|
|
221
|
+
|
|
222
|
+
| Level | Mechanism | Determinism |
|
|
223
|
+
|---|---|---|
|
|
224
|
+
| 1 | Topic & action selection via classification descriptions | Low — LLM chooses |
|
|
225
|
+
| 2 | Agent instructions as behavioral guardrails | Low-Medium — LLM interprets |
|
|
226
|
+
| 3 | Data grounding (RAG via Data Cloud, knowledge articles) | Medium — facts constrain LLM |
|
|
227
|
+
| 4 | Explicit state via variables (persistent grounding, action I/O mapping, conditional filtering) | High — variables gate logic |
|
|
228
|
+
| 5 | Deterministic actions (Apex, Flow, Agent Script `->` logic) | Full — code executes |
|
|
67
229
|
|
|
68
|
-
|
|
230
|
+
**Rule of thumb**: If a workflow involves >3 sequential steps, use Level 5 (deterministic code) rather than relying on topic instructions.
|
|
231
|
+
|
|
232
|
+
### Four Context Failures
|
|
233
|
+
|
|
234
|
+
| Failure | Description |
|
|
69
235
|
|---|---|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
75
|
-
|
|
236
|
+
| **Context Distraction** | Too many irrelevant tools dilute decision quality. Mitigate with focused topics |
|
|
237
|
+
| **Context Clash** | Contradicting instructions across prompts, topics, actions, RAG data |
|
|
238
|
+
| **Context Poisoning** | Inaccurate or outdated grounding data (knowledge articles, CRM records) |
|
|
239
|
+
| **Context Confusion** | Too many complex competing tasks; facts assigned to wrong entities |
|
|
240
|
+
|
|
241
|
+
### Principles
|
|
76
242
|
|
|
77
|
-
|
|
243
|
+
1. Limit topics (max 10) and actions per topic (12-15)
|
|
244
|
+
2. Use variables to store key facts — do not rely on conversation memory
|
|
245
|
+
3. Eliminate contradictions across topic instructions, action instructions, and scope
|
|
246
|
+
4. Validate RAG/knowledge data is current and accurate
|
|
247
|
+
5. Use structured actions for critical business logic; reserve natural language for conversational tasks
|
|
248
|
+
6. Only enforce determinism where necessary (access control, critical rules) — agents need flexibility
|
|
249
|
+
|
|
250
|
+
## Testing
|
|
251
|
+
|
|
252
|
+
### Built-in Metrics
|
|
253
|
+
|
|
254
|
+
| Metric | Expectation Name | Description |
|
|
255
|
+
|---|---|---|
|
|
256
|
+
| Topic | `topic_sequence_match` | Verifies correct topic routing |
|
|
257
|
+
| Action | `action_sequence_match` | Verifies correct action execution |
|
|
258
|
+
| Outcome | `bot_response_rating` | Natural language comparison of expected vs actual |
|
|
259
|
+
| Coherence | `coherence` | Easy to understand, no grammar errors |
|
|
260
|
+
| Completeness | `completeness` | Includes all essential information |
|
|
261
|
+
| Conciseness | `conciseness` | Brief but comprehensive |
|
|
262
|
+
| Latency | `output_latency_milliseconds` | Response time measurement |
|
|
263
|
+
| Instruction Adherence | `instructionAdherence` | Alignment with topic instructions (HIGH/LOW/UNCERTAIN) |
|
|
264
|
+
| Factuality | `factuality` | How factual the response is |
|
|
265
|
+
|
|
266
|
+
### Test Spec YAML Format
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
name: My_Agent_Tests
|
|
270
|
+
subjectType: AGENT
|
|
271
|
+
subjectName: My_Agent
|
|
272
|
+
testCases:
|
|
273
|
+
- utterance: "What's my order status?"
|
|
274
|
+
expectedTopic: Order_Management
|
|
275
|
+
expectedActions:
|
|
276
|
+
- Get_Order_Status
|
|
277
|
+
expectedOutcome: "Your order #12345 is shipped."
|
|
278
|
+
contextVariables:
|
|
279
|
+
- name: EndUserLanguage
|
|
280
|
+
value: en
|
|
281
|
+
metrics:
|
|
282
|
+
- topic_sequence_match
|
|
283
|
+
- action_sequence_match
|
|
284
|
+
- bot_response_rating
|
|
285
|
+
- coherence
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Testing Tools
|
|
289
|
+
|
|
290
|
+
| Tool | Purpose |
|
|
291
|
+
|---|---|
|
|
292
|
+
| **Agent Builder Preview** | Real-time conversational testing (simulated or live mode) |
|
|
293
|
+
| **Agentforce Testing Center** | Bulk test execution; auto-generates test cases from knowledge |
|
|
294
|
+
| **Agentforce DX CLI** | `sf agent generate test-spec`, `sf agent test create`, `sf agent test run` |
|
|
295
|
+
| **VS Code Agent Panel** | View/run tests; Agent Preview pane; Apex Replay Debugger for actions |
|
|
296
|
+
| **Testing REST API** | `POST /einstein/ai-evaluations/runs`, `GET .../runs/{id}`, `GET .../runs/{id}/results` |
|
|
297
|
+
| **Agent Grid (Beta)** | Spreadsheet-like environment for rapid testing with real CRM data |
|
|
298
|
+
| **Apex unit tests** | Standard `@isTest` for action implementation code |
|
|
299
|
+
|
|
300
|
+
## SF CLI Agent Commands
|
|
301
|
+
|
|
302
|
+
Requires SF CLI v2.115.15+ (`@salesforce/plugin-agent`).
|
|
303
|
+
|
|
304
|
+
### Create & Generate
|
|
305
|
+
|
|
306
|
+
| Command | Purpose |
|
|
307
|
+
|---|---|
|
|
308
|
+
| `sf agent generate agent-spec --type <customer\|internal> --role "..." --output-file specs/agentSpec.yaml` | Generate agent spec YAML via LLM interview |
|
|
309
|
+
| `sf agent generate authoring-bundle --spec specs/agentSpec.yaml --name "Name" --api-name API_Name` | Generate `.agent` file + metadata XML from spec |
|
|
310
|
+
| `sf agent generate authoring-bundle --no-spec` | Generate with default boilerplate |
|
|
311
|
+
| `sf agent generate test-spec --output-file specs/testSpec.yaml` | Generate test spec YAML |
|
|
312
|
+
| `sf agent generate template --agent-file path/Bot.bot-meta.xml --agent-version 1 --source-org my-org` | Generate agent template for packaging |
|
|
313
|
+
| `sf agent create --spec specs/agentSpec.yaml --name "Name" --api-name API_Name` | Create agent in org from spec (non-Agent Script path) |
|
|
314
|
+
| `sf template generate project --template agent` | Scaffold sample DX project with agent |
|
|
315
|
+
|
|
316
|
+
### Publish & Validate
|
|
317
|
+
|
|
318
|
+
| Command | Purpose |
|
|
319
|
+
|---|---|
|
|
320
|
+
| `sf agent publish authoring-bundle --target-org my-org` | Publish: validate → generate metadata → deploy |
|
|
321
|
+
| `sf agent publish authoring-bundle --skip-retrieve` | Publish without retrieving generated metadata (CI) |
|
|
322
|
+
| `sf agent validate authoring-bundle` | Validate syntax/structure without publishing |
|
|
323
|
+
|
|
324
|
+
### Preview
|
|
325
|
+
|
|
326
|
+
| Command | Purpose |
|
|
327
|
+
|---|---|
|
|
328
|
+
| `sf agent preview` | Interactive terminal preview session |
|
|
329
|
+
| `sf agent preview start --simulate-actions` | Start programmatic preview (simulated mode) |
|
|
330
|
+
| `sf agent preview start --use-live-actions` | Start programmatic preview (live org resources) |
|
|
331
|
+
| `sf agent preview send --session-id <id> --message "..."` | Send message to active preview |
|
|
332
|
+
| `sf agent preview end --session-id <id>` | End preview and retrieve traces |
|
|
333
|
+
| `sf agent preview sessions` | List active preview sessions |
|
|
334
|
+
|
|
335
|
+
### Test
|
|
336
|
+
|
|
337
|
+
| Command | Purpose |
|
|
338
|
+
|---|---|
|
|
339
|
+
| `sf agent test create --spec specs/testSpec.yaml` | Create test in org from YAML spec |
|
|
340
|
+
| `sf agent test run --api-name My_Test --wait 10 --result-format junit --output-dir ./results` | Execute tests (sync with JUnit output for CI) |
|
|
341
|
+
| `sf agent test resume --test-run-id <id>` | Resume async test run |
|
|
342
|
+
| `sf agent test results --test-id <id>` | View completed test results |
|
|
343
|
+
| `sf agent test list` | List all agent tests in org |
|
|
344
|
+
|
|
345
|
+
### Activate & Manage
|
|
346
|
+
|
|
347
|
+
| Command | Purpose |
|
|
348
|
+
|---|---|
|
|
349
|
+
| `sf agent activate --api-name My_Agent --version 2` | Activate agent version |
|
|
350
|
+
| `sf agent deactivate --api-name My_Agent` | Deactivate agent |
|
|
351
|
+
| `sf org create agent-user` | Create default agent user with required profiles/permissions |
|
|
78
352
|
|
|
79
353
|
## Invocation Channels
|
|
80
354
|
|
|
81
355
|
| Channel | Method |
|
|
82
356
|
|---|---|
|
|
83
357
|
| Flow | Standard "AI Agent" action in Flow Builder; pass user message + optional session ID |
|
|
84
|
-
| Apex | Invocable Action API with agent API name
|
|
358
|
+
| Apex | Invocable Action API with agent API name |
|
|
85
359
|
| LWC | Via Apex method call |
|
|
86
|
-
| External systems | REST with OAuth 2.0
|
|
87
|
-
| Agent-to-agent |
|
|
360
|
+
| External systems | REST with OAuth 2.0 |
|
|
361
|
+
| Agent-to-agent | A2A Protocol for cross-platform delegation; Agent Script `transition to` for internal chaining |
|
|
88
362
|
| Slack, websites, apps | Deploy via Agentforce channel configuration |
|
|
89
363
|
|
|
364
|
+
### Multi-Agent Patterns
|
|
365
|
+
|
|
366
|
+
| Pattern | Description |
|
|
367
|
+
|---|---|
|
|
368
|
+
| **Greeter** | Simple intent detection + routing to service rep |
|
|
369
|
+
| **Operator** | Intelligent routing to specialist AI agents or humans |
|
|
370
|
+
| **Orchestrator** | Manages agent swarm: receives request → creates plan → delegates → aggregates responses |
|
|
371
|
+
|
|
90
372
|
Session ID ties multi-turn conversations together. First message generates the ID; pass it with subsequent messages.
|
|
91
373
|
|
|
92
|
-
##
|
|
374
|
+
## Agent Configuration
|
|
93
375
|
|
|
94
|
-
|
|
|
376
|
+
| Setting | Values | Notes |
|
|
377
|
+
|---|---|---|
|
|
378
|
+
| **Tone** | `formal`, `neutral`, `casual` | Adjusts per language (e.g., casual English, polite-form Japanese) |
|
|
379
|
+
| **Language** | Any supported | Primary language for agent responses |
|
|
380
|
+
| **Welcome message** | Up to 800 characters | Customizable initial greeting |
|
|
381
|
+
| **Error message** | Up to 800 characters | Fallback response on failure |
|
|
382
|
+
| **System message** | Agent persona, mission, tone, guardrails | In Agent Script: `system.instructions` block |
|
|
383
|
+
| **Default Agent User** | User record | Required for Service Agents; sets execution context |
|
|
384
|
+
|
|
385
|
+
## Agent Spec YAML
|
|
386
|
+
|
|
387
|
+
Generated by `sf agent generate agent-spec`. Input to `sf agent generate authoring-bundle`.
|
|
388
|
+
|
|
389
|
+
| Field | Type | Default | Description |
|
|
390
|
+
|---|---|---|---|
|
|
391
|
+
| `agentType` | `customer` \| `internal` | — | Target audience |
|
|
392
|
+
| `companyName` | string | — | Organization name |
|
|
393
|
+
| `companyDescription` | string | — | Brief company description for context |
|
|
394
|
+
| `role` | string | — | Agent's job description (drives topic generation) |
|
|
395
|
+
| `maxNumOfTopics` | number | 5 | Maximum topics to generate |
|
|
396
|
+
| `agentUser` | string | — | Default agent user email |
|
|
397
|
+
| `enrichLogs` | boolean | false | Enable enriched conversation logging |
|
|
398
|
+
| `tone` | `formal` \| `neutral` \| `casual` | casual | Response tone |
|
|
399
|
+
| `promptTemplateName` | string | — | Optional knowledge grounding template |
|
|
400
|
+
| `groundingContext` | string | — | Additional context for LLM |
|
|
401
|
+
| `topics[]` | array | (auto-generated) | Topic name + description pairs |
|
|
402
|
+
|
|
403
|
+
## Limits & Costs
|
|
404
|
+
|
|
405
|
+
| Limit | Value |
|
|
95
406
|
|---|---|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
407
|
+
| Agent API timeout | 120 seconds per request |
|
|
408
|
+
| Recommended topics per agent | Max 10 (context confusion beyond) |
|
|
409
|
+
| Recommended actions per topic | Max 12-15 (routing degrades) |
|
|
410
|
+
| Standard action cost | 20 Flex Credits (~$0.10) per action, up to 10K tokens |
|
|
411
|
+
| Voice action cost | 30 Flex Credits (~$0.15) per action |
|
|
412
|
+
| Per-conversation pricing | $2/conversation (alternative to per-action) |
|
|
413
|
+
| Breakeven | 20 actions/conversation ($2.00 Flex = $2.00 per-conversation) |
|
|
414
|
+
| Apex CPU timeout | 10 seconds synchronous limit per action |
|
|
415
|
+
| Welcome/error message | 800 characters max |
|
|
102
416
|
|
|
103
|
-
|
|
417
|
+
Standard Apex governor limits apply per action (each executes in its own transaction). For heavy computation, offload to Heroku Applink.
|
|
104
418
|
|
|
105
|
-
##
|
|
419
|
+
## Trust & Security
|
|
106
420
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
421
|
+
| Layer | Purpose |
|
|
422
|
+
|---|---|
|
|
423
|
+
| **Einstein Trust Layer** | Sits between agent UI and LLMs. Configurable data masking, zero data retention, input/output toxicity detection |
|
|
424
|
+
| **Instruction Adherence** | AI-generated scoring detects agent deviation from topic instructions (HIGH/LOW/UNCERTAIN) |
|
|
425
|
+
| **Sharing enforcement** | `with sharing` + `WITH USER_MODE` in Apex actions |
|
|
426
|
+
| **Field-Level Security** | Controls what data the agent can read/surface |
|
|
427
|
+
| **MCP Server Registry** | Admin-controlled whitelist for external MCP servers. Rate-limiting, access control |
|
|
428
|
+
| **Audit** | Agent conversations reviewable in Setup > Agent Conversations |
|
|
429
|
+
|
|
430
|
+
## Classic Setup (Pre-Agent Script)
|
|
431
|
+
|
|
432
|
+
For orgs on API v63 or earlier, or without Agent Script enabled, agents are configured entirely through the Setup UI. Topics and actions are managed in Agentforce Builder without `.agent` files. Use `GenAiPlanner` (v60-63) instead of `GenAiPlannerBundle`. All instruction guidelines, action patterns, context engineering principles, and testing approaches above still apply — only the development surface differs.
|
|
433
|
+
|
|
434
|
+
## Further Reading
|
|
435
|
+
|
|
436
|
+
Agentforce evolves rapidly across releases. When this reference does not cover a feature or syntax, check these sources or search the web for the latest documentation.
|
|
437
|
+
|
|
438
|
+
### Official Documentation
|
|
439
|
+
|
|
440
|
+
| Topic | URL |
|
|
441
|
+
|---|---|
|
|
442
|
+
| Agent Script Guide | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-script.html> |
|
|
443
|
+
| Agent Script Language Reference | <https://developer.salesforce.com/docs/ai/agentforce/guide/ascript-reference.html> |
|
|
444
|
+
| Agentforce DX Overview | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-dx.html> |
|
|
445
|
+
| Agent Metadata Types | <https://developer.salesforce.com/docs/ai/agentforce/references/agents-metadata-tooling/agents-metadata.html> |
|
|
446
|
+
| Agent Metadata (DX) | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-dx-metadata.html> |
|
|
447
|
+
| Generate Authoring Bundle | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-dx-nga-authbundle.html> |
|
|
448
|
+
| Publish Authoring Bundle | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-dx-nga-publish.html> |
|
|
449
|
+
| Generate Agent Spec | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-dx-generate-agent-spec.html> |
|
|
450
|
+
| Lightning Types | <https://developer.salesforce.com/docs/ai/agentforce/guide/lightning-types.html> |
|
|
451
|
+
| Apex Citations | <https://developer.salesforce.com/docs/ai/agentforce/guide/citations.html> |
|
|
452
|
+
| Test Spec Customization | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-dx-test-customize.html> |
|
|
453
|
+
| Testing API Reference | <https://developer.salesforce.com/docs/ai/agentforce/references/testing-api/testing-connect-reference.html> |
|
|
454
|
+
| MCP Solutions Guide | <https://developer.salesforce.com/docs/einstein/genai/guide/mcp.html> |
|
|
455
|
+
| Named Query Actions | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-namedquery.html> |
|
|
456
|
+
| InvocableMethod Actions | <https://developer.salesforce.com/docs/ai/agentforce/guide/agent-invocablemethod.html> |
|
|
457
|
+
| Agent Script Recipes | <https://developer.salesforce.com/sample-apps/agent-script-recipes/getting-started/overview> |
|
|
458
|
+
| Agentforce Considerations | <https://help.salesforce.com/s/articleView?id=ai.copilot_considerations.htm> |
|
|
459
|
+
|
|
460
|
+
### Developer Blogs
|
|
461
|
+
|
|
462
|
+
| Topic | URL |
|
|
463
|
+
|---|---|
|
|
464
|
+
| Agent Script Decoded (Feb 2026) | <https://developer.salesforce.com/blogs/2026/02/agent-script-decoded-intro-to-agent-script-language-fundamentals> |
|
|
465
|
+
| Spring '26 Developer Guide | <https://developer.salesforce.com/blogs/2026/01/developers-guide-to-the-spring-26-release> |
|
|
466
|
+
| TDX 2026 Developer Guide | <https://developer.salesforce.com/blogs/2026/03/the-salesforce-developers-guide-to-tdx-2026> |
|
|
467
|
+
| Agentforce Builder (Admin Blog) | <https://admin.salesforce.com/blog/2026/build-with-confidence-inside-the-new-agentforce-builder> |
|
|
468
|
+
| Best Practices: Apex Actions | <https://developer.salesforce.com/blogs/2025/07/best-practices-for-building-agentforce-apex-actions> |
|
|
469
|
+
| NL Instructions Guide | <https://developer.salesforce.com/blogs/2025/01/how-to-write-effective-natural-language-instructions-for-agentforce> |
|
|
470
|
+
| Context Engineering Guide | <https://developer.salesforce.com/blogs/2025/08/a-developers-guide-to-context-engineering-with-agentforce> |
|
|
471
|
+
| Variables & Filters | <https://developer.salesforce.com/blogs/2025/04/control-agent-access-and-decision-making-with-variables-and-filters> |
|
|
472
|
+
| MCP Support Across Salesforce | <https://developer.salesforce.com/blogs/2025/06/introducing-mcp-support-across-salesforce> |
|
|
473
|
+
| AuraEnabled as Agent Actions | <https://developer.salesforce.com/blogs/2025/09/auraenabled-apex-methods-are-now-available-as-agent-actions> |
|
|
474
|
+
| Adaptive Response Formats | <https://developer.salesforce.com/blogs/2025/10/customize-agent-conversations-with-adaptive-response-formats> |
|
|
475
|
+
|
|
476
|
+
### Architecture & Patterns
|
|
477
|
+
|
|
478
|
+
| Topic | URL |
|
|
479
|
+
|---|---|
|
|
480
|
+
| 5 Levels of Determinism | <https://www.salesforce.com/agentforce/five-levels-of-determinism/> |
|
|
481
|
+
| Agentic Patterns | <https://architect.salesforce.com/fundamentals/agentic-patterns> |
|
|
482
|
+
| Enterprise Agentic Architecture | <https://architect.salesforce.com/docs/architect/fundamentals/guide/enterprise-agentic-architecture> |
|
|
483
|
+
| Agent Interoperability (A2A) | <https://www.salesforce.com/blog/agent-interoperability/> |
|
|
484
|
+
| Multi-Agent Orchestration | <https://www.salesforce.com/agentforce/multi-agent-orchestration/> |
|
|
485
|
+
|
|
486
|
+
### Tools & Repositories
|
|
487
|
+
|
|
488
|
+
| Topic | URL |
|
|
489
|
+
|---|---|
|
|
490
|
+
| SF CLI plugin-agent (GitHub) | <https://github.com/salesforcecli/plugin-agent> |
|
|
491
|
+
| SF CLI Release Notes | <https://github.com/forcedotcom/cli/blob/main/releasenotes/README.md> |
|
|
492
|
+
| SF CLI Agent Commands Reference | <https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_agent_commands_unified.htm> |
|
|
493
|
+
| Agentforce DX VS Code Extension | <https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode-agents> |
|
|
494
|
+
| AgentExchange Marketplace | <https://agentexchange.salesforce.com> |
|