@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.
Files changed (78) hide show
  1. package/package.json +1 -1
  2. package/skills/developing-agentforce/README.md +4 -4
  3. package/skills/developing-agentforce/SKILL.md +37 -37
  4. package/skills/developing-agentforce/assets/README-legacy.md +8 -8
  5. package/skills/developing-agentforce/assets/agent-spec-template.md +9 -9
  6. package/skills/developing-agentforce/assets/agents/README.md +4 -4
  7. package/skills/developing-agentforce/assets/agents/hello-world.agent +3 -3
  8. package/skills/developing-agentforce/assets/agents/{multi-topic.agent → multi-subagent.agent} +30 -30
  9. package/skills/developing-agentforce/assets/agents/order-service.agent +25 -25
  10. package/skills/developing-agentforce/assets/agents/production-faq.agent +12 -12
  11. package/skills/developing-agentforce/assets/agents/simple-qa.agent +8 -8
  12. package/skills/developing-agentforce/assets/agents/verification-gate.agent +19 -19
  13. package/skills/developing-agentforce/assets/components/apex-action.agent +3 -3
  14. package/skills/developing-agentforce/assets/components/error-handling.agent +7 -7
  15. package/skills/developing-agentforce/assets/components/escalation-setup.agent +11 -11
  16. package/skills/developing-agentforce/assets/components/flow-action.agent +5 -5
  17. package/skills/developing-agentforce/assets/components/n-ary-conditions.agent +11 -11
  18. package/skills/developing-agentforce/assets/components/{topic-with-actions.agent → subagent-with-actions.agent} +9 -9
  19. package/skills/developing-agentforce/assets/deterministic-routing.agent +19 -19
  20. package/skills/developing-agentforce/assets/escalation-pattern.agent +13 -13
  21. package/skills/developing-agentforce/assets/flow-action-lookup.agent +3 -3
  22. package/skills/developing-agentforce/assets/hub-and-spoke.agent +18 -18
  23. package/skills/developing-agentforce/assets/local-info-agent-annotated.agent +37 -37
  24. package/skills/developing-agentforce/assets/metadata/genai-function-apex.xml +3 -3
  25. package/skills/developing-agentforce/assets/metadata/genai-function-flow.xml +1 -1
  26. package/skills/developing-agentforce/assets/metadata/genai-plugin.xml +10 -10
  27. package/skills/developing-agentforce/assets/minimal-starter.agent +4 -4
  28. package/skills/developing-agentforce/assets/patterns/README.md +21 -21
  29. package/skills/developing-agentforce/assets/patterns/action-callbacks.agent +4 -4
  30. package/skills/developing-agentforce/assets/patterns/advanced-input-bindings.agent +1 -1
  31. package/skills/developing-agentforce/assets/patterns/bidirectional-routing.agent +25 -25
  32. package/skills/developing-agentforce/assets/patterns/critical-input-collection.agent +8 -8
  33. package/skills/developing-agentforce/assets/patterns/delegation-routing.agent +21 -21
  34. package/skills/developing-agentforce/assets/patterns/lifecycle-events.agent +8 -8
  35. package/skills/developing-agentforce/assets/patterns/llm-controlled-actions.agent +5 -5
  36. package/skills/developing-agentforce/assets/patterns/multi-step-workflow.agent +3 -3
  37. package/skills/developing-agentforce/assets/patterns/open-gate-routing.agent +59 -58
  38. package/skills/developing-agentforce/assets/patterns/procedural-instructions.agent +15 -15
  39. package/skills/developing-agentforce/assets/patterns/prompt-template-action.agent +8 -8
  40. package/skills/developing-agentforce/assets/patterns/system-instruction-overrides.agent +40 -40
  41. package/skills/developing-agentforce/assets/prompt-rag-search.agent +9 -9
  42. package/skills/developing-agentforce/assets/{template-multi-topic.agent → template-multi-subagent.agent} +25 -25
  43. package/skills/developing-agentforce/assets/{template-single-topic.agent → template-single-subagent.agent} +14 -14
  44. package/skills/developing-agentforce/assets/verification-gate.agent +16 -16
  45. package/skills/developing-agentforce/references/action-prompt-templates.md +1 -1
  46. package/skills/developing-agentforce/references/actions-reference.md +4 -4
  47. package/skills/developing-agentforce/references/agent-design-and-spec-creation.md +107 -107
  48. package/skills/developing-agentforce/references/agent-metadata-and-lifecycle.md +5 -5
  49. package/skills/developing-agentforce/references/agent-script-core-language.md +79 -79
  50. package/skills/developing-agentforce/references/{agent-topic-map-diagrams.md → agent-subagent-map-diagrams.md} +65 -65
  51. package/skills/developing-agentforce/references/agent-user-setup.md +2 -2
  52. package/skills/developing-agentforce/references/agent-validation-and-debugging.md +55 -55
  53. package/skills/developing-agentforce/references/architecture-patterns.md +33 -33
  54. package/skills/developing-agentforce/references/deploy-reference.md +1 -1
  55. package/skills/developing-agentforce/references/discover-reference.md +1 -1
  56. package/skills/developing-agentforce/references/examples.md +32 -32
  57. package/skills/developing-agentforce/references/feature-validity.md +3 -3
  58. package/skills/developing-agentforce/references/instruction-resolution.md +29 -29
  59. package/skills/developing-agentforce/references/known-issues.md +10 -10
  60. package/skills/developing-agentforce/references/minimal-examples.md +6 -6
  61. package/skills/developing-agentforce/references/production-gotchas.md +22 -22
  62. package/skills/developing-agentforce/references/safety-review-reference.md +2 -2
  63. package/skills/developing-agentforce/references/scoring-rubric.md +3 -3
  64. package/skills/generating-custom-lightning-type/SKILL.md +12 -3
  65. package/skills/observing-agentforce/SKILL.md +8 -8
  66. package/skills/observing-agentforce/apex/AgentforceOptimizeService.cls +2 -2
  67. package/skills/observing-agentforce/references/improve-reference.md +40 -40
  68. package/skills/observing-agentforce/references/issue-classification.md +47 -47
  69. package/skills/observing-agentforce/references/reproduce-reference.md +7 -7
  70. package/skills/observing-agentforce/references/stdm-queries.md +7 -7
  71. package/skills/observing-agentforce/references/stdm-schema.md +2 -2
  72. package/skills/testing-agentforce/SKILL.md +9 -9
  73. package/skills/testing-agentforce/assets/basic-test-spec.yaml +4 -0
  74. package/skills/testing-agentforce/assets/guardrail-test-spec.yaml +4 -0
  75. package/skills/testing-agentforce/assets/standard-test-spec.yaml +8 -4
  76. package/skills/testing-agentforce/references/batch-testing.md +17 -17
  77. package/skills/testing-agentforce/references/preview-testing.md +25 -25
  78. 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. Topics
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 topic'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 topic.
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 topic 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.
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 topic:
28
+ **Worked Example.** Consider this subagent:
29
29
 
