@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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
4. Expressions and Operators
|
|
9
9
|
5. System and Config Blocks
|
|
10
10
|
6. Variables
|
|
11
|
-
7.
|
|
11
|
+
7. Subagents
|
|
12
12
|
8. Reasoning Instructions
|
|
13
13
|
9. Flow Control
|
|
14
14
|
10. Actions
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
|
|
22
22
|
Agent Script operates in two phases: deterministic resolution, then LLM reasoning.
|
|
23
23
|
|
|
24
|
-
**Phase 1: Deterministic Resolution.** The runtime executes a
|
|
24
|
+
**Phase 1: Deterministic Resolution.** The runtime executes a subagent's reasoning instructions top to bottom — evaluating `if`/`else` conditions, running actions via `run`, and setting variables via `set`. The LLM is NOT involved yet. The runtime builds a prompt string by accumulating `|` pipe text and resolving conditional logic. If a `transition` command occurs, the runtime discards the current prompt and starts fresh with the target subagent.
|
|
25
25
|
|
|
26
|
-
**Phase 2: LLM Reasoning.** The runtime passes the resolved prompt to the LLM along with any reasoning actions (tools) the
|
|
26
|
+
**Phase 2: LLM Reasoning.** The runtime passes the resolved prompt to the LLM along with any reasoning actions (tools) the subagent exposes. The LLM decides what to do — it can call available actions but cannot modify the prompt text. It only reasons against what Phase 1 resolved.
|
|
27
27
|
|
|
28
|
-
**Worked Example.** Consider this
|
|
28
|
+
**Worked Example.** Consider this subagent:
|
|
29
29
|
|
|
30
30
|
```agentscript
|
|
31
|
-
|
|
31
|
+
subagent check_order:
|
|
32
32
|
reasoning:
|
|
33
33
|
instructions: ->
|
|
34
34
|
if @variables.order_id != "":
|
|
@@ -80,21 +80,21 @@ knowledge:
|
|
|
80
80
|
language:
|
|
81
81
|
...
|
|
82
82
|
|
|
83
|
-
start_agent
|
|
83
|
+
start_agent agent_router:
|
|
84
84
|
...
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
subagent my_subagent:
|
|
87
87
|
...
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
**Required blocks:** `system`, `config`, `start_agent`, and at least one `
|
|
90
|
+
**Required blocks:** `system`, `config`, `start_agent`, and at least one `subagent`.
|
|
91
91
|
|
|
92
92
|
**Optional blocks:** `variables`, `connections`, `knowledge`, `language`. Omit them if not needed.
|
|
93
93
|
|
|
94
|
-
**Within `start_agent` and `
|
|
94
|
+
**Within `start_agent` and `subagent` blocks**, the internal ordering is:
|
|
95
95
|
|
|
96
96
|
1. `description` (required)
|
|
97
|
-
2. `system` (optional —
|
|
97
|
+
2. `system` (optional — subagent-level override of global system instructions)
|
|
98
98
|
3. `before_reasoning` (optional — runs before reasoning phase)
|
|
99
99
|
4. `reasoning` (required)
|
|
100
100
|
5. `after_reasoning` (optional — runs after reasoning phase)
|
|
@@ -104,7 +104,7 @@ topic my_topic:
|
|
|
104
104
|
|
|
105
105
|
## 3. Naming and Formatting Rules
|
|
106
106
|
|
|
107
|
-
**Naming constraints for all identifiers** (developer_name,
|
|
107
|
+
**Naming constraints for all identifiers** (developer_name, subagent names, variable names, action names, connection names):
|
|
108
108
|
|
|
109
109
|
- Contain only letters, numbers, and underscores
|
|
110
110
|
- Begin with a letter (never underscore)
|
|
@@ -117,10 +117,10 @@ Example: `check_order_status` is valid. `check_order__status` is invalid (consec
|
|
|
117
117
|
|
|
118
118
|
**Indentation:** Use 4 spaces per indent level. NEVER use tabs. Mixing spaces and tabs breaks the parser. All lines at the same nesting level must use the same indentation.
|
|
119
119
|
|
|
120
|
-
Each nesting level adds 4 spaces. The hierarchy follows the block structure —
|
|
120
|
+
Each nesting level adds 4 spaces. The hierarchy follows the block structure — subagent → reasoning → instructions → logic/prompt:
|
|
121
121
|
|
|
122
122
|
```agentscript
|
|
123
|
-
|
|
123
|
+
subagent process_order:
|
|
124
124
|
description: "Handle order processing"
|
|
125
125
|
reasoning:
|
|
126
126
|
instructions: ->
|
|
@@ -188,8 +188,8 @@ The expression inside `{! ... }` is evaluated by the runtime during deterministi
|
|
|
188
188
|
|
|
189
189
|
**Resource references**:
|
|
190
190
|
|
|
191
|
-
- `@actions.<name>` — reference an action defined in the
|
|
192
|
-
- `@
|
|
191
|
+
- `@actions.<name>` — reference an action defined in the subagent's `actions` block
|
|
192
|
+
- `@subagent.<name>` — reference a subagent by name
|
|
193
193
|
- `@variables.<name>` — reference a variable (use in logic)
|
|
194
194
|
- `{!@variables.<name>}` — reference a variable in prompt text (template injection)
|
|
195
195
|
- `@outputs.<name>` — action output (only in `set`/`if` immediately after the action — unavailable elsewhere)
|
|
@@ -220,7 +220,7 @@ system:
|
|
|
220
220
|
error: "Sorry, something went wrong. Please try again."
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
The `instructions` field is required and contains text directives sent to the LLM in every reasoning phase.
|
|
223
|
+
The `instructions` field is required and contains text directives sent to the LLM in every reasoning phase. Subagent-level system blocks can override this.
|
|
224
224
|
|
|
225
225
|
Both `welcome` and `error` messages are required.
|
|
226
226
|
|
|
@@ -242,7 +242,7 @@ config:
|
|
|
242
242
|
- `"AgentforceEmployeeAgent"` — internal employee-facing. Agent Script files with this agent type MUST NOT include:
|
|
243
243
|
- `default_agent_user`
|
|
244
244
|
- MessagingSession linked variables (`EndUserId`, `RoutableId`, `ContactId`, `EndUserLanguage`)
|
|
245
|
-
- Escalation
|
|
245
|
+
- Escalation subagent with `@utils.escalate`
|
|
246
246
|
- `connection messaging:` block
|
|
247
247
|
|
|
248
248
|
**Common mistake — service-agent constructs on employee agent:**
|
|
@@ -364,12 +364,12 @@ In prompt text (inside `|` pipe sections), always use `{!@variables.X}` with bra
|
|
|
364
364
|
|
|
365
365
|
---
|
|
366
366
|
|
|
367
|
-
## 7.
|
|
367
|
+
## 7. Subagents
|
|
368
368
|
|
|
369
|
-
**
|
|
369
|
+
**Subagent structure** — a named scope for reasoning, actions, and flow control:
|
|
370
370
|
|
|
371
371
|
```agentscript
|
|
372
|
-
|
|
372
|
+
subagent order_lookup:
|
|
373
373
|
description: "Handle customer order inquiries"
|
|
374
374
|
|
|
375
375
|
reasoning:
|
|
@@ -389,12 +389,12 @@ topic order_lookup:
|
|
|
389
389
|
status: string
|
|
390
390
|
```
|
|
391
391
|
|
|
392
|
-
**Description is required** — the LLM uses this to understand when the
|
|
392
|
+
**Description is required** — the LLM uses this to understand when the subagent is relevant.
|
|
393
393
|
|
|
394
|
-
**
|
|
394
|
+
**Subagent-level system override** (optional) — override global system instructions for this subagent only:
|
|
395
395
|
|
|
396
396
|
```agentscript
|
|
397
|
-
|
|
397
|
+
subagent product_specialist:
|
|
398
398
|
description: "Answer product questions"
|
|
399
399
|
system:
|
|
400
400
|
instructions: "You are a product expert. Be technical and detailed."
|
|
@@ -403,7 +403,7 @@ topic product_specialist:
|
|
|
403
403
|
| Help with product specs.
|
|
404
404
|
```
|
|
405
405
|
|
|
406
|
-
**Internal block ordering within a
|
|
406
|
+
**Internal block ordering within a subagent**:
|
|
407
407
|
|
|
408
408
|
1. `description`
|
|
409
409
|
2. `system` (optional override)
|
|
@@ -419,15 +419,15 @@ topic product_specialist:
|
|
|
419
419
|
```agentscript
|
|
420
420
|
before_reasoning:
|
|
421
421
|
if @variables.session_expired:
|
|
422
|
-
transition to @
|
|
422
|
+
transition to @subagent.login
|
|
423
423
|
|
|
424
424
|
reasoning:
|
|
425
425
|
instructions: ->
|
|
426
|
-
| Main
|
|
426
|
+
| Main subagent logic
|
|
427
427
|
|
|
428
428
|
after_reasoning:
|
|
429
429
|
if @variables.transaction_complete:
|
|
430
|
-
transition to @
|
|
430
|
+
transition to @subagent.confirmation
|
|
431
431
|
```
|
|
432
432
|
|
|
433
433
|
Directive blocks use the arrow syntax (`->`) for logic but no LLM reasoning. They run deterministically.
|
|
@@ -541,9 +541,9 @@ run @actions.process_order
|
|
|
541
541
|
with order_id = @variables.order_id
|
|
542
542
|
set @variables.result = @outputs.status
|
|
543
543
|
if @outputs.success == True:
|
|
544
|
-
transition to @
|
|
544
|
+
transition to @subagent.confirmation
|
|
545
545
|
else:
|
|
546
|
-
transition to @
|
|
546
|
+
transition to @subagent.error_handling
|
|
547
547
|
```
|
|
548
548
|
|
|
549
549
|
After an action completes, you can check outputs and transition.
|
|
@@ -586,22 +586,22 @@ instructions: ->
|
|
|
586
586
|
|
|
587
587
|
## 9. Flow Control
|
|
588
588
|
|
|
589
|
-
Flow control determines how execution moves between
|
|
589
|
+
Flow control determines how execution moves between subagents and responds to conditions.
|
|
590
590
|
|
|
591
|
-
**Start agent
|
|
591
|
+
**Start agent subagent** — the mandatory entry point:
|
|
592
592
|
|
|
593
|
-
Every conversation begins at `start_agent`. The LLM classifies the user's intent and routes to the appropriate
|
|
593
|
+
Every conversation begins at `start_agent`. The LLM classifies the user's intent and routes to the appropriate subagent:
|
|
594
594
|
|
|
595
595
|
```agentscript
|
|
596
|
-
start_agent
|
|
597
|
-
description: "Route to appropriate
|
|
596
|
+
start_agent agent_router:
|
|
597
|
+
description: "Route to appropriate subagent"
|
|
598
598
|
reasoning:
|
|
599
599
|
instructions: ->
|
|
600
600
|
| Welcome. I can help with orders, accounts, or billing.
|
|
601
601
|
actions:
|
|
602
|
-
go_orders: @utils.transition to @
|
|
602
|
+
go_orders: @utils.transition to @subagent.order_info
|
|
603
603
|
description: "For order inquiries"
|
|
604
|
-
go_accounts: @utils.transition to @
|
|
604
|
+
go_accounts: @utils.transition to @subagent.account_help
|
|
605
605
|
description: "For account questions"
|
|
606
606
|
```
|
|
607
607
|
|
|
@@ -612,8 +612,8 @@ Expose the transition as a reasoning action when the LLM should judge the right
|
|
|
612
612
|
```agentscript
|
|
613
613
|
reasoning:
|
|
614
614
|
actions:
|
|
615
|
-
go_next: @utils.transition to @
|
|
616
|
-
description: "Move to the next
|
|
615
|
+
go_next: @utils.transition to @subagent.next_subagent
|
|
616
|
+
description: "Move to the next subagent"
|
|
617
617
|
available when @variables.ready == True
|
|
618
618
|
```
|
|
619
619
|
|
|
@@ -624,29 +624,29 @@ Use bare `transition to` in `before_reasoning` and `after_reasoning` for state-b
|
|
|
624
624
|
```agentscript
|
|
625
625
|
before_reasoning:
|
|
626
626
|
if @variables.not_authenticated:
|
|
627
|
-
transition to @
|
|
627
|
+
transition to @subagent.login
|
|
628
628
|
|
|
629
629
|
after_reasoning:
|
|
630
630
|
if @variables.session_complete:
|
|
631
|
-
transition to @
|
|
631
|
+
transition to @subagent.summary
|
|
632
632
|
```
|
|
633
633
|
|
|
634
634
|
The runtime evaluates the condition and transitions immediately. Do NOT use `@utils.transition to` in directive blocks — it causes compilation errors.
|
|
635
635
|
|
|
636
636
|
**Delegation with return**:
|
|
637
637
|
|
|
638
|
-
When a
|
|
638
|
+
When a subagent needs another subagent's expertise but still has work to do afterward, use `@subagent.X` to delegate. The target subagent runs its reasoning, then returns control to the caller:
|
|
639
639
|
|
|
640
640
|
```agentscript
|
|
641
641
|
reasoning:
|
|
642
642
|
actions:
|
|
643
|
-
ask_expert: @
|
|
644
|
-
description: "Consult the expert
|
|
643
|
+
ask_expert: @subagent.expert_consultation
|
|
644
|
+
description: "Consult the expert subagent"
|
|
645
645
|
```
|
|
646
646
|
|
|
647
|
-
This is different from `@utils.transition to`, which is one-way — the calling
|
|
647
|
+
This is different from `@utils.transition to`, which is one-way — the calling subagent does not resume.
|
|
648
648
|
|
|
649
|
-
**Conditional branching within
|
|
649
|
+
**Conditional branching within subagents**:
|
|
650
650
|
|
|
651
651
|
Conditions in reasoning instructions control which prompt text the LLM ultimately receives. The runtime evaluates `if`/`else` branches and includes only the matching `|` pipe sections in the resolved prompt:
|
|
652
652
|
|
|
@@ -665,7 +665,7 @@ reasoning:
|
|
|
665
665
|
|
|
666
666
|
Actions invoke Flows, Apex classes, Prompt Templates, or other target types. They can run deterministically (the runtime always executes them) or be exposed as tools for the LLM to choose at reasoning time.
|
|
667
667
|
|
|
668
|
-
**Action definition** — each action is defined in the
|
|
668
|
+
**Action definition** — each action is defined in the subagent's `actions` block with required and optional properties:
|
|
669
669
|
|
|
670
670
|
```agentscript
|
|
671
671
|
actions:
|
|
@@ -877,17 +877,17 @@ run @actions.fetch_order
|
|
|
877
877
|
|
|
878
878
|
Utility functions control flow and state. They do not call external systems.
|
|
879
879
|
|
|
880
|
-
**`@utils.transition to`** — permanent one-way handoff to another
|
|
880
|
+
**`@utils.transition to`** — permanent one-way handoff to another subagent:
|
|
881
881
|
|
|
882
882
|
```agentscript
|
|
883
883
|
reasoning:
|
|
884
884
|
actions:
|
|
885
|
-
go_checkout: @utils.transition to @
|
|
885
|
+
go_checkout: @utils.transition to @subagent.checkout
|
|
886
886
|
description: "Proceed to checkout"
|
|
887
887
|
available when @variables.cart_has_items == True
|
|
888
888
|
```
|
|
889
889
|
|
|
890
|
-
Transition discards the current
|
|
890
|
+
Transition discards the current subagent's prompt and starts fresh with the target subagent.
|
|
891
891
|
|
|
892
892
|
**`@utils.escalate`** — route to a human agent (**service agents only** — requires a `connection messaging:` block, which is only valid for `AgentforceServiceAgent`; do not use in employee agents):
|
|
893
893
|
|
|
@@ -914,17 +914,17 @@ reasoning:
|
|
|
914
914
|
|
|
915
915
|
The LLM extracts values from the conversation and populates the specified variables.
|
|
916
916
|
|
|
917
|
-
**`@
|
|
917
|
+
**`@subagent.X`** — delegation to another subagent with return:
|
|
918
918
|
|
|
919
919
|
```agentscript
|
|
920
920
|
reasoning:
|
|
921
921
|
actions:
|
|
922
|
-
consult_expert: @
|
|
922
|
+
consult_expert: @subagent.expert_subagent
|
|
923
923
|
description: "Get expert guidance"
|
|
924
924
|
available when @variables.needs_expert_help == True
|
|
925
925
|
```
|
|
926
926
|
|
|
927
|
-
Calling a
|
|
927
|
+
Calling a subagent as a tool runs that subagent's reasoning, then returns control to the calling subagent.
|
|
928
928
|
|
|
929
929
|
**Post-action directives apply only to `@actions`, not `@utils`**:
|
|
930
930
|
|
|
@@ -950,7 +950,7 @@ Utilities cannot have output, so `set` is invalid.
|
|
|
950
950
|
# WRONG — this doesn't compile
|
|
951
951
|
reasoning:
|
|
952
952
|
actions:
|
|
953
|
-
go_next: transition to @
|
|
953
|
+
go_next: transition to @subagent.next
|
|
954
954
|
description: "Go to next"
|
|
955
955
|
```
|
|
956
956
|
|
|
@@ -961,7 +961,7 @@ reasoning:
|
|
|
961
961
|
```agentscript
|
|
962
962
|
reasoning:
|
|
963
963
|
actions:
|
|
964
|
-
go_next: @utils.transition to @
|
|
964
|
+
go_next: @utils.transition to @subagent.next
|
|
965
965
|
description: "Go to next"
|
|
966
966
|
```
|
|
967
967
|
|
|
@@ -974,7 +974,7 @@ The `@utils.transition to` syntax creates a callable tool.
|
|
|
974
974
|
```agentscript
|
|
975
975
|
# WRONG — compile error
|
|
976
976
|
after_reasoning:
|
|
977
|
-
@utils.transition to @
|
|
977
|
+
@utils.transition to @subagent.next
|
|
978
978
|
```
|
|
979
979
|
|
|
980
980
|
**Why it fails:** Directive blocks (`before_reasoning`, `after_reasoning`) execute deterministically — the runtime handles them, not the LLM. They use bare `transition to` syntax.
|
|
@@ -983,7 +983,7 @@ after_reasoning:
|
|
|
983
983
|
|
|
984
984
|
```agentscript
|
|
985
985
|
after_reasoning:
|
|
986
|
-
transition to @
|
|
986
|
+
transition to @subagent.next
|
|
987
987
|
```
|
|
988
988
|
|
|
989
989
|
Bare `transition to` is deterministic — the runtime executes it directly.
|
|
@@ -1127,7 +1127,7 @@ Three things make this work: (1) naming the specific output fields the LLM must
|
|
|
1127
1127
|
# WRONG — utilities have no outputs
|
|
1128
1128
|
reasoning:
|
|
1129
1129
|
actions:
|
|
1130
|
-
go_next: @utils.transition to @
|
|
1130
|
+
go_next: @utils.transition to @subagent.next
|
|
1131
1131
|
set @variables.transitioned = True
|
|
1132
1132
|
```
|
|
1133
1133
|
|
|
@@ -1138,8 +1138,8 @@ reasoning:
|
|
|
1138
1138
|
```agentscript
|
|
1139
1139
|
# If you need to record state, set before transitioning
|
|
1140
1140
|
before_reasoning:
|
|
1141
|
-
set @variables.
|
|
1142
|
-
transition to @
|
|
1141
|
+
set @variables.last_subagent = "current_subagent"
|
|
1142
|
+
transition to @subagent.next
|
|
1143
1143
|
```
|
|
1144
1144
|
|
|
1145
1145
|
---
|
|
@@ -1180,7 +1180,7 @@ Three mitigations applied: (1) explicit post-action instructions telling the LLM
|
|
|
1180
1180
|
|
|
1181
1181
|
```agentscript
|
|
1182
1182
|
# WRONG — no instructions prepare the LLM
|
|
1183
|
-
|
|
1183
|
+
subagent check_status:
|
|
1184
1184
|
reasoning:
|
|
1185
1185
|
actions:
|
|
1186
1186
|
lookup: @actions.fetch_status
|
|
@@ -1191,7 +1191,7 @@ topic check_status:
|
|
|
1191
1191
|
**CORRECT:**
|
|
1192
1192
|
|
|
1193
1193
|
```agentscript
|
|
1194
|
-
|
|
1194
|
+
subagent check_status:
|
|
1195
1195
|
reasoning:
|
|
1196
1196
|
instructions: ->
|
|
1197
1197
|
| If the customer asks about their order status, use the {!@actions.fetch_status} action.
|
|
@@ -1204,52 +1204,52 @@ Always pair actions with guiding instructions in the reasoning block.
|
|
|
1204
1204
|
|
|
1205
1205
|
---
|
|
1206
1206
|
|
|
1207
|
-
**WRONG: Gate
|
|
1207
|
+
**WRONG: Gate subagent transitions to router via `after_reasoning` without defensive instructions**
|
|
1208
1208
|
|
|
1209
1209
|
```agentscript
|
|
1210
1210
|
# WRONG — the router processes the gate's triggering message in the same turn
|
|
1211
|
-
|
|
1211
|
+
subagent collect_username:
|
|
1212
1212
|
reasoning:
|
|
1213
1213
|
instructions: ->
|
|
1214
1214
|
| Ask the customer for their username.
|
|
1215
1215
|
after_reasoning:
|
|
1216
1216
|
if @variables.username != "":
|
|
1217
|
-
transition to @
|
|
1217
|
+
transition to @subagent.agent_router
|
|
1218
1218
|
|
|
1219
|
-
|
|
1219
|
+
subagent agent_router:
|
|
1220
1220
|
reasoning:
|
|
1221
1221
|
instructions: ->
|
|
1222
1222
|
| Route the customer's message:
|
|
1223
|
-
- Events → @
|
|
1224
|
-
- Venues → @
|
|
1225
|
-
- Weather → @
|
|
1226
|
-
- Anything else → @
|
|
1223
|
+
- Events → @subagent.event_lookup
|
|
1224
|
+
- Venues → @subagent.venue_booking
|
|
1225
|
+
- Weather → @subagent.weather_forecast
|
|
1226
|
+
- Anything else → @subagent.off_topic
|
|
1227
1227
|
```
|
|
1228
1228
|
|
|
1229
|
-
**Why it fails:** When `collect_username` captures the username and `after_reasoning` transitions to `
|
|
1229
|
+
**Why it fails:** When `collect_username` captures the username and `after_reasoning` transitions to `agent_router`, both subagents process in the same user turn. The router's reasoning fires against the user's original message (e.g., "My username is vivek.chawla"), not a fresh utterance. Since that message doesn't match any domain subagent, the router sends it to `off_topic`.
|
|
1230
1230
|
|
|
1231
1231
|
**CORRECT:**
|
|
1232
1232
|
|
|
1233
1233
|
```agentscript
|
|
1234
|
-
|
|
1234
|
+
subagent collect_username:
|
|
1235
1235
|
reasoning:
|
|
1236
1236
|
instructions: ->
|
|
1237
1237
|
| Ask the customer for their username.
|
|
1238
1238
|
after_reasoning:
|
|
1239
1239
|
if @variables.username != "":
|
|
1240
|
-
transition to @
|
|
1240
|
+
transition to @subagent.agent_router
|
|
1241
1241
|
|
|
1242
|
-
|
|
1242
|
+
subagent agent_router:
|
|
1243
1243
|
reasoning:
|
|
1244
1244
|
instructions: ->
|
|
1245
|
-
| Route the customer's message to the right
|
|
1245
|
+
| Route the customer's message to the right subagent.
|
|
1246
1246
|
If the customer just arrived from the username collection
|
|
1247
1247
|
step, greet them and ask how you can help — do NOT route
|
|
1248
1248
|
their previous message.
|
|
1249
|
-
- Events → @
|
|
1250
|
-
- Venues → @
|
|
1251
|
-
- Weather → @
|
|
1252
|
-
- Anything else → @
|
|
1249
|
+
- Events → @subagent.event_lookup
|
|
1250
|
+
- Venues → @subagent.venue_booking
|
|
1251
|
+
- Weather → @subagent.weather_forecast
|
|
1252
|
+
- Anything else → @subagent.off_topic
|
|
1253
1253
|
```
|
|
1254
1254
|
|
|
1255
|
-
This pattern applies whenever a gate
|
|
1255
|
+
This pattern applies whenever a gate subagent transitions into a routing subagent via `after_reasoning`.
|