@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
|
@@ -22,13 +22,13 @@ The `before_reasoning:` and `after_reasoning:` lifecycle hooks are validated. Co
|
|
|
22
22
|
|
|
23
23
|
### Cost Optimization Pattern
|
|
24
24
|
|
|
25
|
-
Fetch data once in `before_reasoning:`, cache in variables, reuse across
|
|
25
|
+
Fetch data once in `before_reasoning:`, cache in variables, reuse across subagents.
|
|
26
26
|
|
|
27
27
|
## Lifecycle Hooks
|
|
28
28
|
|
|
29
29
|
```yaml
|
|
30
|
-
|
|
31
|
-
description: "
|
|
30
|
+
subagent main:
|
|
31
|
+
description: "Subagent with lifecycle hooks"
|
|
32
32
|
|
|
33
33
|
# BEFORE: Runs deterministically BEFORE LLM sees instructions
|
|
34
34
|
before_reasoning:
|
|
@@ -55,7 +55,7 @@ topic main:
|
|
|
55
55
|
- Reliable primitives: `set`, `if`/`else`, `transition to`. `run` has inconsistent runtime behavior across bundle types — use it in `reasoning.actions:` or `instructions: ->` instead
|
|
56
56
|
- `before_reasoning:` is FREE (no credit cost) - use for data prep
|
|
57
57
|
- `after_reasoning:` is FREE (no credit cost) - use for logging, cleanup
|
|
58
|
-
- `transition to` works in `after_reasoning:` — but if a
|
|
58
|
+
- `transition to` works in `after_reasoning:` — but if a subagent transitions mid-reasoning, the original subagent's `after_reasoning:` does NOT run
|
|
59
59
|
|
|
60
60
|
**❌ WRONG Syntax (causes compile error):**
|
|
61
61
|
```yaml
|
|
@@ -74,19 +74,19 @@ before_reasoning:
|
|
|
74
74
|
|
|
75
75
|
| Term | Syntax | Behavior | Use When |
|
|
76
76
|
|------|--------|----------|----------|
|
|
77
|
-
| **Handoff** | `@utils.transition to @
|
|
78
|
-
| **Supervision** | `@
|
|
77
|
+
| **Handoff** | `@utils.transition to @subagent.X` | Control transfers completely, child generates final response | Checkout, escalation, terminal states |
|
|
78
|
+
| **Supervision** | `@subagent.X` (as action reference) | Parent orchestrates, child returns, parent synthesizes | Expert consultation, sub-tasks |
|
|
79
79
|
|
|
80
80
|
```yaml
|
|
81
|
-
# HANDOFF - child
|
|
82
|
-
checkout: @utils.transition to @
|
|
81
|
+
# HANDOFF - child subagent takes over completely:
|
|
82
|
+
checkout: @utils.transition to @subagent.order_checkout
|
|
83
83
|
description: "Proceed to checkout"
|
|
84
|
-
# → @
|
|
84
|
+
# → @subagent.order_checkout generates the user-facing response
|
|
85
85
|
|
|
86
86
|
# SUPERVISION - parent remains in control:
|
|
87
|
-
get_advice: @
|
|
87
|
+
get_advice: @subagent.product_expert
|
|
88
88
|
description: "Consult product expert"
|
|
89
|
-
# → @
|
|
89
|
+
# → @subagent.product_expert returns, parent subagent synthesizes final response
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
**KNOWN BUG**: Adding ANY new action in Canvas view may inadvertently change Supervision references to Handoff transitions.
|
|
@@ -111,16 +111,16 @@ outputs:
|
|
|
111
111
|
is_used_by_planner: True # LLM can use for routing decisions
|
|
112
112
|
|
|
113
113
|
# In Agent Script - LLM routes but cannot hallucinate:
|
|
114
|
-
|
|
114
|
+
subagent intent_router:
|
|
115
115
|
reasoning:
|
|
116
116
|
instructions: ->
|
|
117
117
|
run @actions.classify_intent
|
|
118
118
|
set @variables.intent = @outputs.intent_classification
|
|
119
119
|
|
|
120
120
|
if @variables.intent == "refund":
|
|
121
|
-
transition to @
|
|
121
|
+
transition to @subagent.refunds
|
|
122
122
|
if @variables.intent == "order_status":
|
|
123
|
-
transition to @
|
|
123
|
+
transition to @subagent.orders
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
## Action I/O Metadata Properties
|
|
@@ -187,26 +187,26 @@ KNOWN BUG: Chained actions with Prompt Templates don't properly map inputs using
|
|
|
187
187
|
|
|
188
188
|
For prompt template action definitions, input binding syntax, and grounded data patterns, see [Action Prompt Templates](action-prompt-templates.md).
|
|
189
189
|
|
|
190
|
-
## Latch Variable Pattern for
|
|
190
|
+
## Latch Variable Pattern for Subagent Re-entry
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
Subagent router doesn't properly re-evaluate after user provides missing input. Use a "latch" variable to force re-entry:
|
|
193
193
|
|
|
194
194
|
```yaml
|
|
195
195
|
variables:
|
|
196
196
|
verification_in_progress: mutable boolean = False
|
|
197
197
|
|
|
198
|
-
start_agent
|
|
198
|
+
start_agent agent_router:
|
|
199
199
|
reasoning:
|
|
200
200
|
instructions: ->
|
|
201
201
|
if @variables.verification_in_progress == True:
|
|
202
|
-
transition to @
|
|
202
|
+
transition to @subagent.verification
|
|
203
203
|
| How can I help you today?
|
|
204
204
|
actions:
|
|
205
|
-
start_verify: @
|
|
205
|
+
start_verify: @subagent.verification
|
|
206
206
|
description: "Start identity verification"
|
|
207
207
|
set @variables.verification_in_progress = True
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
subagent verification:
|
|
210
210
|
reasoning:
|
|
211
211
|
instructions: ->
|
|
212
212
|
| Please provide your email to verify your identity.
|
|
@@ -219,9 +219,9 @@ topic verification:
|
|
|
219
219
|
|
|
220
220
|
## Loop Protection Guardrail
|
|
221
221
|
|
|
222
|
-
Agent Scripts have a built-in guardrail that limits iterations to approximately **3-4 loops** before breaking out and returning to the
|
|
222
|
+
Agent Scripts have a built-in guardrail that limits iterations to approximately **3-4 loops** before breaking out and returning to the Subagent Router.
|
|
223
223
|
|
|
224
|
-
**Best Practice**: Map out your execution paths and test for unintended circular references between
|
|
224
|
+
**Best Practice**: Map out your execution paths and test for unintended circular references between subagents.
|
|
225
225
|
|
|
226
226
|
## Token & Size Limits
|
|
227
227
|
|
|
@@ -78,8 +78,8 @@ For each finding, assign severity: **BLOCK** (stops pipeline), **WARN** (flags f
|
|
|
78
78
|
| Check | Severity | What to Look For |
|
|
79
79
|
|-------|----------|------------------|
|
|
80
80
|
| Missing scope definition | WARN | No "do not" or "only handle" clause |
|
|
81
|
-
| Overly broad scope | WARN | No
|
|
82
|
-
| Missing escalation | WARN | Complex/sensitive
|
|
81
|
+
| Overly broad scope | WARN | No subagent boundaries, no escalation path |
|
|
82
|
+
| Missing escalation | WARN | Complex/sensitive subagents without human transfer |
|
|
83
83
|
| Missing error handling | INFO | No instructions for when agent can't help |
|
|
84
84
|
|
|
85
85
|
## Output Format
|
|
@@ -6,11 +6,11 @@ Score every generated agent against this rubric before presenting to the user.
|
|
|
6
6
|
|
|
7
7
|
| Category | Points | Key Criteria |
|
|
8
8
|
|----------|--------|--------------|
|
|
9
|
-
| Structure & Syntax | 15 | All required blocks present (`system`, `config`, `start_agent`, at least one `
|
|
9
|
+
| Structure & Syntax | 15 | All required blocks present (`system`, `config`, `start_agent`, at least one `subagent`). Correct block order (`system` → `config` → `variables` → ...). Proper nesting. Consistent 4-space indentation. Valid field names. All string values double-quoted. |
|
|
10
10
|
| Safety & Responsible AI | 15 | Evaluated via safety review (7 categories): AI disclosure present, no impersonation/deception/manipulation, responsible data handling, no harmful content (including euphemisms), no discrimination (direct or proxy), clear scope boundaries, escalation paths for sensitive topics. Deduct 15 for any BLOCK finding, 5 per WARN finding. |
|
|
11
|
-
| Deterministic Logic | 20 | `after_reasoning` patterns for post-action routing. FSM transitions with no dead-end
|
|
11
|
+
| Deterministic Logic | 20 | `after_reasoning` patterns for post-action routing. FSM transitions with no dead-end subagents. `available when` guards for security-sensitive actions. Post-action checks at TOP of `instructions: ->`. |
|
|
12
12
|
| Instruction Resolution | 20 | Clear, actionable instructions. Procedural mode (`->`) where conditionals are needed. Literal mode (`\|`) where static text suffices. Variable injection where dynamic. Conditional instructions based on state. |
|
|
13
|
-
| FSM Architecture | 10 | Hub-and-spoke or verification gate pattern. Every
|
|
13
|
+
| FSM Architecture | 10 | Hub-and-spoke or verification gate pattern. Every subagent reachable. Every subagent has an exit (transition or escalation). No orphan subagents. Start subagent routes correctly. |
|
|
14
14
|
| Action Configuration | 10 | Proper Level 1 definitions with targets and I/O schemas. Correct Level 2 invocations with `with`/`set`. Slot-filling (`...`) for conversational inputs. Output capture into variables. Correct type mapping for action I/O (use `object` + `complex_data_type_name` for SObjects and custom Lightning types). |
|
|
15
15
|
| Deployment Readiness | 10 | Valid `default_agent_user`. `developer_name` matches folder. `bundle-meta.xml` present with `<bundleType>AGENT</bundleType>`. Linked variables for service agents (`EndUserId`, `RoutableId`, `ContactId`). |
|
|
16
16
|
|
|
@@ -20,6 +20,7 @@ Use this skill when you need to:
|
|
|
20
20
|
Custom Lightning Types (CLTs) are JSON Schema-based type definitions used by the Lightning Platform (including Einstein Agent actions) to describe structured inputs/outputs and drive editor/renderer experiences.
|
|
21
21
|
|
|
22
22
|
## Configuration
|
|
23
|
+
- **Choose referenced CLT pattern for nested objects** - When you need a **reusable** or **separately deployed** nested type, create a CLT for that shape and reference it with `"lightning:type": "c__<CLTName>"`. That string is the referenced type’s **`lightning:type` value / FQN / registered identifier** — not the JSON Schema `title`.
|
|
23
24
|
- **Choose standard Lightning types** when the structure is simple and can be expressed with properties and supported primitive `lightning:type` identifiers.
|
|
24
25
|
- **Choose Apex class types** (`@apexClassType/...`) when the structure already exists server-side and you want the Apex class to define the shape.
|
|
25
26
|
- **Include editor/renderer config** only when you need custom UI behavior (custom LWC input/output components). Otherwise, omit.
|
|
@@ -33,7 +34,7 @@ Custom Lightning Types (CLTs) are JSON Schema-based type definitions used by the
|
|
|
33
34
|
- `"unevaluatedProperties"` is enforced as `false` by the CLT metaschema. Do not set it to `true`.
|
|
34
35
|
- **Root object schemas MUST NOT include** `"examples"` when `"unevaluatedProperties": false` is set.
|
|
35
36
|
- **Nested objects (inside `properties`) MUST NOT set** `"lightning:type": "lightning__objectType"`.
|
|
36
|
-
|
|
37
|
+
- Nested objects can be: references to other CLTs using `c__<CLTName>` syntax.
|
|
37
38
|
- **List/array properties are highly restricted by the CLT metaschema**:
|
|
38
39
|
- **CRITICAL LIMITATION**: the CLT metaschema may reject the `items` keyword entirely. Treat `items` as **disallowed by default**.
|
|
39
40
|
- **Root-level arrays** (direct children of the root `properties`):
|
|
@@ -96,8 +97,13 @@ When strict validation is enabled (`unevaluatedProperties: false`), keep each pr
|
|
|
96
97
|
2. **Draft `schema.json`**
|
|
97
98
|
- Start with the root object structure (required root fields).
|
|
98
99
|
- Add `properties` using valid primitive `lightning:type` identifiers.
|
|
99
|
-
- For nested
|
|
100
|
+
- For nested-object properties, use **CLT Reference pattern**:
|
|
101
|
+
- `"lightning:type": "c__<CLTName>"` to reference another CLT
|
|
102
|
+
- The referenced CLT must be deployed to the org before the parent CLT.
|
|
103
|
+
- For Apex-based nested objects: Use `@apexClassType/...` when structure exists server-side.
|
|
104
|
+
- If the prompt explicitly requires true nested object output, prefer an **Apex-based CLT** (`@apexClassType/...`) for deploy-safe nested structures.
|
|
100
105
|
- For arrays: follow the strict list rules (avoid `items`; avoid `lightning:type` on nested arrays).
|
|
106
|
+
- Before deployment, verify exact `lightning:type` spellings (for example, use `lightning__richTextType`, not misspelled variants).
|
|
101
107
|
3. **(Optional) Draft `editor.json`** (only if custom UI is required)
|
|
102
108
|
- **Supported shape:** Top-level `editor` object with `editor.componentOverrides` and `editor.layout`.
|
|
103
109
|
- Top-level `editor` object.
|
|
@@ -159,6 +165,7 @@ When strict validation is enabled (`unevaluatedProperties: false`), keep each pr
|
|
|
159
165
|
</LightningComponentBundle>
|
|
160
166
|
```
|
|
161
167
|
7. **Deploy and validate**
|
|
168
|
+
- Run a final schema sanity check before deploy: valid `lightning:type` names, required fields present, and no disallowed keywords.
|
|
162
169
|
- Deploy the bundle using your org's standard metadata deployment flow (e.g. Salesforce CLI or IDE). The MCP client or tooling in use should provide or integrate with the appropriate deploy/retrieve commands for Lightning Type bundles.
|
|
163
170
|
- Validate incrementally: if deployment fails, remove disallowed keywords first (especially `examples`, `items`, nested `lightning:type`).
|
|
164
171
|
|
|
@@ -166,7 +173,9 @@ When strict validation is enabled (`unevaluatedProperties: false`), keep each pr
|
|
|
166
173
|
| Error / Symptom | Likely Cause | Fix |
|
|
167
174
|
|---|---|---|
|
|
168
175
|
| Schema validation fails due to unknown keyword | `unevaluatedProperties: false` + disallowed keyword (commonly `examples`, `items`) | Remove the offending keyword; keep schema minimal |
|
|
169
|
-
| Nested object validation failure |
|
|
176
|
+
| Nested object validation failure | Org/channel validation rejects nested object typing in `LightningTypeBundle` | Use CLT reference (`c__<CLTName>`) or Apex class types |
|
|
177
|
+
| Invalid CLT reference | Referenced CLT doesn't exist in org or incorrect syntax | Deploy the referenced CLT first; `c__<CLTName>` must match the referenced type’s **`lightning:type` value / FQN / registered identifier**, not `title` |
|
|
178
|
+
| Invalid or misspelled `lightning:type` (for example, `lightning__richtextType` instead of `lightning__richTextType`) | Incorrect generated type name | Cross-check all `lightning:type` values against supported type names and correct them before deployment |
|
|
170
179
|
| Array property rejected | Use of `items` (or `lightning:type` in nested arrays) rejected by validator | For nested arrays: keep only `type: "array"`. For root arrays: use minimal structure; remove `items` if rejected |
|
|
171
180
|
| Apex-based CLT rejected | Extra fields added (e.g., `type`, `properties`) | Use only `title`, optional `description`, and `lightning:type` |
|
|
172
181
|
| Editor config rejected | Use of invalid patterns (`es_property_editors/inputList`, `itemSchema`) or unrecognized top-level keys | Use `editor.componentOverrides` and `editor.layout`; keep config minimal |
|
|
@@ -99,8 +99,8 @@ fi
|
|
|
99
99
|
Read the `.agent` file and verify it has proper Agent Script structure:
|
|
100
100
|
- `system:` block with `instructions:`
|
|
101
101
|
- `config:` block with `developer_name:`
|
|
102
|
-
- `start_agent` or `
|
|
103
|
-
- Each
|
|
102
|
+
- `start_agent` or `subagent` blocks with `reasoning: instructions:`
|
|
103
|
+
- Each subagent should have distinct `instructions:` content (not identical across subagents)
|
|
104
104
|
|
|
105
105
|
Store the resolved path as `AGENT_FILE` for Phase 3.
|
|
106
106
|
|
|
@@ -187,7 +187,7 @@ sf agent test results --json --job-id "$JOB_ID" --result-format json -o <org>
|
|
|
187
187
|
|
|
188
188
|
### 1-ALT.2 Derive test utterances from .agent file (if no test suite)
|
|
189
189
|
|
|
190
|
-
If no test suite exists, derive utterances: one per non-entry
|
|
190
|
+
If no test suite exists, derive utterances: one per non-entry subagent (from `description:` keywords), one per key action, one guardrail test, one multi-turn test.
|
|
191
191
|
|
|
192
192
|
### 1-ALT.3 Preview with `--authoring-bundle` (local traces)
|
|
193
193
|
|
|
@@ -209,13 +209,13 @@ sf agent preview end --json --session-id "$SESSION_ID" --authoring-bundle <Bundl
|
|
|
209
209
|
|
|
210
210
|
| Issue type | Trace command |
|
|
211
211
|
|---|---|
|
|
212
|
-
|
|
|
212
|
+
| Subagent misroute | `jq -r '.plan[] \| select(.type=="NodeEntryStateStep") \| .data.agent_name' "$TRACE"` |
|
|
213
213
|
| Action not called | `jq -r '.plan[] \| select(.type=="EnabledToolsStep") \| .data.enabled_tools[]' "$TRACE"` |
|
|
214
214
|
| LOW adherence | `jq -r '.plan[] \| select(.type=="ReasoningStep") \| {category, reason}' "$TRACE"` |
|
|
215
215
|
| Variable capture fail | `jq -r '.plan[] \| select(.type=="VariableUpdateStep") \| .data.variable_updates[]' "$TRACE"` |
|
|
216
216
|
| Vague instructions | `jq -r '.plan[] \| select(.type=="LLMStep") \| .data.messages_sent[0].content' "$TRACE"` |
|
|
217
217
|
|
|
218
|
-
**DefaultTopic trace quirk:** With `--authoring-bundle`, the root `.topic` field often shows `"DefaultTopic"` even when routing works. Always use `NodeEntryStateStep.data.agent_name` for the real
|
|
218
|
+
**DefaultTopic trace quirk:** With `--authoring-bundle`, the root `.topic` field often shows `"DefaultTopic"` even when routing works. Always use `NodeEntryStateStep.data.agent_name` for the real subagent chain.
|
|
219
219
|
|
|
220
220
|
**Entry answering directly (SMALL_TALK pattern):** If `start_agent` trace shows `SMALL_TALK` grounding and transition tools visible but none invoked, add "You are a router only. Do NOT answer questions directly." to `start_agent` instructions.
|
|
221
221
|
|
|
@@ -271,7 +271,7 @@ Render turn-by-turn timeline from `ConversationData` JSON for each session.
|
|
|
271
271
|
|
|
272
272
|
> Full issue pattern table and classification categories: see `references/issue-classification.md`
|
|
273
273
|
|
|
274
|
-
Check each session for: action errors,
|
|
274
|
+
Check each session for: action errors, subagent misroutes, missing actions, wrong inputs, variable capture failures, no transitions, slow actions, LOW adherence, abandoned sessions, dead subagents, publish drift, dead hub anti-pattern, entry answering directly, and safety issues.
|
|
275
275
|
|
|
276
276
|
Priority: P1 = action errors, misroutes, LOW adherence; P2 = missing actions, variable bugs, knowledge gaps; P3 = performance, abandoned sessions.
|
|
277
277
|
|
|
@@ -281,7 +281,7 @@ Present sessions analyzed, issues grouped by root cause category, and uplift est
|
|
|
281
281
|
|
|
282
282
|
> Full structural analysis checks, cross-reference procedures, and publish drift detection: see `references/issue-classification.md`
|
|
283
283
|
|
|
284
|
-
Retrieve the `.agent` file from the org, run automated checks (
|
|
284
|
+
Retrieve the `.agent` file from the org, run automated checks (subagent count vs action blocks, dead hub detection, orphan actions, cross-subagent variable dependencies), and cross-reference STDM symptoms against the file structure.
|
|
285
285
|
|
|
286
286
|
---
|
|
287
287
|
|
|
@@ -325,7 +325,7 @@ Map each confirmed issue to a fix location in the `.agent` file (description, in
|
|
|
325
325
|
|
|
326
326
|
### 3.4 Regression prevention
|
|
327
327
|
|
|
328
|
-
Establish baseline before editing. Make minimal edits. Test immediately after each edit. One fix per publish cycle. Check cross-
|
|
328
|
+
Establish baseline before editing. Make minimal edits. Test immediately after each edit. One fix per publish cycle. Check cross-subagent dependencies. Test adjacent subagents.
|
|
329
329
|
|
|
330
330
|
### 3.5 Apply fixes
|
|
331
331
|
|
|
@@ -80,7 +80,7 @@ public with sharing class AgentforceOptimizeService {
|
|
|
80
80
|
*/
|
|
81
81
|
public class TurnData {
|
|
82
82
|
public String interaction_id;
|
|
83
|
-
/**
|
|
83
|
+
/** Subagent API name (stored as `topic` in STDM) — null/mismatch signals a misroute (P1) */
|
|
84
84
|
public String topic;
|
|
85
85
|
public String start_time;
|
|
86
86
|
public String end_time;
|
|
@@ -1142,7 +1142,7 @@ public with sharing class AgentforceOptimizeService {
|
|
|
1142
1142
|
@InvocableVariable(label='Agent API Name' required=false)
|
|
1143
1143
|
public String agentApiName;
|
|
1144
1144
|
|
|
1145
|
-
@InvocableVariable(label='
|
|
1145
|
+
@InvocableVariable(label='Subagent API Name' required=false)
|
|
1146
1146
|
public String topicApiName;
|
|
1147
1147
|
|
|
1148
1148
|
@InvocableVariable(label='Lookback Days' required=false)
|
|
@@ -68,17 +68,17 @@ variables:
|
|
|
68
68
|
|
|
69
69
|
start_agent: entry_topic
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
label: "Entry
|
|
73
|
-
description: "Routes users to specialized
|
|
71
|
+
subagent entry_topic:
|
|
72
|
+
label: "Entry Subagent"
|
|
73
|
+
description: "Routes users to specialized subagents"
|
|
74
74
|
|
|
75
75
|
reasoning:
|
|
76
76
|
instructions: ->
|
|
77
77
|
| Welcome the user warmly.
|
|
78
78
|
| Ask how you can help today.
|
|
79
79
|
actions:
|
|
80
|
-
go_to_orders: @utils.transition to @
|
|
81
|
-
description: "Route to orders
|
|
80
|
+
go_to_orders: @utils.transition to @subagent.orders
|
|
81
|
+
description: "Route to orders subagent"
|
|
82
82
|
check_order: @actions.get_order_status
|
|
83
83
|
description: "Look up order details"
|
|
84
84
|
with order_id = @variables.order_id
|
|
@@ -86,10 +86,10 @@ topic entry_topic:
|
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
**Critical mapping to Salesforce metadata:**
|
|
89
|
-
- `
|
|
90
|
-
- `
|
|
89
|
+
- `subagent.description` -> `GenAiPluginDefinition.Description` (subagent routing signal)
|
|
90
|
+
- `subagent.reasoning.instructions` -> `GenAiPluginInstructionDef.Instruction` (verbatim LLM prompt text)
|
|
91
91
|
- `system.instructions` -> `GenAiPlannerDefinition.Description` (agent-level system prompt)
|
|
92
|
-
- `reasoning.actions` with `@utils.transition` ->
|
|
92
|
+
- `reasoning.actions` with `@utils.transition` -> subagent transitions
|
|
93
93
|
- `reasoning.actions` with `@actions.*` -> action invocations with `with` (input) and `set` (output) bindings
|
|
94
94
|
|
|
95
95
|
---
|
|
@@ -98,17 +98,17 @@ topic entry_topic:
|
|
|
98
98
|
|
|
99
99
|
| Root cause category | STDM signal | Fix target in .agent file | What to change |
|
|
100
100
|
|---|---|---|---|
|
|
101
|
-
| `Agent Configuration Gap` |
|
|
102
|
-
| `Agent Configuration Gap` | Action not called | `
|
|
101
|
+
| `Agent Configuration Gap` | Subagent misroute | `subagent <name>: description:` | Tighten description to exclude overlapping intents |
|
|
102
|
+
| `Agent Configuration Gap` | Action not called | `subagent <name>: reasoning: actions:` and `reasoning: instructions:` | Add action definition under `actions:` and mention it in `instructions:` |
|
|
103
103
|
| `Agent Configuration Gap` | Wrong action input / error | `reasoning: actions: <action>: with` | Correct `with` bindings or action `target:` URI |
|
|
104
104
|
| `Agent Configuration Gap` | Variable not captured | `reasoning: actions: <action>: set` | Add `set @variables.myVar = @outputs.field` binding |
|
|
105
|
-
| `Agent Configuration Gap` | No post-action transition | `reasoning: actions:` | Add `@utils.transition to @
|
|
106
|
-
| `Agent Configuration Gap` | LOW adherence / vague instructions | `
|
|
107
|
-
| `Agent Configuration Gap` | Identical instructions across
|
|
108
|
-
| `Knowledge Gap -- Infrastructure` | Knowledge question answered generically | Add knowledge action definition to the relevant
|
|
105
|
+
| `Agent Configuration Gap` | No post-action transition | `reasoning: actions:` | Add `@utils.transition to @subagent.<next_subagent>` action |
|
|
106
|
+
| `Agent Configuration Gap` | LOW adherence / vague instructions | `subagent <name>: reasoning: instructions:` | Rewrite using instruction principles below |
|
|
107
|
+
| `Agent Configuration Gap` | Identical instructions across subagents | All `subagent: reasoning: instructions:` blocks | Give each subagent distinct, actionable instructions |
|
|
108
|
+
| `Knowledge Gap -- Infrastructure` | Knowledge question answered generically | Add knowledge action definition to the relevant subagent | Define action with `retriever://` target |
|
|
109
109
|
| `Knowledge Gap -- Content` | Knowledge question -- wrong/missing answer | N/A (org data issue) | Add missing articles to knowledge space |
|
|
110
110
|
| `Platform / Runtime Issue` | Action timeout / latency > 10s | Flow or Apex class (not .agent) | Optimize query/processing logic |
|
|
111
|
-
| `Agent Configuration Gap` | Dead hub anti-pattern | Entire intermediate
|
|
111
|
+
| `Agent Configuration Gap` | Dead hub anti-pattern | Entire intermediate subagent block | Move transitions to `start_agent > reasoning > actions:`, delete dead hub subagent |
|
|
112
112
|
|
|
113
113
|
**Target resolution checklist:**
|
|
114
114
|
|
|
@@ -121,20 +121,20 @@ topic entry_topic:
|
|
|
121
121
|
|
|
122
122
|
---
|
|
123
123
|
|
|
124
|
-
## Principles for Effective
|
|
124
|
+
## Principles for Effective Subagent Instructions
|
|
125
125
|
|
|
126
|
-
Good instructions are specific, imperative, and action-named. Poor instructions are persona descriptions or generic guidance reused across
|
|
126
|
+
Good instructions are specific, imperative, and action-named. Poor instructions are persona descriptions or generic guidance reused across subagents.
|
|
127
127
|
|
|
128
128
|
1. **Name the action explicitly** -- "Use `@actions.schedule_test_drive` to book the appointment" not "help the user book"
|
|
129
129
|
2. **State the pre-condition** -- "Only handle scheduling after the customer's name and email have been collected"
|
|
130
130
|
3. **State what to do after** -- "After scheduling completes, confirm the date/time and transition to follow_up"
|
|
131
|
-
4. **Scope tightly** -- "This
|
|
132
|
-
5. **Keep persona out of instructions** -- persona belongs in `system: instructions:` (agent-level), not per-
|
|
133
|
-
6. **One responsibility per
|
|
131
|
+
4. **Scope tightly** -- "This subagent handles test drive scheduling only. For vehicle specs or pricing, do not answer -- the user should be routed to general_support"
|
|
132
|
+
5. **Keep persona out of instructions** -- persona belongs in `system: instructions:` (agent-level), not per-subagent reasoning instructions
|
|
133
|
+
6. **One responsibility per subagent** -- if the instruction covers 3 distinct tasks, split into 3 subagents
|
|
134
134
|
|
|
135
135
|
**Before / after example** (identical instructions -> distinct instructions):
|
|
136
136
|
|
|
137
|
-
*Before (generic persona text, same across all
|
|
137
|
+
*Before (generic persona text, same across all subagents):*
|
|
138
138
|
```
|
|
139
139
|
reasoning:
|
|
140
140
|
instructions: |
|
|
@@ -142,7 +142,7 @@ reasoning:
|
|
|
142
142
|
help them with their needs, and guide them toward scheduling a test drive.
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
*After (for `identity_collection`
|
|
145
|
+
*After (for `identity_collection` subagent specifically):*
|
|
146
146
|
```
|
|
147
147
|
reasoning:
|
|
148
148
|
instructions: ->
|
|
@@ -154,7 +154,7 @@ reasoning:
|
|
|
154
154
|
description: "Capture customer contact details"
|
|
155
155
|
set @variables.customer_name = @outputs.name
|
|
156
156
|
set @variables.customer_email = @outputs.email
|
|
157
|
-
proceed: @utils.transition to @
|
|
157
|
+
proceed: @utils.transition to @subagent.schedule_test_drive
|
|
158
158
|
description: "Move to test drive scheduling after info collected"
|
|
159
159
|
available when @variables.customer_name != ""
|
|
160
160
|
```
|
|
@@ -163,7 +163,7 @@ reasoning:
|
|
|
163
163
|
|
|
164
164
|
## Regression Prevention
|
|
165
165
|
|
|
166
|
-
When editing
|
|
166
|
+
When editing subagent instructions, follow these principles:
|
|
167
167
|
|
|
168
168
|
1. **Establish a baseline BEFORE editing** -- Run the test utterance 3 times before making changes. Record the pass rate.
|
|
169
169
|
|
|
@@ -172,35 +172,35 @@ When editing topic instructions, follow these principles:
|
|
|
172
172
|
3. **Avoid instruction expansion** -- Adding more text to instructions does NOT always help. Prefer:
|
|
173
173
|
- Adding a single action reference: "Use `@actions.X` to look up..."
|
|
174
174
|
- Adding a single constraint: "Do not proceed until the customer provides..."
|
|
175
|
-
- Adding a single routing directive: "After completing, transition to @
|
|
175
|
+
- Adding a single routing directive: "After completing, transition to @subagent.Y"
|
|
176
176
|
|
|
177
177
|
4. **Test immediately after each edit** -- Run the same test utterances. If pass rate drops, revert the change immediately.
|
|
178
178
|
|
|
179
179
|
5. **One fix per publish cycle** -- Do not batch multiple instruction changes into a single publish.
|
|
180
180
|
|
|
181
|
-
6. **Check cross-
|
|
181
|
+
6. **Check cross-subagent dependencies before editing** -- Before changing Subagent A, identify variable dependencies, transition chains, and shared variable mutations:
|
|
182
182
|
```bash
|
|
183
183
|
grep -n 'set @variables\.' "$AGENT_FILE"
|
|
184
184
|
grep -n 'with .* = @variables\.' "$AGENT_FILE"
|
|
185
|
-
grep -n '@utils.transition to @
|
|
185
|
+
grep -n '@utils.transition to @subagent\.' "$AGENT_FILE"
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
7. **Test adjacent
|
|
188
|
+
7. **Test adjacent subagents after each fix** -- Include at least one cross-subagent test to confirm the fix didn't cause spillover routing.
|
|
189
189
|
|
|
190
|
-
8. **Verify start_agent routing after
|
|
190
|
+
8. **Verify start_agent routing after subagent removal** -- If removing a dead hub or merging subagents, verify `start_agent > reasoning > actions:` still has transition actions to all remaining subagents.
|
|
191
191
|
|
|
192
192
|
---
|
|
193
193
|
|
|
194
194
|
## Apply Fixes
|
|
195
195
|
|
|
196
|
-
**Step 1 -- Read the current .agent file** using the Read tool. Locate the specific `
|
|
196
|
+
**Step 1 -- Read the current .agent file** using the Read tool. Locate the specific `subagent` block that needs changes.
|
|
197
197
|
|
|
198
198
|
**Step 2 -- Edit the .agent file directly** using the Edit tool. Edit only the specific lines that need to change. Common edit patterns:
|
|
199
199
|
|
|
200
|
-
- **
|
|
201
|
-
- **
|
|
200
|
+
- **Subagent description** (for misroute fixes): Change `description:` text
|
|
201
|
+
- **Subagent instructions** (for LOW adherence): Replace `reasoning: instructions:` block
|
|
202
202
|
- **Adding an action**: Add definition under `reasoning: actions:`
|
|
203
|
-
- **Adding a transition**: Add `@utils.transition to @
|
|
203
|
+
- **Adding a transition**: Add `@utils.transition to @subagent.<name>` action
|
|
204
204
|
- **Adding an `available when` guard**: Add guard condition to action definition
|
|
205
205
|
|
|
206
206
|
IMPORTANT: Agent Script uses **tabs** for indentation, not spaces.
|
|
@@ -238,7 +238,7 @@ sf project deploy start --json --metadata "AiAuthoringBundle:<AGENT_API_NAME>" -
|
|
|
238
238
|
sf agent activate --json --api-name <AGENT_API_NAME> -o <org>
|
|
239
239
|
```
|
|
240
240
|
|
|
241
|
-
> **Warning: deploy + activate is an incomplete fallback.** `sf project deploy start` stores the bundle metadata but does **NOT** propagate
|
|
241
|
+
> **Warning: deploy + activate is an incomplete fallback.** `sf project deploy start` stores the bundle metadata but does **NOT** propagate subagent-level `reasoning: actions:` blocks to live `GenAiPluginDefinition` records. Always verify with `--authoring-bundle` preview.
|
|
242
242
|
|
|
243
243
|
**Never use the Tooling API to patch `GenAiPluginInstructionDef` or other BPO objects directly.**
|
|
244
244
|
|
|
@@ -266,7 +266,7 @@ sf agent preview end --json --session-id "$SESSION_ID" --authoring-bundle <Bundl
|
|
|
266
266
|
|
|
267
267
|
**Trace-based verification checklist:**
|
|
268
268
|
```bash
|
|
269
|
-
# 1. Correct
|
|
269
|
+
# 1. Correct subagent routing
|
|
270
270
|
jq -r '.topic' "$TRACE"
|
|
271
271
|
# 2. Grounding passed (no UNGROUNDED)
|
|
272
272
|
jq -r '.plan[] | select(.type == "ReasoningStep") | .category' "$TRACE"
|
|
@@ -282,7 +282,7 @@ jq -r '.plan[] | select(.type == "VariableUpdateStep") | .data.variable_updates[
|
|
|
282
282
|
|
|
283
283
|
| Metric | What to look for after fix |
|
|
284
284
|
|---|---|
|
|
285
|
-
|
|
|
285
|
+
| Subagents seen in STDM | Dead subagents should now appear in session data |
|
|
286
286
|
| `TRUST_GUARDRAILS_STEP` value | `LOW` occurrences should drop or disappear |
|
|
287
287
|
| Action invocation per turn | Actions should now fire for the intents they cover |
|
|
288
288
|
| `action_error_count` | Should not increase (regression check) |
|
|
@@ -295,7 +295,7 @@ jq -r '.plan[] | select(.type == "VariableUpdateStep") | .data.variable_updates[
|
|
|
295
295
|
After applying fixes, re-run safety review on the modified `.agent` file. Optimization fixes can inadvertently introduce safety regressions:
|
|
296
296
|
|
|
297
297
|
- Relaxing `available when` guards may expose actions that should be gated
|
|
298
|
-
- Expanding
|
|
298
|
+
- Expanding subagent descriptions may cause the agent to handle out-of-scope requests
|
|
299
299
|
- Changing instructions to be more permissive may weaken guardrails
|
|
300
300
|
- Adding literal instructions with tool names may bypass safety boundaries
|
|
301
301
|
|
|
@@ -304,7 +304,7 @@ After applying fixes, re-run safety review on the modified `.agent` file. Optimi
|
|
|
304
304
|
1. **Scope boundaries** -- Did the fix widen the agent's scope beyond what's appropriate?
|
|
305
305
|
2. **Guard conditions** -- Did relaxing `available when` expose sensitive actions?
|
|
306
306
|
3. **Instruction safety** -- Do new/modified instructions maintain appropriate guardrails?
|
|
307
|
-
4. **Escalation paths** -- Are escalation paths still intact after
|
|
307
|
+
4. **Escalation paths** -- Are escalation paths still intact after subagent restructuring?
|
|
308
308
|
|
|
309
309
|
**If any new BLOCK finding is introduced by the fix:** revert and find an alternative fix. Do NOT deploy an agent with new safety violations.
|
|
310
310
|
|
|
@@ -322,12 +322,12 @@ subjectName: <AgentApiName>
|
|
|
322
322
|
|
|
323
323
|
testCases:
|
|
324
324
|
- utterance: "<exact utterance from Phase 2 scenario>"
|
|
325
|
-
expectedTopic: <
|
|
325
|
+
expectedTopic: <subagent_that_should_handle_this>
|
|
326
326
|
expectedActions:
|
|
327
327
|
- <action_that_should_fire>
|
|
328
328
|
|
|
329
329
|
- utterance: "<another failing utterance>"
|
|
330
|
-
expectedTopic: <
|
|
330
|
+
expectedTopic: <expected_subagent>
|
|
331
331
|
expectedOutcome: "Agent should <expected behavior description>"
|
|
332
332
|
```
|
|
333
333
|
|