30
30
  ```agentscript
31
- topic check_order:
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 topic_selector:
83
+ start_agent agent_router:
84
84
  ...
85
85
 
86
- topic my_topic:
86
+ subagent my_subagent:
87
87
  ...
88
88
  ```
89
89
 
90
- **Required blocks:** `system`, `config`, `start_agent`, and at least one `topic`.
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 `topic` blocks**, the internal ordering is:
94
+ **Within `start_agent` and `subagent` blocks**, the internal ordering is:
95
95
 
96
96
  1. `description` (required)
97
- 2. `system` (optional — topic-level override of global system instructions)
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, topic names, variable names, action names, connection names):
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 — topic → reasoning → instructions → logic/prompt:
120
+ Each nesting level adds 4 spaces. The hierarchy follows the block structure — subagent → reasoning → instructions → logic/prompt:
121
121
 
122
122
  ```agentscript
123
- topic process_order:
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 topic's `actions` block
192
- - `@topic.<name>` — reference a topic by name
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. Topic-level system blocks can override this.
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 topic with `@utils.escalate`
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. Topics
367
+ ## 7. Subagents
368
368
 
369
- **Topic structure** — a named scope for reasoning, actions, and flow control:
369
+ **Subagent structure** — a named scope for reasoning, actions, and flow control:
370
370
 
371
371
  ```agentscript
