@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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
1. Agent Spec: Structure and Lifecycle
|
|
6
6
|
2. Discovery Questions
|
|
7
7
|
3. Environment Prerequisites
|
|
8
|
-
4.
|
|
8
|
+
4. Subagent Architecture
|
|
9
9
|
5. Mapping Logic to Actions
|
|
10
10
|
6. Transition Patterns
|
|
11
11
|
7. Deterministic vs. Subjective Flow Control
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
|
|
17
17
|
## 1. Agent Spec: Structure and Lifecycle
|
|
18
18
|
|
|
19
|
-
An **Agent Spec** is a structured design document describing an agent's purpose,
|
|
19
|
+
An **Agent Spec** is a structured design document describing an agent's purpose, subagents, actions, state, control flow, and behavioral intent. When creating a new agent, produce the Agent Spec before writing Agent Script code. When comprehending or diagnosing an existing agent, reverse-engineer an Agent Spec from the `.agent` file to make the agent's design explicit.
|
|
20
20
|
|
|
21
21
|
### What an Agent Spec Contains
|
|
22
22
|
|
|
23
23
|
- **Purpose & Scope** — what the agent does, in plain language
|
|
24
24
|
- **Behavioral Intent** — what the agent is supposed to achieve (requirements and constraints), not just what the code does
|
|
25
|
-
- **
|
|
25
|
+
- **Subagent Map** — a Mermaid flowchart showing all subagents, transitions (with type labels: handoff or delegation), and when transitions occur
|
|
26
26
|
- **Actions & Backing Logic** — each action's name, its backing implementation (Apex class, Flow, Prompt Template), inputs/outputs with visibility decisions, and whether the backing logic exists or needs creation
|
|
27
|
-
- **Variables** — declarations, types, default values, which
|
|
27
|
+
- **Variables** — declarations, types, default values, which subagents set/read them, and what gates they control
|
|
28
28
|
- **Gating Logic** — conditions that govern action visibility or instruction evaluation, with rationale for each. Always include this section; if no gating applies, state "No gating required" so reviewers know it was considered, not overlooked.
|
|
29
29
|
|
|
30
30
|
### Directional vs. Observational Entries
|
|
@@ -41,11 +41,11 @@ Both go in the same Agent Spec section.
|
|
|
41
41
|
|
|
42
42
|
The Agent Spec evolves across the agent's lifecycle:
|
|
43
43
|
|
|
44
|
-
**Creation (sparse).** Purpose,
|
|
44
|
+
**Creation (sparse).** Purpose, subagent names, rough descriptions, directional notes about backing logic ("this action needs an Apex class that accepts X, returns Y"). No flowchart yet. Entries are mostly placeholders.
|
|
45
45
|
|
|
46
46
|
**Build (filled).** Flowchart added with transition types labeled. Backing logic mapped (existing implementations identified with filenames, missing implementations stubbed with protocols and I/O specs). Variables documented with their usage and gating impact. Gating rationale explained.
|
|
47
47
|
|
|
48
|
-
**Comprehension (reverse-engineered).** Starting from an existing `.agent` file, produce a complete Agent Spec by parsing
|
|
48
|
+
**Comprehension (reverse-engineered).** Starting from an existing `.agent` file, produce a complete Agent Spec by parsing subagents, tracing transitions, analyzing actions, and documenting state. This is the "what does this agent do?" output.
|
|
49
49
|
|
|
50
50
|
**Diagnosis (reference).** Compare actual runtime behavior against the Agent Spec to find where intent and implementation diverge.
|
|
51
51
|
|
|
@@ -69,19 +69,19 @@ These five question categories drive the content of your Agent Spec. When creati
|
|
|
69
69
|
- What personality should the agent have? (professional, friendly, formal, casual)
|
|
70
70
|
- What error message should the agent show if something breaks?
|
|
71
71
|
|
|
72
|
-
###
|
|
72
|
+
### Subagents & Conversation Flow *(feeds Subagent Map)*
|
|
73
73
|
|
|
74
|
-
- What distinct conversation areas (
|
|
75
|
-
- Which
|
|
76
|
-
- What are the possible transitions between
|
|
77
|
-
- Are there
|
|
78
|
-
- Are there guardrail
|
|
74
|
+
- What distinct conversation areas (subagents) does the agent need?
|
|
75
|
+
- Which subagent is the entry point? (where conversations start)
|
|
76
|
+
- What are the possible transitions between subagents?
|
|
77
|
+
- Are there subagents that delegate to others and need to return?
|
|
78
|
+
- Are there guardrail subagents (off-topic redirection, ambiguity handling, security gates)?
|
|
79
79
|
|
|
80
80
|
### Reasoning & Instructions *(feeds Behavioral Intent)*
|
|
81
81
|
|
|
82
|
-
- What should the agent do in each
|
|
82
|
+
- What should the agent do in each subagent?
|
|
83
83
|
- What conditions change the instructions? (if guest is premium, if step 1 is complete)
|
|
84
|
-
- Should the agent do anything before or after reasoning in a given
|
|
84
|
+
- Should the agent do anything before or after reasoning in a given subagent? (e.g., security checks, data fetches, automatic transitions)
|
|
85
85
|
- What data transformations (if any) does the LLM need to do?
|
|
86
86
|
|
|
87
87
|
### Actions & External Systems *(feeds Actions & Backing Logic)*
|
|
@@ -98,17 +98,17 @@ These five question categories drive the content of your Agent Spec. When creati
|
|
|
98
98
|
|
|
99
99
|
- What information must persist across the conversation? (customer name, preferences, process state)
|
|
100
100
|
- What external context is needed? (session ID, user record, linked fields)
|
|
101
|
-
- What conditions should trigger different behavior in the same
|
|
101
|
+
- What conditions should trigger different behavior in the same subagent? (is_premium, role, completed_steps)
|
|
102
102
|
|
|
103
103
|
---
|
|
104
104
|
|
|
105
105
|
## 3. Environment Prerequisites
|
|
106
106
|
|
|
107
|
-
**⚠️ MANDATORY: Run these checks immediately after determining the agent type during discovery.** Do not proceed to
|
|
107
|
+
**⚠️ MANDATORY: Run these checks immediately after determining the agent type during discovery.** Do not proceed to subagent architecture or code generation until the environment is validated.
|
|
108
108
|
|
|
109
109
|
### `AgentforceEmployeeAgent`
|
|
110
110
|
|
|
111
|
-
1. Confirm the config block does NOT include `default_agent_user`. If the generated boilerplate includes it, remove it along with any MessagingSession linked variables and escalation
|
|
111
|
+
1. Confirm the config block does NOT include `default_agent_user`. If the generated boilerplate includes it, remove it along with any MessagingSession linked variables and escalation subagent.
|
|
112
112
|
|
|
113
113
|
**⚠️ Setting `default_agent_user` on an employee agent causes publish and preview to fail with an unhelpful "unknown error."**
|
|
114
114
|
|
|
@@ -144,20 +144,20 @@ Add a "Configuration" section to the Agent Spec:
|
|
|
144
144
|
|
|
145
145
|
---
|
|
146
146
|
|
|
147
|
-
## 4.
|
|
147
|
+
## 4. Subagent Architecture
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
Subagents are states in a finite state machine. When designing a new agent, plan your subagent structure before writing code. When comprehending an existing agent, identify which subagent strategies and architecture pattern it uses.
|
|
150
150
|
|
|
151
|
-
###
|
|
151
|
+
### Subagent Strategies
|
|
152
152
|
|
|
153
|
-
Every
|
|
153
|
+
Every subagent in an agent serves one of three roles: domain, guardrail, or escalation.
|
|
154
154
|
|
|
155
|
-
**Domain
|
|
155
|
+
**Domain Subagents.** The core conversation areas where the agent does its work. Each domain subagent handles a specific area (orders, billing, weather, events) with its own instructions, actions, and state. Most agents have 1-5 domain subagents.
|
|
156
156
|
|
|
157
|
-
**Guardrail
|
|
157
|
+
**Guardrail Subagents.** Specialized subagents that enforce agent boundaries. The standard Agentforce template includes two guardrail subagents by default: `off_topic` (redirects users back to the agent's scope) and `ambiguous_question` (asks for clarification instead of guessing). Preserve these when modifying existing agents.
|
|
158
158
|
|
|
159
159
|
```agentscript
|
|
160
|
-
|
|
160
|
+
subagent off_topic:
|
|
161
161
|
description: "Handle off-topic requests"
|
|
162
162
|
reasoning:
|
|
163
163
|
instructions: ->
|
|
@@ -165,7 +165,7 @@ topic off_topic:
|
|
|
165
165
|
I can only help with [list your capabilities].
|
|
166
166
|
What can I help you with today?
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
subagent ambiguous_question:
|
|
169
169
|
description: "Ask for clarification"
|
|
170
170
|
reasoning:
|
|
171
171
|
instructions: ->
|
|
@@ -173,89 +173,89 @@ topic ambiguous_question:
|
|
|
173
173
|
Can you provide more details about what you need?
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
**Escalation
|
|
176
|
+
**Escalation Subagents.** Hand off to a human via `@utils.escalate`. This is a permanent exit — the user leaves the agent for a support channel (phone, email, chat with a human). Once triggered, the agent session ends. The escalation action does NOT return.
|
|
177
177
|
|
|
178
178
|
```agentscript
|
|
179
|
-
|
|
179
|
+
subagent escalation:
|
|
180
180
|
reasoning:
|
|
181
181
|
actions:
|
|
182
182
|
escalate: @utils.escalate
|
|
183
183
|
description: "Connect with a human agent"
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
### Single-
|
|
186
|
+
### Single-Subagent vs. Multi-Subagent
|
|
187
187
|
|
|
188
188
|
Decide this before choosing an architecture pattern.
|
|
189
189
|
|
|
190
|
-
Use **single-
|
|
190
|
+
Use **single-subagent** if:
|
|
191
191
|
- The agent handles one domain only (FAQ, weather checker, status lookup)
|
|
192
192
|
- All interactions naturally stay in the same context
|
|
193
193
|
- No complex state transitions needed
|
|
194
194
|
|
|
195
|
-
Use **multi-
|
|
195
|
+
Use **multi-subagent** if:
|
|
196
196
|
- The agent handles multiple distinct domains (customer service: orders + billing + account)
|
|
197
|
-
- Different
|
|
197
|
+
- Different subagents have different instructions or action sets
|
|
198
198
|
- Users may need to switch contexts mid-conversation
|
|
199
199
|
- You need different entry points or security gates
|
|
200
200
|
|
|
201
201
|
### Architecture Patterns
|
|
202
202
|
|
|
203
|
-
**Hub-and-Spoke.** One central
|
|
203
|
+
**Hub-and-Spoke.** One central subagent (the router) transitions to specialized domain subagents. The router is typically the `start_agent` subagent. Each spoke handles a specific domain and may transition back to the router or to other spokes. Use when the agent handles multiple distinct domains that don't naturally flow together.
|
|
204
204
|
|
|
205
|
-
Example: The Local Info Agent. The `
|
|
205
|
+
Example: The Local Info Agent. The `agent_router` subagent (hub) routes to domain and guardrail subagents (spokes).
|
|
206
206
|
|
|
207
207
|
```agentscript
|
|
208
|
-
start_agent
|
|
208
|
+
start_agent agent_router:
|
|
209
209
|
reasoning:
|
|
210
210
|
actions:
|
|
211
|
-
go_to_weather: @utils.transition to @
|
|
212
|
-
go_to_events: @utils.transition to @
|
|
213
|
-
go_to_hours: @utils.transition to @
|
|
214
|
-
go_to_off_topic: @utils.transition to @
|
|
215
|
-
go_to_ambiguous_question: @utils.transition to @
|
|
211
|
+
go_to_weather: @utils.transition to @subagent.local_weather
|
|
212
|
+
go_to_events: @utils.transition to @subagent.local_events
|
|
213
|
+
go_to_hours: @utils.transition to @subagent.resort_hours
|
|
214
|
+
go_to_off_topic: @utils.transition to @subagent.off_topic
|
|
215
|
+
go_to_ambiguous_question: @utils.transition to @subagent.ambiguous_question
|
|
216
216
|
|
|
217
|
-
# Domain
|
|
218
|
-
|
|
217
|
+
# Domain subagents — each has its own instructions and actions
|
|
218
|
+
subagent local_weather:
|
|
219
219
|
reasoning:
|
|
220
220
|
instructions: | Handle weather questions.
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
subagent local_events:
|
|
223
223
|
reasoning:
|
|
224
224
|
instructions: | Handle event questions.
|
|
225
225
|
|
|
226
226
|
# resort_hours, off_topic, ambiguous_question defined further down the file
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
**Linear Flow.**
|
|
229
|
+
**Linear Flow.** Subagents form a pipeline: start → step 1 → step 2 → step 3 → end. Users progress through stages without backtracking. Use for multi-step workflows with mandatory ordering (application forms, onboarding, troubleshooting trees).
|
|
230
230
|
|
|
231
231
|
```agentscript
|
|
232
232
|
start_agent intake:
|
|
233
233
|
reasoning:
|
|
234
234
|
actions:
|
|
235
|
-
go_next: @utils.transition to @
|
|
235
|
+
go_next: @utils.transition to @subagent.verification
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
subagent verification:
|
|
238
238
|
reasoning:
|
|
239
239
|
actions:
|
|
240
|
-
go_next: @utils.transition to @
|
|
240
|
+
go_next: @utils.transition to @subagent.details_gathering
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
subagent details_gathering:
|
|
243
243
|
reasoning:
|
|
244
244
|
actions:
|
|
245
|
-
go_next: @utils.transition to @
|
|
245
|
+
go_next: @utils.transition to @subagent.confirmation
|
|
246
246
|
```
|
|
247
247
|
|
|
248
248
|
**Escalation Chain.** Tiered support where each level has increasing capabilities. First-level resolves common issues with basic actions; second-level has access to more powerful actions or broader authority; final level escalates to a human. Use when support difficulty varies and you want to resolve simple issues quickly without involving higher tiers.
|
|
249
249
|
|
|
250
250
|
```agentscript
|
|
251
|
-
|
|
251
|
+
subagent level_1_support:
|
|
252
252
|
reasoning:
|
|
253
253
|
instructions: | Try to resolve the issue using the FAQ and basic troubleshooting.
|
|
254
254
|
actions:
|
|
255
255
|
check_faq: @actions.search_faq
|
|
256
|
-
escalate: @utils.transition to @
|
|
256
|
+
escalate: @utils.transition to @subagent.level_2_support
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
subagent level_2_support:
|
|
259
259
|
reasoning:
|
|
260
260
|
instructions: | You have access to account tools. Try to resolve before escalating.
|
|
261
261
|
actions:
|
|
@@ -264,23 +264,23 @@ topic level_2_support:
|
|
|
264
264
|
escalate_to_human: @utils.escalate
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
-
**Verification Gate.** A security or permission check before allowing access to protected
|
|
267
|
+
**Verification Gate.** A security or permission check before allowing access to protected subagents. The gate validates the user, then transitions to the protected subagent or denies access.
|
|
268
268
|
|
|
269
269
|
```agentscript
|
|
270
270
|
start_agent security_gate:
|
|
271
271
|
reasoning:
|
|
272
272
|
actions:
|
|
273
|
-
go_admin: @utils.transition to @
|
|
273
|
+
go_admin: @utils.transition to @subagent.admin_panel
|
|
274
274
|
available when @variables.user_role == "admin"
|
|
275
|
-
go_denied: @utils.transition to @
|
|
275
|
+
go_denied: @utils.transition to @subagent.access_denied
|
|
276
276
|
available when @variables.user_role != "admin"
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
subagent access_denied:
|
|
279
279
|
reasoning:
|
|
280
280
|
instructions: | You don't have permission to access this.
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
**Single-
|
|
283
|
+
**Single-Subagent.** The entire agent is one subagent — no transitions. Use for focused QA agents where all interactions stay in the same domain.
|
|
284
284
|
|
|
285
285
|
```agentscript
|
|
286
286
|
start_agent faq:
|
|
@@ -293,7 +293,7 @@ start_agent faq:
|
|
|
293
293
|
|
|
294
294
|
### Composing Patterns
|
|
295
295
|
|
|
296
|
-
Real agents often combine patterns. A hub-and-spoke agent may use a verification gate before protected spokes. A linear flow may include escalation exits at each stage. When composing, each
|
|
296
|
+
Real agents often combine patterns. A hub-and-spoke agent may use a verification gate before protected spokes. A linear flow may include escalation exits at each stage. When composing, each subagent still serves exactly one role (domain, guardrail, or escalation) — the architecture pattern determines how they connect.
|
|
297
297
|
|
|
298
298
|
---
|
|
299
299
|
|
|
@@ -415,7 +415,7 @@ Each `@InvocableVariable` on the request class becomes an action input; each on
|
|
|
415
415
|
|
|
416
416
|
```agentscript
|
|
417
417
|
# WRONG — snake_case doesn't match the Apex field names
|
|
418
|
-
|
|
418
|
+
subagent orders:
|
|
419
419
|
actions:
|
|
420
420
|
check_order: @actions.check_order
|
|
421
421
|
target: "apex://OrderLookup"
|
|
@@ -425,7 +425,7 @@ topic orders:
|
|
|
425
425
|
order_date: date # Apex field is orderDate, NOT order_date
|
|
426
426
|
|
|
427
427
|
# RIGHT — names match Apex @InvocableVariable field names exactly
|
|
428
|
-
|
|
428
|
+
subagent orders:
|
|
429
429
|
actions:
|
|
430
430
|
check_order: @actions.check_order
|
|
431
431
|
target: "apex://OrderLookup"
|
|
@@ -626,67 +626,67 @@ ALWAYS fix deploy errors BEFORE generating and deploying the next stub.
|
|
|
626
626
|
|
|
627
627
|
## 6. Transition Patterns
|
|
628
628
|
|
|
629
|
-
When creating a new agent, label every transition in your Agent Spec's
|
|
629
|
+
When creating a new agent, label every transition in your Agent Spec's Subagent Map as either **handoff** or **delegation**. When analyzing an existing agent, classify each transition to determine whether context flow matches the design intent.
|
|
630
630
|
|
|
631
631
|
### Handoff: Permanent Transition
|
|
632
632
|
|
|
633
|
-
A handoff is a one-way transition. The user moves to a new
|
|
633
|
+
A handoff is a one-way transition. The user moves to a new subagent and control never returns to the original subagent. Handoffs use `@utils.transition to` in `reasoning.actions`.
|
|
634
634
|
|
|
635
635
|
Use handoff when:
|
|
636
636
|
- Switching modes (preview → confirm → complete)
|
|
637
|
-
- Entry point routing (
|
|
637
|
+
- Entry point routing (agent_router → domain subagents)
|
|
638
638
|
- One-way workflows (checkout → order_confirmation → end)
|
|
639
639
|
|
|
640
640
|
```agentscript
|
|
641
|
-
|
|
641
|
+
subagent agent_router:
|
|
642
642
|
reasoning:
|
|
643
643
|
actions:
|
|
644
|
-
go_to_checkout: @utils.transition to @
|
|
644
|
+
go_to_checkout: @utils.transition to @subagent.checkout
|
|
645
645
|
description: "Start checkout"
|
|
646
646
|
|
|
647
|
-
|
|
647
|
+
subagent checkout:
|
|
648
648
|
reasoning:
|
|
649
649
|
actions:
|
|
650
|
-
go_to_confirm: @utils.transition to @
|
|
650
|
+
go_to_confirm: @utils.transition to @subagent.order_confirmation
|
|
651
651
|
description: "Proceed to confirmation"
|
|
652
652
|
```
|
|
653
653
|
|
|
654
|
-
After `go_to_confirm` executes, the user is in `order_confirmation`. If they later say "go back," the agent routes them back through `
|
|
654
|
+
After `go_to_confirm` executes, the user is in `order_confirmation`. If they later say "go back," the agent routes them back through `agent_router` (the entry point), not to `checkout`. Handoffs don't stack; they reset the conversation state.
|
|
655
655
|
|
|
656
656
|
### Delegation: Handoff with Explicit Return
|
|
657
657
|
|
|
658
|
-
Delegation hands control to another
|
|
658
|
+
Delegation hands control to another subagent using `@subagent.X` in `reasoning.actions`. It signals *intent* to return, but the return does not happen automatically — the delegated subagent must explicitly transition back to the caller.
|
|
659
659
|
|
|
660
660
|
Use delegation when:
|
|
661
|
-
- One
|
|
662
|
-
- Reusable sub-workflows (e.g., identity verification called from multiple
|
|
663
|
-
- A
|
|
661
|
+
- One subagent needs advice from a specialist and should continue after
|
|
662
|
+
- Reusable sub-workflows (e.g., identity verification called from multiple subagents)
|
|
663
|
+
- A subagent needs to temporarily visit another subagent, then resume
|
|
664
664
|
|
|
665
|
-
**Critical Rule:** `@
|
|
665
|
+
**Critical Rule:** `@subagent.X` delegates control. It does NOT implement call-return semantics. If you want the user to return to the calling subagent, code an explicit `transition to @subagent.<caller>` in the delegated subagent. Without it, the next user utterance falls through to `agent_router`.
|
|
666
666
|
|
|
667
|
-
WRONG: Assuming `@
|
|
667
|
+
WRONG: Assuming `@subagent.specialist` returns automatically
|
|
668
668
|
```agentscript
|
|
669
|
-
|
|
669
|
+
subagent main:
|
|
670
670
|
reasoning:
|
|
671
671
|
actions:
|
|
672
|
-
consult_specialist: @
|
|
672
|
+
consult_specialist: @subagent.specialist # WRONG — assumes return
|
|
673
673
|
|
|
674
674
|
# After specialist runs, control does NOT return to main.
|
|
675
|
-
# The next user utterance routes through
|
|
675
|
+
# The next user utterance routes through agent_router.
|
|
676
676
|
```
|
|
677
677
|
|
|
678
|
-
RIGHT: Delegated
|
|
678
|
+
RIGHT: Delegated subagent defines explicit return transition
|
|
679
679
|
```agentscript
|
|
680
|
-
|
|
680
|
+
subagent main:
|
|
681
681
|
reasoning:
|
|
682
682
|
actions:
|
|
683
|
-
consult_specialist: @
|
|
683
|
+
consult_specialist: @subagent.specialist
|
|
684
684
|
description: "Consult specialist"
|
|
685
685
|
|
|
686
|
-
|
|
686
|
+
subagent specialist:
|
|
687
687
|
reasoning:
|
|
688
688
|
actions:
|
|
689
|
-
go_to_main: @utils.transition to @
|
|
689
|
+
go_to_main: @utils.transition to @subagent.main
|
|
690
690
|
description: "Return to main"
|
|
691
691
|
```
|
|
692
692
|
|
|
@@ -713,7 +713,7 @@ Instructions are suggestions the LLM *may* follow. Gates and guards are enforced
|
|
|
713
713
|
|
|
714
714
|
WRONG: Security rule as an instruction (LLM can ignore it)
|
|
715
715
|
```agentscript
|
|
716
|
-
|
|
716
|
+
subagent admin_panel:
|
|
717
717
|
reasoning:
|
|
718
718
|
instructions: ->
|
|
719
719
|
| Only respond if the user is an admin.
|
|
@@ -730,7 +730,7 @@ Two factors govern subjective control effectiveness: instruction ordering and gr
|
|
|
730
730
|
|
|
731
731
|
RIGHT: Post-action check at the top (LLM sees it first)
|
|
732
732
|
```agentscript
|
|
733
|
-
|
|
733
|
+
subagent checkout:
|
|
734
734
|
reasoning:
|
|
735
735
|
instructions: ->
|
|
736
736
|
# Post-action check — LLM sees this first
|
|
@@ -752,7 +752,7 @@ topic checkout:
|
|
|
752
752
|
|
|
753
753
|
WRONG: Post-action check at the bottom (LLM may respond before seeing it)
|
|
754
754
|
```agentscript
|
|
755
|
-
|
|
755
|
+
subagent checkout:
|
|
756
756
|
reasoning:
|
|
757
757
|
instructions: ->
|
|
758
758
|
| Your current cart total is {!@variables.cart_total}.
|
|
@@ -775,7 +775,7 @@ Grounding validation requires **live mode preview** (`sf agent preview --use-liv
|
|
|
775
775
|
|
|
776
776
|
### Post-Action Behavior
|
|
777
777
|
|
|
778
|
-
When an action completes without triggering a transition, the
|
|
778
|
+
When an action completes without triggering a transition, the subagent stays active. The runtime re-evaluates the entire subagent — resolving instructions top-to-bottom again with updated variables, then passing the new prompt to the LLM. The LLM may call the same action again. To prevent unwanted loops, see Section 9 (Action Loop Prevention).
|
|
779
779
|
|
|
780
780
|
---
|
|
781
781
|
|
|
@@ -787,7 +787,7 @@ An action marked `available when <condition>` is hidden from the LLM when the co
|
|
|
787
787
|
|
|
788
788
|
**WRONG: Relying on instructions to prevent action calls**
|
|
789
789
|
```agentscript
|
|
790
|
-
|
|
790
|
+
subagent booking:
|
|
791
791
|
reasoning:
|
|
792
792
|
instructions: ->
|
|
793
793
|
| if @variables.booking_pending:
|
|
@@ -801,7 +801,7 @@ The action is visible; instructions tell the LLM not to call it. The LLM may ign
|
|
|
801
801
|
|
|
802
802
|
**RIGHT: Using `available when` to hide the action**
|
|
803
803
|
```agentscript
|
|
804
|
-
|
|
804
|
+
subagent booking:
|
|
805
805
|
reasoning:
|
|
806
806
|
actions:
|
|
807
807
|
confirm: @actions.confirm_booking
|
|
@@ -815,7 +815,7 @@ If `booking_pending` is False, the LLM sees no `confirm` action.
|
|
|
815
815
|
Use `if/else` in instructions to show/hide text based on state. This doesn't hide actions; it changes what the LLM is told to do.
|
|
816
816
|
|
|
817
817
|
```agentscript
|
|
818
|
-
|
|
818
|
+
subagent support:
|
|
819
819
|
reasoning:
|
|
820
820
|
instructions: ->
|
|
821
821
|
| You're helping a customer with their order.
|
|
@@ -833,19 +833,19 @@ Use conditional instructions when you want to steer the LLM's reasoning without
|
|
|
833
833
|
|
|
834
834
|
### `before_reasoning` Guards — Early Exit
|
|
835
835
|
|
|
836
|
-
The `before_reasoning` block runs before the LLM is invoked. Code here executes every time the
|
|
836
|
+
The `before_reasoning` block runs before the LLM is invoked. Code here executes every time the subagent is entered. The LLM never sees it, cannot override it, and cannot skip it.
|
|
837
837
|
|
|
838
838
|
```agentscript
|
|
839
|
-
|
|
839
|
+
subagent admin_panel:
|
|
840
840
|
before_reasoning:
|
|
841
841
|
if @variables.user_role != "admin":
|
|
842
|
-
transition to @
|
|
842
|
+
transition to @subagent.access_denied
|
|
843
843
|
|
|
844
844
|
reasoning:
|
|
845
845
|
instructions: | You are in the admin panel.
|
|
846
846
|
```
|
|
847
847
|
|
|
848
|
-
If the user is not an admin, they transition out before the LLM is invoked. The admin
|
|
848
|
+
If the user is not an admin, they transition out before the LLM is invoked. The admin subagent's reasoning instructions never execute.
|
|
849
849
|
|
|
850
850
|
### Multi-Condition Gating
|
|
851
851
|
|
|
@@ -854,10 +854,10 @@ Combine `available when`, conditional instructions, and guards to enforce comple
|
|
|
854
854
|
Example: "Show the payment action only if the user is authenticated AND the cart is not empty AND we're not in a preview/demo mode"
|
|
855
855
|
|
|
856
856
|
```agentscript
|
|
857
|
-
|
|
857
|
+
subagent checkout:
|
|
858
858
|
before_reasoning:
|
|
859
859
|
if @variables.is_demo_mode:
|
|
860
|
-
transition to @
|
|
860
|
+
transition to @subagent.demo_complete
|
|
861
861
|
|
|
862
862
|
reasoning:
|
|
863
863
|
instructions: ->
|
|
@@ -882,7 +882,7 @@ variables:
|
|
|
882
882
|
step2_verified: mutable boolean = False
|
|
883
883
|
step3_verified: mutable boolean = False
|
|
884
884
|
|
|
885
|
-
|
|
885
|
+
subagent verification:
|
|
886
886
|
reasoning:
|
|
887
887
|
actions:
|
|
888
888
|
verify_step1: @actions.run_check_1
|
|
@@ -890,7 +890,7 @@ topic verification:
|
|
|
890
890
|
available when @variables.step1_verified == True
|
|
891
891
|
verify_step3: @actions.run_check_3
|
|
892
892
|
available when @variables.step2_verified == True
|
|
893
|
-
proceed: @utils.transition to @
|
|
893
|
+
proceed: @utils.transition to @subagent.confirmed
|
|
894
894
|
available when @variables.step3_verified == True
|
|
895
895
|
```
|
|
896
896
|
|
|
@@ -898,9 +898,9 @@ Each step becomes visible only after the previous step completes (updates its va
|
|
|
898
898
|
|
|
899
899
|
### Same-Turn Behavior After Gate Transitions
|
|
900
900
|
|
|
901
|
-
When a gate
|
|
901
|
+
When a gate subagent (e.g., username collection) uses `after_reasoning` to transition into a routing subagent, both subagents process in the **same user turn**. The router receives the user's original message — the one that satisfied the gate — not a fresh utterance.
|
|
902
902
|
|
|
903
|
-
This means if the user said "My username is alex" and the gate transitions to a
|
|
903
|
+
This means if the user said "My username is alex" and the gate transitions to a subagent router, the router's reasoning fires against "My username is alex." Since that message doesn't match any domain subagent, the router may misclassify it (e.g., routing to `off_topic`).
|
|
904
904
|
|
|
905
905
|
**Mitigation:** Write the router's reasoning instructions defensively. Tell the LLM that if the user just arrived from the gate, it should greet them and ask how it can help instead of routing the triggering message. See the Anti-Patterns section in the Core Language reference for a full WRONG/RIGHT example.
|
|
906
906
|
|
|
@@ -916,7 +916,7 @@ An action loop occurs when the LLM calls the same action repeatedly without new
|
|
|
916
916
|
|
|
917
917
|
**WRONG: All three loop conditions present**
|
|
918
918
|
```agentscript
|
|
919
|
-
|
|
919
|
+
subagent events:
|
|
920
920
|
reasoning:
|
|
921
921
|
instructions: ->
|
|
922
922
|
| Use the {!@actions.check_events} action to find events.
|
|
@@ -935,7 +935,7 @@ No gate, variable-bound input, no post-action guidance. The LLM can call `check_
|
|
|
935
935
|
Tell the LLM to stop calling the action after receiving results. Name the specific output fields the LLM should include in its text response — vague instructions like "present the results" let platform tools hijack the response (see Section 7, Grounding).
|
|
936
936
|
|
|
937
937
|
```agentscript
|
|
938
|
-
|
|
938
|
+
subagent events:
|
|
939
939
|
reasoning:
|
|
940
940
|
instructions: ->
|
|
941
941
|
| Use {!@actions.check_events} to find events matching the guest's interest.
|
|
@@ -952,10 +952,10 @@ topic events:
|
|
|
952
952
|
|
|
953
953
|
**2. Post-Action Transitions (state-based).**
|
|
954
954
|
|
|
955
|
-
Move the agent out of the
|
|
955
|
+
Move the agent out of the subagent after the action completes, breaking the cycle.
|
|
956
956
|
|
|
957
957
|
```agentscript
|
|
958
|
-
|
|
958
|
+
subagent events:
|
|
959
959
|
reasoning:
|
|
960
960
|
instructions: ->
|
|
961
961
|
| Use {!@actions.check_events} to find events.
|
|
@@ -966,17 +966,17 @@ topic events:
|
|
|
966
966
|
|
|
967
967
|
after_reasoning:
|
|
968
968
|
if @outputs.events_found:
|
|
969
|
-
transition to @
|
|
969
|
+
transition to @subagent.results_displayed
|
|
970
970
|
```
|
|
971
971
|
|
|
972
|
-
After `check_events` runs, the `after_reasoning` block transitions to a new
|
|
972
|
+
After `check_events` runs, the `after_reasoning` block transitions to a new subagent. The agent never cycles back to `events`, so the action can't be called again.
|
|
973
973
|
|
|
974
974
|
**3. LLM Slot-Filling Over Variable Binding (friction-based).**
|
|
975
975
|
|
|
976
976
|
Use `...` (LLM slot-fill) instead of variable binding. This forces the LLM to extract values from the conversation each cycle, adding natural decision friction.
|
|
977
977
|
|
|
978
978
|
```agentscript
|
|
979
|
-
|
|
979
|
+
subagent search:
|
|
980
980
|
reasoning:
|
|
981
981
|
instructions: ->
|
|
982
982
|
| Help the user search for products.
|
|
@@ -992,7 +992,7 @@ With `...`, the LLM must actively decide "do I have a new search query?" on ever
|
|
|
992
992
|
**Combine mitigations for reinforcement:**
|
|
993
993
|
|
|
994
994
|
```agentscript
|
|
995
|
-
|
|
995
|
+
subagent lookup:
|
|
996
996
|
reasoning:
|
|
997
997
|
instructions: ->
|
|
998
998
|
| Once you have the result, present it. Do NOT call the action again.
|
|
@@ -1003,7 +1003,7 @@ topic lookup:
|
|
|
1003
1003
|
|
|
1004
1004
|
after_reasoning:
|
|
1005
1005
|
if @outputs.data_found:
|
|
1006
|
-
transition to @
|
|
1006
|
+
transition to @subagent.done # Exit the subagent
|
|
1007
1007
|
```
|
|
1008
1008
|
|
|
1009
1009
|
Combine mitigations for reinforcement.
|
|
@@ -28,7 +28,7 @@ RUNTIME DOMAIN (created by publish)
|
|
|
28
28
|
Bot (top-level container, one per agent)
|
|
29
29
|
└── BotVersion (one per published version)
|
|
30
30
|
└── GenAiPlannerBundle (versioned bundle, contains compiled agent definition)
|
|
31
|
-
└── local
|
|
31
|
+
└── local subagents and actions (scoped to this version only)
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
The authoring domain is where you work. The runtime domain is what the org creates when you publish. These two domains are separate until you publish, which is when they connect.
|
|
@@ -36,7 +36,7 @@ The authoring domain is where you work. The runtime domain is what the org creat
|
|
|
36
36
|
|
|
37
37
|
An `AiAuthoringBundle` is a Salesforce metadata source component represented as a directory in your local project containing two files:
|
|
38
38
|
|
|
39
|
-
**1. `.agent` file** — Agent Script source code. This is the editable text file where you define
|
|
39
|
+
**1. `.agent` file** — Agent Script source code. This is the editable text file where you define subagents, actions, variables, and flow control. It is human-readable and supports multiple versions.
|
|
40
40
|
|
|
41
41
|
**2. `.bundle-meta.xml` file** — Metadata about the bundle. Contains a `bundleType` element set to `AGENT` and optionally a `<target>` element that controls whether the bundle is DRAFT (editable) or locked to a published version:
|
|
42
42
|
|
|
@@ -62,7 +62,7 @@ Publishing creates the runtime entities that make an agent usable in the org.
|
|
|
62
62
|
|
|
63
63
|
**BotVersion** — One per published version (e.g., `v1`, `v2`, `v3`). Only one version can be active at a time.
|
|
64
64
|
|
|
65
|
-
**GenAiPlannerBundle** — Compiled agent definition for a specific version. Contains
|
|
65
|
+
**GenAiPlannerBundle** — Compiled agent definition for a specific version. Contains subagents, actions, and all runtime metadata, scoped to that version only.
|
|
66
66
|
|
|
67
67
|
Runtime entities are org-generated and never edited directly.
|
|
68
68
|
### Agent Pseudo Metadata Type
|
|
@@ -136,7 +136,7 @@ aiAuthoringBundles/
|
|
|
136
136
|
└── Local_Info_Agent.bundle-meta.xml (metadata)
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
The `.agent` file contains boilerplate with `system`, `config`, `start_agent`, and placeholder
|
|
139
|
+
The `.agent` file contains boilerplate with `system`, `config`, `start_agent`, and placeholder subagents. You edit this file to define your agent.
|
|
140
140
|
|
|
141
141
|
The `.bundle-meta.xml` file is initially minimal (bundleType only, no `<target>`), indicating DRAFT state.
|
|
142
142
|
### Common Failure Modes with WRONG/RIGHT Pairs
|
|
@@ -301,7 +301,7 @@ When you publish, the org creates:
|
|
|
301
301
|
|
|
302
302
|
- **Bot** — Top-level container (one per agent)
|
|
303
303
|
- **BotVersion** — Versioned instance (e.g., `v1`, `v2`, `v3`)
|
|
304
|
-
- **GenAiPlannerBundle** — Compiled agent definition for this version of the agent, with a `localActions/` directory containing
|
|
304
|
+
- **GenAiPlannerBundle** — Compiled agent definition for this version of the agent, with a `localActions/` directory containing subagent-scoped action definitions.
|
|
305
305
|
|
|
306
306
|
Example directory structure after publishing:
|
|
307
307
|
|