@salesforce/afv-skills 1.7.2 → 1.7.4
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 +4 -4
- package/skills/developing-agentforce/SKILL.md +37 -37
- package/skills/developing-agentforce/assets/README-legacy.md +8 -8
- package/skills/developing-agentforce/assets/agent-spec-template.md +9 -9
- package/skills/developing-agentforce/assets/agents/README.md +4 -4
- package/skills/developing-agentforce/assets/agents/hello-world.agent +3 -3
- package/skills/developing-agentforce/assets/agents/{multi-topic.agent → multi-subagent.agent} +30 -30
- package/skills/developing-agentforce/assets/agents/order-service.agent +25 -25
- package/skills/developing-agentforce/assets/agents/production-faq.agent +12 -12
- package/skills/developing-agentforce/assets/agents/simple-qa.agent +8 -8
- package/skills/developing-agentforce/assets/agents/verification-gate.agent +19 -19
- package/skills/developing-agentforce/assets/components/apex-action.agent +3 -3
- package/skills/developing-agentforce/assets/components/error-handling.agent +7 -7
- package/skills/developing-agentforce/assets/components/escalation-setup.agent +11 -11
- package/skills/developing-agentforce/assets/components/flow-action.agent +5 -5
- package/skills/developing-agentforce/assets/components/n-ary-conditions.agent +11 -11
- package/skills/developing-agentforce/assets/components/{topic-with-actions.agent → subagent-with-actions.agent} +9 -9
- package/skills/developing-agentforce/assets/deterministic-routing.agent +19 -19
- package/skills/developing-agentforce/assets/escalation-pattern.agent +13 -13
- package/skills/developing-agentforce/assets/flow-action-lookup.agent +3 -3
- package/skills/developing-agentforce/assets/hub-and-spoke.agent +18 -18
- package/skills/developing-agentforce/assets/local-info-agent-annotated.agent +37 -37
- package/skills/developing-agentforce/assets/metadata/genai-function-apex.xml +3 -3
- package/skills/developing-agentforce/assets/metadata/genai-function-flow.xml +1 -1
- package/skills/developing-agentforce/assets/metadata/genai-plugin.xml +10 -10
- package/skills/developing-agentforce/assets/minimal-starter.agent +4 -4
- package/skills/developing-agentforce/assets/patterns/README.md +21 -21
- package/skills/developing-agentforce/assets/patterns/action-callbacks.agent +4 -4
- package/skills/developing-agentforce/assets/patterns/advanced-input-bindings.agent +1 -1
- package/skills/developing-agentforce/assets/patterns/bidirectional-routing.agent +25 -25
- package/skills/developing-agentforce/assets/patterns/critical-input-collection.agent +8 -8
- package/skills/developing-agentforce/assets/patterns/delegation-routing.agent +21 -21
- package/skills/developing-agentforce/assets/patterns/lifecycle-events.agent +8 -8
- package/skills/developing-agentforce/assets/patterns/llm-controlled-actions.agent +5 -5
- package/skills/developing-agentforce/assets/patterns/multi-step-workflow.agent +3 -3
- package/skills/developing-agentforce/assets/patterns/open-gate-routing.agent +59 -58
- package/skills/developing-agentforce/assets/patterns/procedural-instructions.agent +15 -15
- package/skills/developing-agentforce/assets/patterns/prompt-template-action.agent +8 -8
- package/skills/developing-agentforce/assets/patterns/system-instruction-overrides.agent +40 -40
- package/skills/developing-agentforce/assets/prompt-rag-search.agent +9 -9
- package/skills/developing-agentforce/assets/{template-multi-topic.agent → template-multi-subagent.agent} +25 -25
- package/skills/developing-agentforce/assets/{template-single-topic.agent → template-single-subagent.agent} +14 -14
- package/skills/developing-agentforce/assets/verification-gate.agent +16 -16
- package/skills/developing-agentforce/references/action-prompt-templates.md +1 -1
- package/skills/developing-agentforce/references/actions-reference.md +4 -4
- package/skills/developing-agentforce/references/agent-design-and-spec-creation.md +107 -107
- package/skills/developing-agentforce/references/agent-metadata-and-lifecycle.md +5 -5
- package/skills/developing-agentforce/references/agent-script-core-language.md +79 -79
- package/skills/developing-agentforce/references/{agent-topic-map-diagrams.md → agent-subagent-map-diagrams.md} +65 -65
- package/skills/developing-agentforce/references/agent-user-setup.md +2 -2
- package/skills/developing-agentforce/references/agent-validation-and-debugging.md +55 -55
- package/skills/developing-agentforce/references/architecture-patterns.md +33 -33
- package/skills/developing-agentforce/references/deploy-reference.md +1 -1
- package/skills/developing-agentforce/references/discover-reference.md +1 -1
- package/skills/developing-agentforce/references/examples.md +32 -32
- package/skills/developing-agentforce/references/feature-validity.md +3 -3
- package/skills/developing-agentforce/references/instruction-resolution.md +29 -29
- package/skills/developing-agentforce/references/known-issues.md +10 -10
- package/skills/developing-agentforce/references/minimal-examples.md +6 -6
- package/skills/developing-agentforce/references/production-gotchas.md +22 -22
- package/skills/developing-agentforce/references/safety-review-reference.md +2 -2
- package/skills/developing-agentforce/references/scoring-rubric.md +3 -3
- package/skills/generating-custom-lightning-type/SKILL.md +12 -3
- package/skills/observing-agentforce/SKILL.md +8 -8
- package/skills/observing-agentforce/apex/AgentforceOptimizeService.cls +2 -2
- package/skills/observing-agentforce/references/improve-reference.md +40 -40
- package/skills/observing-agentforce/references/issue-classification.md +47 -47
- package/skills/observing-agentforce/references/reproduce-reference.md +7 -7
- package/skills/observing-agentforce/references/stdm-queries.md +7 -7
- package/skills/observing-agentforce/references/stdm-schema.md +2 -2
- package/skills/testing-agentforce/SKILL.md +9 -9
- package/skills/testing-agentforce/assets/basic-test-spec.yaml +4 -0
- package/skills/testing-agentforce/assets/guardrail-test-spec.yaml +4 -0
- package/skills/testing-agentforce/assets/standard-test-spec.yaml +8 -4
- package/skills/testing-agentforce/references/batch-testing.md +17 -17
- package/skills/testing-agentforce/references/preview-testing.md +25 -25
- package/skills/testing-agentforce/references/test-report-format.md +6 -6
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Agent
|
|
1
|
+
# Agent Subagent Map Diagrams Reference
|
|
2
2
|
|
|
3
3
|
## Table of Contents
|
|
4
4
|
|
|
5
5
|
- [Purpose and Context](#purpose-and-context)
|
|
6
6
|
- [Fundamental Structure Rules](#fundamental-structure-rules)
|
|
7
7
|
- [Node Types and Agent Script Elements](#node-types-and-agent-script-elements)
|
|
8
|
-
- [
|
|
8
|
+
- [Subagent Map Patterns](#subagent-map-patterns)
|
|
9
9
|
- [Complete Example: Local_Info_Agent](#complete-example-local_info_agent)
|
|
10
10
|
- [Validation Checklist](#validation-checklist)
|
|
11
11
|
- [Anti-patterns](#anti-patterns)
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
|
|
15
15
|
## Purpose and Context
|
|
16
16
|
|
|
17
|
-
A
|
|
17
|
+
A Subagent Map diagram is a Mermaid flowchart that visualizes an agent's subagent graph structure. It shows the architecture of an agent before implementation, displaying:
|
|
18
18
|
|
|
19
|
-
- The start_agent
|
|
20
|
-
- All
|
|
21
|
-
-
|
|
22
|
-
- Action calls within
|
|
19
|
+
- The start_agent agent_router entry point
|
|
20
|
+
- All subagents in the agent
|
|
21
|
+
- Subagent transitions and routing logic
|
|
22
|
+
- Action calls within subagents (with backing type: Apex, Prompt Template, Flow)
|
|
23
23
|
- Gating conditions (available_when expressions)
|
|
24
24
|
- Variable state changes
|
|
25
25
|
- Escalation and off-topic handling
|
|
26
26
|
- Conditional instructions based on variable values
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Subagent Map diagrams are the primary visual deliverable in an Agent Spec (design document) and serve both specification and comprehension purposes.
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -34,15 +34,15 @@ Topic Map diagrams are the primary visual deliverable in an Agent Spec (design d
|
|
|
34
34
|
### Graph Orientation
|
|
35
35
|
|
|
36
36
|
- ALWAYS use `graph TD` (Top-Down orientation)
|
|
37
|
-
- Start with start_agent
|
|
38
|
-
-
|
|
37
|
+
- Start with start_agent agent_router at the top
|
|
38
|
+
- Subagents flow downward from the router
|
|
39
39
|
- Never use other orientations
|
|
40
40
|
|
|
41
41
|
### Node Identification
|
|
42
42
|
|
|
43
43
|
- Use sequential capital letters (A, B, C, ...) for node IDs
|
|
44
44
|
- Start with `A` for start_agent
|
|
45
|
-
- Increment sequentially through
|
|
45
|
+
- Increment sequentially through subagents and decisions
|
|
46
46
|
- Use descriptive labels within brackets
|
|
47
47
|
|
|
48
48
|
### Flow Direction
|
|
@@ -50,36 +50,36 @@ Topic Map diagrams are the primary visual deliverable in an Agent Spec (design d
|
|
|
50
50
|
- Primary flow moves top-to-bottom
|
|
51
51
|
- Use `-->` for standard transitions
|
|
52
52
|
- Label decision branches with `|Label|` syntax
|
|
53
|
-
- Separate paths for different
|
|
53
|
+
- Separate paths for different subagents
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
57
|
## Node Types and Agent Script Elements
|
|
58
58
|
|
|
59
|
-
### Start Agent
|
|
59
|
+
### Start Agent Subagent Router Node
|
|
60
60
|
|
|
61
|
-
Format: `[start_agent<br/>
|
|
61
|
+
Format: `[start_agent<br/>agent_router]`
|
|
62
62
|
|
|
63
|
-
Represents the entry point where user input is evaluated and routed to appropriate
|
|
63
|
+
Represents the entry point where user input is evaluated and routed to appropriate subagents.
|
|
64
64
|
|
|
65
65
|
```mermaid
|
|
66
66
|
%%{init: {'theme':'neutral'}}%%
|
|
67
67
|
graph TD
|
|
68
|
-
A[start_agent<br/>
|
|
68
|
+
A[start_agent<br/>agent_router]
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
###
|
|
71
|
+
### Subagent Nodes
|
|
72
72
|
|
|
73
|
-
Format: `[
|
|
73
|
+
Format: `[subagent_name<br/>Subagent]`
|
|
74
74
|
|
|
75
|
-
Represents a
|
|
75
|
+
Represents a subagent within the agent.
|
|
76
76
|
|
|
77
77
|
```mermaid
|
|
78
78
|
%%{init: {'theme':'neutral'}}%%
|
|
79
79
|
graph TD
|
|
80
|
-
A[start_agent<br/>
|
|
81
|
-
B[order_status<br/>
|
|
82
|
-
C[billing<br/>
|
|
80
|
+
A[start_agent<br/>agent_router]
|
|
81
|
+
B[order_status<br/>Subagent]
|
|
82
|
+
C[billing<br/>Subagent]
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
### Action Call Nodes
|
|
@@ -93,7 +93,7 @@ Example: `[Call check_weather<br/>backing: Apex]`
|
|
|
93
93
|
```mermaid
|
|
94
94
|
%%{init: {'theme':'neutral'}}%%
|
|
95
95
|
graph TD
|
|
96
|
-
A[local_weather<br/>
|
|
96
|
+
A[local_weather<br/>Subagent] --> B[Call check_weather<br/>backing: Apex]
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### Decision/Gating Nodes
|
|
@@ -102,12 +102,12 @@ Use curly braces `{}` for conditions. Common formats:
|
|
|
102
102
|
|
|
103
103
|
- Variable availability gates: `{Check: variable_name != empty?}`
|
|
104
104
|
- Conditional instructions: `{variable_name == value?}`
|
|
105
|
-
-
|
|
105
|
+
- Subagent transition logic: `{user_intent matches?}`
|
|
106
106
|
|
|
107
107
|
```mermaid
|
|
108
108
|
%%{init: {'theme':'neutral'}}%%
|
|
109
109
|
graph TD
|
|
110
|
-
A[
|
|
110
|
+
A[subagent<br/>Subagent] --> B{Check: guest_interests<br/>!= empty?}
|
|
111
111
|
B -->|Yes| C[Call collect_events<br/>backing: Prompt Template]
|
|
112
112
|
B -->|No| D[Ask for clarification]
|
|
113
113
|
```
|
|
@@ -133,32 +133,32 @@ For escalation and system utilities.
|
|
|
133
133
|
```mermaid
|
|
134
134
|
%%{init: {'theme':'neutral'}}%%
|
|
135
135
|
graph TD
|
|
136
|
-
A[escalation<br/>
|
|
136
|
+
A[escalation<br/>Subagent] --> B[Call @utils.escalate]
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
---
|
|
140
140
|
|
|
141
|
-
##
|
|
141
|
+
## Subagent Map Patterns
|
|
142
142
|
|
|
143
|
-
### Basic
|
|
143
|
+
### Basic Subagent with Single Action
|
|
144
144
|
|
|
145
145
|
```mermaid
|
|
146
146
|
%%{init: {'theme':'neutral'}}%%
|
|
147
147
|
graph TD
|
|
148
|
-
A[start_agent<br/>
|
|
149
|
-
A -->|route to
|
|
148
|
+
A[start_agent<br/>agent_router]
|
|
149
|
+
A -->|route to subagent| B[simple_subagent<br/>Subagent]
|
|
150
150
|
B --> C[Call do_action<br/>backing: Apex]
|
|
151
151
|
C --> D[Continue]
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
###
|
|
154
|
+
### Subagent with Gating Condition
|
|
155
155
|
|
|
156
156
|
Available_when expressions prevent action execution until conditions are met.
|
|
157
157
|
|
|
158
158
|
```mermaid
|
|
159
159
|
%%{init: {'theme':'neutral'}}%%
|
|
160
160
|
graph TD
|
|
161
|
-
A[
|
|
161
|
+
A[subagent_with_gate<br/>Subagent]
|
|
162
162
|
A --> B{Check: required_var<br/>!= empty?}
|
|
163
163
|
B -->|No| C[Instruction: collect info first]
|
|
164
164
|
B -->|Yes| D[Call action<br/>backing: Prompt Template]
|
|
@@ -166,9 +166,9 @@ graph TD
|
|
|
166
166
|
E --> A
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
###
|
|
169
|
+
### Subagent with Conditional Instructions
|
|
170
170
|
|
|
171
|
-
Variable values control which instructions apply to a
|
|
171
|
+
Variable values control which instructions apply to a subagent.
|
|
172
172
|
|
|
173
173
|
```mermaid
|
|
174
174
|
%%{init: {'theme':'neutral'}}%%
|
|
@@ -180,18 +180,18 @@ graph TD
|
|
|
180
180
|
D --> E[Continue]
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
-
###
|
|
183
|
+
### Subagent Transitions
|
|
184
184
|
|
|
185
|
-
When logic determines a new
|
|
185
|
+
When logic determines a new subagent should be active.
|
|
186
186
|
|
|
187
187
|
```mermaid
|
|
188
188
|
%%{init: {'theme':'neutral'}}%%
|
|
189
189
|
graph TD
|
|
190
|
-
A[
|
|
190
|
+
A[current_subagent<br/>Subagent]
|
|
191
191
|
A --> B{Transition<br/>condition?}
|
|
192
|
-
B -->|Yes| C[Transition to<br/>
|
|
193
|
-
C --> D[
|
|
194
|
-
B -->|No| E[Continue in<br/>
|
|
192
|
+
B -->|Yes| C[Transition to<br/>next_subagent]
|
|
193
|
+
C --> D[next_subagent<br/>Subagent]
|
|
194
|
+
B -->|No| E[Continue in<br/>current_subagent]
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
### Off-Topic and Escalation Routing
|
|
@@ -201,9 +201,9 @@ How the agent handles out-of-scope requests.
|
|
|
201
201
|
```mermaid
|
|
202
202
|
%%{init: {'theme':'neutral'}}%%
|
|
203
203
|
graph TD
|
|
204
|
-
A[start_agent<br/>
|
|
205
|
-
A -->|out of scope| B[off_topic<br/>
|
|
206
|
-
A -->|needs help| C[escalation<br/>
|
|
204
|
+
A[start_agent<br/>agent_router]
|
|
205
|
+
A -->|out of scope| B[off_topic<br/>Subagent]
|
|
206
|
+
A -->|needs help| C[escalation<br/>Subagent]
|
|
207
207
|
B --> D[Instruction: redirect user]
|
|
208
208
|
C --> E[Call @utils.escalate]
|
|
209
209
|
```
|
|
@@ -212,19 +212,19 @@ graph TD
|
|
|
212
212
|
|
|
213
213
|
## Complete Example: Local_Info_Agent
|
|
214
214
|
|
|
215
|
-
This example demonstrates a complete
|
|
215
|
+
This example demonstrates a complete Subagent Map for a guest information agent with multiple subagents, gating conditions, variable state, and escalation handling.
|
|
216
216
|
|
|
217
217
|
```mermaid
|
|
218
218
|
%%{init: {'theme':'neutral'}}%%
|
|
219
219
|
graph TD
|
|
220
|
-
A[start_agent<br/>
|
|
220
|
+
A[start_agent<br/>agent_router]
|
|
221
221
|
|
|
222
|
-
A -->|weather query| B[local_weather<br/>
|
|
223
|
-
A -->|events query| C[local_events<br/>
|
|
224
|
-
A -->|hours query| D[resort_hours<br/>
|
|
225
|
-
A -->|unclear intent| E[ambiguous_question<br/>
|
|
226
|
-
A -->|out of scope| F[off_topic<br/>
|
|
227
|
-
A -->|needs escalation| G[escalation<br/>
|
|
222
|
+
A -->|weather query| B[local_weather<br/>Subagent]
|
|
223
|
+
A -->|events query| C[local_events<br/>Subagent]
|
|
224
|
+
A -->|hours query| D[resort_hours<br/>Subagent]
|
|
225
|
+
A -->|unclear intent| E[ambiguous_question<br/>Subagent]
|
|
226
|
+
A -->|out of scope| F[off_topic<br/>Subagent]
|
|
227
|
+
A -->|needs escalation| G[escalation<br/>Subagent]
|
|
228
228
|
|
|
229
229
|
B --> B1[Call check_weather<br/>backing: Apex]
|
|
230
230
|
B1 --> B2[Continue]
|
|
@@ -248,14 +248,14 @@ graph TD
|
|
|
248
248
|
E1 --> E2[Await user input]
|
|
249
249
|
E2 --> A
|
|
250
250
|
|
|
251
|
-
F --> F1[Instruction: explain available
|
|
251
|
+
F --> F1[Instruction: explain available subagents]
|
|
252
252
|
F1 --> F2[Continue]
|
|
253
253
|
|
|
254
254
|
G --> G1[Call @utils.escalate]
|
|
255
255
|
G1 --> G2[Continue]
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
###
|
|
258
|
+
### Subagent Descriptions
|
|
259
259
|
|
|
260
260
|
**local_weather**: Provides weather information via Apex-backed action. No preconditions.
|
|
261
261
|
|
|
@@ -265,30 +265,30 @@ graph TD
|
|
|
265
265
|
|
|
266
266
|
**ambiguous_question**: No actions. Requests clarification and routes back to start_agent.
|
|
267
267
|
|
|
268
|
-
**off_topic**: No actions. Explains available
|
|
268
|
+
**off_topic**: No actions. Explains available subagents and continues conversation.
|
|
269
269
|
|
|
270
270
|
**escalation**: Calls @utils.escalate utility to route to human agent.
|
|
271
271
|
|
|
272
|
-
**start_agent
|
|
272
|
+
**start_agent agent_router**: Routes incoming user input to appropriate subagents based on intent.
|
|
273
273
|
|
|
274
274
|
---
|
|
275
275
|
|
|
276
276
|
## Validation Checklist
|
|
277
277
|
|
|
278
|
-
Before finalizing a
|
|
278
|
+
Before finalizing a Subagent Map diagram:
|
|
279
279
|
|
|
280
280
|
- [ ] Uses `graph TD` syntax
|
|
281
281
|
- [ ] Starts with `%%{init: {'theme':'neutral'}}%%`
|
|
282
|
-
- [ ] start_agent
|
|
282
|
+
- [ ] start_agent agent_router is node A at top
|
|
283
283
|
- [ ] Nodes use sequential capital letter IDs
|
|
284
|
-
- [ ] All
|
|
284
|
+
- [ ] All subagents labeled with `[subagent_name<br/>Subagent]` format
|
|
285
285
|
- [ ] Action calls include backing type (Apex, Prompt Template, Flow)
|
|
286
286
|
- [ ] Gating conditions shown as decision nodes with `{Check: ...?}` format
|
|
287
287
|
- [ ] Variable state changes explicitly labeled with `[Set variable = value]`
|
|
288
288
|
- [ ] Escalation uses `[Call @utils.escalate]` format
|
|
289
289
|
- [ ] All transition branches are labeled
|
|
290
290
|
- [ ] Diagram fits in 20-30 nodes
|
|
291
|
-
- [ ]
|
|
291
|
+
- [ ] Subagent routing from start_agent is clear
|
|
292
292
|
- [ ] Off-topic and escalation paths are visible
|
|
293
293
|
- [ ] Conditional instruction logic is shown
|
|
294
294
|
|
|
@@ -304,20 +304,20 @@ Before finalizing a Topic Map diagram:
|
|
|
304
304
|
- Use ambiguous decision node labels (avoid `{Process?}`)
|
|
305
305
|
- Hide gating conditions in node descriptions instead of showing as decisions
|
|
306
306
|
- Omit variable state changes that affect downstream behavior
|
|
307
|
-
- Create
|
|
308
|
-
- Mix
|
|
307
|
+
- Create subagent routing without labels on the decision logic
|
|
308
|
+
- Mix subagent nodes with action nodes at same level without clear containment
|
|
309
309
|
- Use custom color styling (breaks in dark mode)
|
|
310
310
|
- Leave off-topic and escalation paths out of diagram
|
|
311
311
|
|
|
312
312
|
### Do
|
|
313
313
|
|
|
314
|
-
- Keep start_agent
|
|
315
|
-
- Show all
|
|
314
|
+
- Keep start_agent agent_router at the top
|
|
315
|
+
- Show all subagents reachable from start_agent
|
|
316
316
|
- Include backing type for every action call
|
|
317
317
|
- Make gating conditions explicit as decision nodes
|
|
318
318
|
- Show variable updates as separate nodes when they affect logic flow
|
|
319
319
|
- Label all transition branches
|
|
320
|
-
- Include off-topic and escalation
|
|
320
|
+
- Include off-topic and escalation subagents
|
|
321
321
|
- Show conditional instructions with decision nodes
|
|
322
322
|
- Use `%%{init: {'theme':'neutral'}}%%` for light/dark mode compatibility
|
|
323
|
-
- Focus diagram on
|
|
323
|
+
- Focus diagram on subagent structure, not detailed action logic
|
|
@@ -89,7 +89,7 @@ sf project deploy start --json \
|
|
|
89
89
|
sf agent preview start --json \
|
|
90
90
|
--api-name <AgentName> \
|
|
91
91
|
-o TARGET_ORG
|
|
92
|
-
# Test all
|
|
92
|
+
# Test all subagents and actions to verify permissions
|
|
93
93
|
|
|
94
94
|
# Step 8: Publish & Activate (only after testing passes)
|
|
95
95
|
sf agent publish authoring-bundle --json \
|
|
@@ -292,7 +292,7 @@ sf agent preview start --json \
|
|
|
292
292
|
```
|
|
293
293
|
|
|
294
294
|
What to test:
|
|
295
|
-
1. All
|
|
295
|
+
1. All subagents trigger correctly
|
|
296
296
|
2. All Apex actions execute without "Insufficient Privileges" errors
|
|
297
297
|
3. Agent responds with expected data
|
|
298
298
|
4. No compilation errors
|
|
@@ -55,11 +55,11 @@ Do not attempt to preview or deploy until validation passes.
|
|
|
55
55
|
|
|
56
56
|
Before running the validation command, mentally check these 14 items. This checklist prevents the most common errors and speeds up the feedback loop:
|
|
57
57
|
|
|
58
|
-
- Block ordering is correct: `system` → `config` → `variables` → `connections` → `knowledge` → `language` → `start_agent` → `
|
|
58
|
+
- Block ordering is correct: `system` → `config` → `variables` → `connections` → `knowledge` → `language` → `start_agent` → `subagent` blocks
|
|
59
59
|
- `config` block has `developer_name` (required for service agents: also needs `default_agent_user`)
|
|
60
60
|
- `system` block has `messages.welcome`, `messages.error`, and `instructions`
|
|
61
61
|
- `start_agent` block exists with description and at least one transition action
|
|
62
|
-
- Each `
|
|
62
|
+
- Each `subagent` has a `description` and `reasoning` block
|
|
63
63
|
- All `mutable` variables have default values (required)
|
|
64
64
|
- All `linked` variables have `source` specified and NO default value
|
|
65
65
|
- Action `target` uses valid format (`flow://`, `apex://`, `prompt://`, etc.)
|
|
@@ -82,14 +82,14 @@ Validation errors fall into several categories: block ordering, indentation, syn
|
|
|
82
82
|
|
|
83
83
|
```agentscript
|
|
84
84
|
# WRONG — bare transition in reasoning.actions
|
|
85
|
-
go_next: transition to @
|
|
85
|
+
go_next: transition to @subagent.next
|
|
86
86
|
|
|
87
87
|
# CORRECT — use @utils.transition to in reasoning.actions
|
|
88
|
-
go_next: @utils.transition to @
|
|
88
|
+
go_next: @utils.transition to @subagent.next
|
|
89
89
|
|
|
90
90
|
# CORRECT — use bare transition in directive blocks
|
|
91
91
|
after_reasoning:
|
|
92
|
-
transition to @
|
|
92
|
+
transition to @subagent.next
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
In reasoning actions (where the LLM decides what to do), use `@utils.transition to`. In directive blocks (`before_reasoning`, `after_reasoning`), use bare `transition to`. These are two different syntaxes for two different contexts.
|
|
@@ -160,7 +160,7 @@ Linked variables are populated from their `source` at runtime. Do not assign a d
|
|
|
160
160
|
|
|
161
161
|
```agentscript
|
|
162
162
|
# WRONG — utilities don't support post-action directives
|
|
163
|
-
go_next: @utils.transition to @
|
|
163
|
+
go_next: @utils.transition to @subagent.next
|
|
164
164
|
set @variables.navigated = True
|
|
165
165
|
|
|
166
166
|
# CORRECT — only @actions support post-action directives
|
|
@@ -168,7 +168,7 @@ process: @actions.process_order
|
|
|
168
168
|
set @variables.result = @outputs.result
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
Post-action directives (`set`, `run`, `if`, `transition`) only work after `@actions.*` invocations. Utility actions (`@utils.*`) and
|
|
171
|
+
Post-action directives (`set`, `run`, `if`, `transition`) only work after `@actions.*` invocations. Utility actions (`@utils.*`) and subagent delegates (`@subagent.*`) do not produce outputs, so post-action directives are not applicable.
|
|
172
172
|
|
|
173
173
|
---
|
|
174
174
|
|
|
@@ -336,7 +336,7 @@ If multiple agents have concurrent sessions against the same agent, omitting the
|
|
|
336
336
|
|
|
337
337
|
### Context Variable Limitations in Preview
|
|
338
338
|
|
|
339
|
-
Agent behavior requiring `@context` or `@session` variables for routing or guards CAN NOT be tested via `sf agent preview`. Commands in the `preview`
|
|
339
|
+
Agent behavior requiring `@context` or `@session` variables for routing or guards CAN NOT be tested via `sf agent preview`. Commands in the `preview` command DO NOT support context or session variable injection. Flags like `--context`, `--session-var`, or `--variables` DO NOT EXIST.
|
|
340
340
|
|
|
341
341
|
- `@session.sessionID`, `@context.customerId`, `@context.RoutableId` — do NOT work in preview.
|
|
342
342
|
- Mutable variables with default values — work normally in preview.
|
|
@@ -346,16 +346,16 @@ Agent behavior requiring `@context` or `@session` variables for routing or guard
|
|
|
346
346
|
|
|
347
347
|
Utterances provided to `sf agent preview send` must be derived from the `.agent` file using these guidelines:
|
|
348
348
|
|
|
349
|
-
1. **One per non-start
|
|
349
|
+
1. **One per non-start subagent** — based on `description:` keywords. Pick the most natural user phrasing.
|
|
350
350
|
2. **One that should trigger each key action** — match the action's `description:` to a realistic user request.
|
|
351
351
|
3. **One off-topic utterance** — tests guardrails (e.g., "Tell me a joke", "What's the weather?").
|
|
352
|
-
4. **One multi-turn pair** — if agent has
|
|
352
|
+
4. **One multi-turn pair** — if agent has subagent transitions, send two related utterances to test handoff (e.g., "Check my order" → "Actually I want to return it").
|
|
353
353
|
|
|
354
354
|
---
|
|
355
355
|
|
|
356
356
|
## 4. Session Traces
|
|
357
357
|
|
|
358
|
-
After each utterance in a preview session, the runtime writes trace files. Traces show the complete execution path: what
|
|
358
|
+
After each utterance in a preview session, the runtime writes trace files. Traces show the complete execution path: what subagent was selected, what variables were set, what the LLM saw in its prompt, what it decided to do, and whether the response passed grounding.
|
|
359
359
|
|
|
360
360
|
### Trace File Location
|
|
361
361
|
|
|
@@ -386,7 +386,7 @@ Traces are available immediately after each `send` — you do NOT need to end th
|
|
|
386
386
|
|
|
387
387
|
To connect a failed turn to its trace, find the agent response in the transcript and read the `planId` from its `raw` array. That `planId` is the filename under `traces/`.
|
|
388
388
|
|
|
389
|
-
**traces/<PLAN_ID>.json** is the detailed execution log for a single turn. It contains top-level fields (`type`, `planId`, `sessionId`, `intent`, `
|
|
389
|
+
**traces/<PLAN_ID>.json** is the detailed execution log for a single turn. It contains top-level fields (`type`, `planId`, `sessionId`, `intent`, `subagent`) and a `plan` array with execution steps in chronological order.
|
|
390
390
|
|
|
391
391
|
### Step Types (Reference Table)
|
|
392
392
|
|
|
@@ -394,14 +394,14 @@ Each trace step type reveals specific execution information:
|
|
|
394
394
|
|
|
395
395
|
- **`UserInputStep`** — The user's utterance that triggered this turn.
|
|
396
396
|
- **`SessionInitialStateStep`** — Variable values and directive context at turn start.
|
|
397
|
-
- **`NodeEntryStateStep`** — Which agent/
|
|
397
|
+
- **`NodeEntryStateStep`** — Which agent/subagent is executing and its full state snapshot.
|
|
398
398
|
- **`VariableUpdateStep`** — A variable was changed — shows old/new value and reason.
|
|
399
399
|
- **`BeforeReasoningIterationStep`** — `before_reasoning` block ran — lists actions executed.
|
|
400
400
|
- **`EnabledToolsStep`** — Which tools/actions are available to the LLM for this reasoning cycle.
|
|
401
401
|
- **`LLMStep`** — The LLM call — full prompt, response, available tools, latency.
|
|
402
402
|
- **`FunctionStep`** — An action executed — shows input, output, and latency.
|
|
403
403
|
- **`ReasoningStep`** — Grounding check result — `GROUNDED` or `UNGROUNDED` with reason.
|
|
404
|
-
- **`TransitionStep`** —
|
|
404
|
+
- **`TransitionStep`** — Subagent transition — shows from/to subagents and transition type.
|
|
405
405
|
- **`PlannerResponseStep`** — Final response delivered to user — includes safety scores.
|
|
406
406
|
|
|
407
407
|
|
|
@@ -410,19 +410,19 @@ Each trace step type reveals specific execution information:
|
|
|
410
410
|
Read steps in chronological order:
|
|
411
411
|
|
|
412
412
|
1. Locate `UserInputStep` — the trigger for this turn
|
|
413
|
-
2. Check `NodeEntryStateStep` — which
|
|
413
|
+
2. Check `NodeEntryStateStep` — which subagent is running and what is the current variable state?
|
|
414
414
|
3. Look for `EnabledToolsStep` — what actions are available to the LLM?
|
|
415
415
|
4. Find `LLMStep` — examine `messages_sent` (the full prompt), `tools_sent` (available actions), and `response_messages` (what the LLM chose to do)
|
|
416
416
|
5. If an action was called, find the corresponding `FunctionStep` — compare inputs sent and outputs received
|
|
417
417
|
6. Check `ReasoningStep` — did the response pass grounding?
|
|
418
|
-
7. Look for `TransitionStep` — did the agent move to another
|
|
418
|
+
7. Look for `TransitionStep` — did the agent move to another subagent?
|
|
419
419
|
8. Check `PlannerResponseStep` — what did the user receive?
|
|
420
420
|
|
|
421
421
|
### The LLMStep in Detail
|
|
422
422
|
|
|
423
423
|
The `LLMStep` is the most diagnostic step type. It contains:
|
|
424
424
|
|
|
425
|
-
- `agent_name` — which
|
|
425
|
+
- `agent_name` — which subagent or router is running
|
|
426
426
|
- `messages_sent` — the FULL prompt sent to the LLM (system message, conversation history, and injected instructions)
|
|
427
427
|
- `tools_sent` — action names available to the LLM
|
|
428
428
|
- `response_messages` — the LLM's response (text or tool invocation)
|
|
@@ -437,10 +437,10 @@ The `messages_sent` array shows you exactly what the LLM saw. This is invaluable
|
|
|
437
437
|
|
|
438
438
|
### When to Use Traces vs. Transcript
|
|
439
439
|
|
|
440
|
-
Use the **transcript** to quickly identify WHICH turn failed (unexpected response, wrong
|
|
440
|
+
Use the **transcript** to quickly identify WHICH turn failed (unexpected response, wrong subagent, agent crash).
|
|
441
441
|
|
|
442
442
|
Use the **trace files** when:
|
|
443
|
-
- The agent routes to the wrong
|
|
443
|
+
- The agent routes to the wrong subagent
|
|
444
444
|
- An action isn't firing
|
|
445
445
|
- The response is unexpectedly worded
|
|
446
446
|
- Grounding is failing
|
|
@@ -453,13 +453,13 @@ The transcript is sufficient for conversation-level understanding. Traces provid
|
|
|
453
453
|
|
|
454
454
|
Use these `jq` commands against trace files (`traces/<PLAN_ID>.json`) to quickly extract diagnostic information.
|
|
455
455
|
|
|
456
|
-
#### Check 1:
|
|
456
|
+
#### Check 1: Subagent Routing
|
|
457
457
|
|
|
458
458
|
```bash
|
|
459
459
|
jq '[.steps[] | select(.stepType == "TransitionStep") | .data.to]' "$TRACE"
|
|
460
460
|
```
|
|
461
461
|
|
|
462
|
-
**Expected**: Array contains the target
|
|
462
|
+
**Expected**: Array contains the target subagent name (e.g., `["order_mgmt"]`). Empty array means the agent stayed in Subagent Router — subagent descriptions are too vague. Wrong subagent name means keyword overlap between subagents.
|
|
463
463
|
|
|
464
464
|
#### Check 2: Action Invocation
|
|
465
465
|
|
|
@@ -467,7 +467,7 @@ jq '[.steps[] | select(.stepType == "TransitionStep") | .data.to]' "$TRACE"
|
|
|
467
467
|
jq '[.steps[] | select(.stepType == "FunctionStep") | .data.function]' "$TRACE"
|
|
468
468
|
```
|
|
469
469
|
|
|
470
|
-
**Expected**: Array contains the target action name. If missing: `available when:` guards too restrictive, action `description:` doesn't match user request, or action not listed in `reasoning.actions:` for this
|
|
470
|
+
**Expected**: Array contains the target action name. If missing: `available when:` guards too restrictive, action `description:` doesn't match user request, or action not listed in `reasoning.actions:` for this subagent.
|
|
471
471
|
|
|
472
472
|
#### Check 3: Wrong Action Selected
|
|
473
473
|
|
|
@@ -495,7 +495,7 @@ jq '.steps[] | select(.stepType == "PlannerResponseStep") | .data.safetyScore' "
|
|
|
495
495
|
jq '[.steps[] | select(.stepType == "EnabledToolsStep") | .data.enabled_tools]' "$TRACE"
|
|
496
496
|
```
|
|
497
497
|
|
|
498
|
-
**Expected**: Array includes the action names defined in the
|
|
498
|
+
**Expected**: Array includes the action names defined in the subagent's `reasoning.actions:`. If missing: `available when:` conditions not met, action defined in wrong subagent, or action `target:` protocol invalid (flow not deployed, apex class not found).
|
|
499
499
|
|
|
500
500
|
---
|
|
501
501
|
|
|
@@ -503,46 +503,46 @@ jq '[.steps[] | select(.stepType == "EnabledToolsStep") | .data.enabled_tools]'
|
|
|
503
503
|
|
|
504
504
|
These patterns map symptoms to trace analysis techniques. Each pattern follows the same structure: symptom → which trace steps to examine → root cause → fix (with code example).
|
|
505
505
|
|
|
506
|
-
### Pattern: Wrong
|
|
506
|
+
### Pattern: Wrong Subagent Routing
|
|
507
507
|
|
|
508
|
-
**Symptom:** The agent enters the wrong
|
|
508
|
+
**Symptom:** The agent enters the wrong subagent. For example, asking about weather sends the agent to the events subagent instead.
|
|
509
509
|
|
|
510
510
|
**Trace Analysis:**
|
|
511
511
|
|
|
512
|
-
1. Find the `LLMStep` where `agent_name` is `
|
|
513
|
-
2. Examine `tools_sent` — are the transition actions for all expected
|
|
512
|
+
1. Find the `LLMStep` where `agent_name` is `agent_router` (the entry point that routes to subagents)
|
|
513
|
+
2. Examine `tools_sent` — are the transition actions for all expected subagents listed? (e.g., `go_to_local_weather`, `go_to_local_events`, `go_to_resort_hours`)
|
|
514
514
|
3. Examine `response_messages` — which action tool did the LLM select?
|
|
515
|
-
4. Examine `messages_sent` — does the system prompt (what
|
|
515
|
+
4. Examine `messages_sent` — does the system prompt (what subagent router instructions were compiled to) give the LLM enough context to route correctly?
|
|
516
516
|
|
|
517
|
-
**Root Cause:**
|
|
517
|
+
**Root Cause:** Subagent router instructions are ambiguous, missing context, or don't map user requests to the correct subagents.
|
|
518
518
|
|
|
519
|
-
**Fix:** A minimal
|
|
519
|
+
**Fix:** A minimal subagent router with well-named actions often routes correctly. When it doesn't, add routing instructions and action descriptions to give the LLM more context:
|
|
520
520
|
|
|
521
521
|
```agentscript
|
|
522
522
|
# BEFORE — relies on action names alone for routing
|
|
523
|
-
start_agent
|
|
524
|
-
description: "Route to appropriate
|
|
523
|
+
start_agent agent_router:
|
|
524
|
+
description: "Route to appropriate subagents"
|
|
525
525
|
reasoning:
|
|
526
526
|
actions:
|
|
527
|
-
go_to_weather: @utils.transition to @
|
|
528
|
-
go_to_events: @utils.transition to @
|
|
527
|
+
go_to_weather: @utils.transition to @subagent.local_weather
|
|
528
|
+
go_to_events: @utils.transition to @subagent.local_events
|
|
529
529
|
|
|
530
530
|
# AFTER — explicit instructions and descriptions improve routing accuracy
|
|
531
|
-
start_agent
|
|
532
|
-
description: "Route to appropriate
|
|
531
|
+
start_agent agent_router:
|
|
532
|
+
description: "Route to appropriate subagents"
|
|
533
533
|
reasoning:
|
|
534
534
|
instructions: ->
|
|
535
|
-
| If the user asks about weather conditions, temperature, or forecasts, go to the weather
|
|
536
|
-
If the user asks about local events, activities, or entertainment, go to the events
|
|
537
|
-
If the user asks about facility hours, reservations, or amenities, go to the hours
|
|
535
|
+
| If the user asks about weather conditions, temperature, or forecasts, go to the weather subagent.
|
|
536
|
+
If the user asks about local events, activities, or entertainment, go to the events subagent.
|
|
537
|
+
If the user asks about facility hours, reservations, or amenities, go to the hours subagent.
|
|
538
538
|
|
|
539
539
|
actions:
|
|
540
|
-
go_to_weather: @utils.transition to @
|
|
541
|
-
description: "Route to weather
|
|
542
|
-
go_to_events: @utils.transition to @
|
|
543
|
-
description: "Route to events
|
|
544
|
-
go_to_hours: @utils.transition to @
|
|
545
|
-
description: "Route to hours
|
|
540
|
+
go_to_weather: @utils.transition to @subagent.local_weather
|
|
541
|
+
description: "Route to weather subagent for weather questions"
|
|
542
|
+
go_to_events: @utils.transition to @subagent.local_events
|
|
543
|
+
description: "Route to events subagent for local event questions"
|
|
544
|
+
go_to_hours: @utils.transition to @subagent.resort_hours
|
|
545
|
+
description: "Route to hours subagent for facility hours questions"
|
|
546
546
|
```
|
|
547
547
|
|
|
548
548
|
|
|
@@ -552,7 +552,7 @@ start_agent topic_selector:
|
|
|
552
552
|
|
|
553
553
|
**Trace Analysis:**
|
|
554
554
|
|
|
555
|
-
1. Find the `EnabledToolsStep` for the
|
|
555
|
+
1. Find the `EnabledToolsStep` for the subagent — is the expected action listed?
|
|
556
556
|
2. If missing:
|
|
557
557
|
- Check the action definition's `available when` condition (e.g., `available when @variables.guest_interests != ""`)
|
|
558
558
|
- Look at the `NodeEntryStateStep` to see if the gating variable has the expected value
|
|
@@ -595,12 +595,12 @@ reasoning:
|
|
|
595
595
|
|
|
596
596
|
**Symptom:** The agent keeps asking the same question or repeating the same response across multiple turns, even though the user already provided the requested information.
|
|
597
597
|
|
|
598
|
-
**Diagnosis:** Observe the conversation output first — the behavioral symptom is often obvious (e.g., the agent asking the same question repeatedly). A common cause is instructions that collect information and act on it within the same
|
|
598
|
+
**Diagnosis:** Observe the conversation output first — the behavioral symptom is often obvious (e.g., the agent asking the same question repeatedly). A common cause is instructions that collect information and act on it within the same subagent — when the subagent is re-entered, the collection logic runs again even though the data was already gathered.
|
|
599
599
|
|
|
600
|
-
**Fix Example:** In this real scenario, the `local_events`
|
|
600
|
+
**Fix Example:** In this real scenario, the `local_events` subagent asks about interests and then looks up events. But each time the subagent is re-entered, the agent asks about interests again instead of checking whether it already knows them:
|
|
601
601
|
|
|
602
602
|
```agentscript
|
|
603
|
-
# BEFORE — agent asks about interests every time the
|
|
603
|
+
# BEFORE — agent asks about interests every time the subagent is entered
|
|
604
604
|
reasoning:
|
|
605
605
|
instructions: ->
|
|
606
606
|
| If you do not already know the guest's interests, ask them about their
|
|
@@ -648,11 +648,11 @@ Note: repeated `LLMStep` → `ReasoningStep` pairs in a trace may indicate groun
|
|
|
648
648
|
1. Find the `PlannerResponseStep` — is the message the system error message?
|
|
649
649
|
2. Look backward through the trace for consecutive `ReasoningStep` entries with `category: "UNGROUNDED"` — two consecutive UNGROUNDED results cause this error
|
|
650
650
|
3. If no grounding failures, look for `FunctionStep` entries with error outputs (action execution failed)
|
|
651
|
-
4. Check if a
|
|
651
|
+
4. Check if a subagent transition failed (the target subagent doesn't exist or has a circular reference)
|
|
652
652
|
|
|
653
|
-
**Root Cause:** Grounding failed twice in a row, OR an action returned an error, OR a
|
|
653
|
+
**Root Cause:** Grounding failed twice in a row, OR an action returned an error, OR a subagent transition is misconfigured.
|
|
654
654
|
|
|
655
|
-
**Fix:** See Diagnostic Workflow: Grounding subsection for grounding failures. For action errors, verify the backing Apex/Flow/Prompt Template is deployed and handles edge cases correctly. For transition errors, verify all referenced
|
|
655
|
+
**Fix:** See Diagnostic Workflow: Grounding subsection for grounding failures. For action errors, verify the backing Apex/Flow/Prompt Template is deployed and handles edge cases correctly. For transition errors, verify all referenced subagents exist and are spelled correctly.
|
|
656
656
|
|
|
657
657
|
### Pattern: Agent Responds with Generic Message but No Data After Successful Action
|
|
658
658
|
|
|
@@ -669,7 +669,7 @@ Note: repeated `LLMStep` → `ReasoningStep` pairs in a trace may indicate groun
|
|
|
669
669
|
|
|
670
670
|
| Failure | Target Block | Edit Strategy | Example |
|
|
671
671
|
|---------|-------------|---------------|---------|
|
|
672
|
-
|
|
|
672
|
+
| Subagent not matched | `subagent X: description:` | Add keywords from test utterance | `"Handle orders"` → `"Handle order queries, order status, package tracking, shipping updates"` |
|
|
673
673
|
| Action not invoked | `reasoning.actions: X description:` | Make description more trigger-specific | `"Get order"` → `"Look up order status when user asks about their order, package, or delivery"` |
|
|
674
674
|
| Action not invoked | `available when:` | Relax guard condition | Remove overly restrictive `@variables.X == True` if variable isn't set yet |
|
|
675
675
|
| Wrong action selected | Both competing `description:` fields | Differentiate with exclusion language | Add `"NOT for returns"` to order action, `"ONLY for returns"` to refund action |
|
|
@@ -690,7 +690,7 @@ Use this systematic 8-step approach when diagnosing any agent behavior issue.
|
|
|
690
690
|
3. **Read the Trace** — Open `traces/<PLAN_ID>.json` for the failing turn. Read the plan array in order.
|
|
691
691
|
|
|
692
692
|
4. **Follow Execution** — As you read each step, note:
|
|
693
|
-
- Which
|
|
693
|
+
- Which subagent was selected? (Look at `NodeEntryStateStep`)
|
|
694
694
|
- What state were variables in? (Look at `SessionInitialStateStep` and `VariableUpdateStep`)
|
|
695
695
|
- What actions were available vs. invoked? (Look at `EnabledToolsStep` and `LLMStep` response)
|
|
696
696
|
- What did the LLM see in its prompt? (Look at `LLMStep.messages_sent`)
|
|
@@ -723,7 +723,7 @@ When the platform's grounding checker flags a response as UNGROUNDED:
|
|
|
723
723
|
```
|
|
724
724
|
2. The LLM is given another chance to respond
|
|
725
725
|
3. If the second attempt is also UNGROUNDED, the agent returns the system error message ("I apologize, but I encountered an unexpected error") and gives up
|
|
726
|
-
4. This retry is visible in traces as repeated `LLMStep` → `ReasoningStep` pairs for the same
|
|
726
|
+
4. This retry is visible in traces as repeated `LLMStep` → `ReasoningStep` pairs for the same subagent
|
|
727
727
|
5. When this happens, the actual action output is still in the trace's `FunctionStep.function.output`. The LLM's failed response attempts are in the `LLMStep.response_messages`. Use these to understand what the agent tried to say versus what the action actually returned.
|
|
728
728
|
|
|
729
729
|
|