372
- topic order_lookup:
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 topic is relevant.
392
+ **Description is required** — the LLM uses this to understand when the subagent is relevant.
393
393
 
394
- **Topic-level system override** (optional) — override global system instructions for this topic only:
394
+ **Subagent-level system override** (optional) — override global system instructions for this subagent only:
395
395
 
396
396
  ```agentscript
397
- topic product_specialist:
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 topic**:
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 @topic.login
422
+ transition to @subagent.login
423
423
 
424
424
  reasoning:
425
425
  instructions: ->
426
- | Main topic logic
426
+ | Main subagent logic
427
427
 
428
428
  after_reasoning:
429
429
  if @variables.transaction_complete:
430
- transition to @topic.confirmation
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 @topic.confirmation
544
+ transition to @subagent.confirmation
545
545
  else:
546
- transition to @topic.error_handling
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 topics and responds to conditions.
589
+ Flow control determines how execution moves between subagents and responds to conditions.
590
590
 
591
- **Start agent topic** — the mandatory entry point:
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 topic:
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 topic_selector:
597
- description: "Route to appropriate topic"
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 @topic.order_info
602
+ go_orders: @utils.transition to @subagent.order_info
603
603
  description: "For order inquiries"
604
- go_accounts: @utils.transition to @topic.account_help
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 @topic.next_topic
616
- description: "Move to the next topic"
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 @topic.login
627
+ transition to @subagent.login
628
628
 
629
629
  after_reasoning:
630
630
  if @variables.session_complete:
631
- transition to @topic.summary
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 topic needs another topic's expertise but still has work to do afterward, use `@topic.X` to delegate. The target topic runs its reasoning, then returns control to the caller:
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: @topic.expert_consultation
644
- description: "Consult the expert topic"
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 topic does not resume.
647
+ This is different from `@utils.transition to`, which is one-way — the calling subagent does not resume.
648
648
 
649
- **Conditional branching within topics**:
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 topic's `actions` block with required and optional properties:
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 topic:
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 @topic.checkout
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 topic's prompt and starts fresh with the target topic.
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
- **`@topic.X`** — delegation to another topic with return:
917
+ **`@subagent.X`** — delegation to another subagent with return:
918
918
 
919
919
  ```agentscript
920
920
  reasoning:
921
921
  actions:
922
- consult_expert: @topic.expert_topic
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 topic as a tool runs that topic's reasoning, then returns control to the calling topic.
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 @topic.next
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 @topic.next
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 @topic.next
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 @topic.next
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 @topic.next
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.last_topic = "current_topic"
1142
- transition to @topic.next
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
- topic check_status:
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
- topic check_status:
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 topic transitions to router via `after_reasoning` without defensive instructions**
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
- topic collect_username:
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 @topic.topic_selector
1217
+ transition to @subagent.agent_router
1218
1218
 
1219
- topic topic_selector:
1219
+ subagent agent_router:
1220
1220
  reasoning:
1221
1221
  instructions: ->
1222
1222
  | Route the customer's message:
1223
- - Events → @topic.event_lookup
1224
- - Venues → @topic.venue_booking
1225
- - Weather → @topic.weather_forecast
1226
- - Anything else → @topic.off_topic
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 `topic_selector`, both topics 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 topic, the router sends it to `off_topic`.
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
- topic collect_username:
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 @topic.topic_selector
1240
+ transition to @subagent.agent_router
1241
1241
 
1242
- topic topic_selector:
1242
+ subagent agent_router:
1243
1243
  reasoning:
1244
1244
  instructions: ->
1245
- | Route the customer's message to the right topic.
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 → @topic.event_lookup
1250
- - Venues → @topic.venue_booking
1251
- - Weather → @topic.weather_forecast
1252
- - Anything else → @topic.off_topic
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 topic transitions into a routing topic via `after_reasoning`.
1255
+ This pattern applies whenever a gate subagent transitions into a routing subagent via `after_reasoning`.