@salesforce/afv-skills 1.68.0 → 1.69.0

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 (188) hide show
  1. package/package.json +1 -1
  2. package/skills/afcc-setup-coordinate/SKILL.md +348 -0
  3. package/skills/afcc-setup-coordinate/assets/console-app/AFCC_Service_Console.app-meta.xml +19 -0
  4. package/skills/afcc-setup-coordinate/assets/console-app/Admin.profile-meta.xml +8 -0
  5. package/skills/afcc-setup-coordinate/assets/console-app/Standard.profile-meta.xml +8 -0
  6. package/skills/afcc-setup-coordinate/assets/gap_report_template.md +35 -0
  7. package/skills/afcc-setup-coordinate/assets/org_profile_template.json +16 -0
  8. package/skills/afcc-setup-coordinate/references/gotchas.md +22 -0
  9. package/skills/afcc-setup-coordinate/scripts/audit_org.sh +159 -0
  10. package/skills/agentforce-bot-upgrade/SKILL.md +117 -66
  11. package/skills/agentforce-bot-upgrade/assets/_vendored/agent-spec-template.md +139 -0
  12. package/skills/agentforce-bot-upgrade/references/_vendored/agent-design-and-spec-creation.md +1211 -0
  13. package/skills/agentforce-bot-upgrade/references/_vendored/agent-script-core-language.md +1390 -0
  14. package/skills/agentforce-bot-upgrade/references/_vendored/agent-subagent-map-diagrams.md +341 -0
  15. package/skills/agentforce-bot-upgrade/references/_vendored/agent-user-setup.md +672 -0
  16. package/skills/agentforce-bot-upgrade/references/_vendored/agent-validation-and-debugging.md +904 -0
  17. package/skills/agentforce-bot-upgrade/references/_vendored/agentscript-toolchain.md +112 -0
  18. package/skills/agentforce-bot-upgrade/references/_vendored/architecture-patterns.md +277 -0
  19. package/skills/agentforce-bot-upgrade/references/_vendored/common-control-flow-pitfalls.md +255 -0
  20. package/skills/agentforce-bot-upgrade/references/_vendored/control-flow-actions-sequencing.md +198 -0
  21. package/skills/agentforce-bot-upgrade/references/_vendored/control-flow-lifecycle-side-effects.md +87 -0
  22. package/skills/agentforce-bot-upgrade/references/_vendored/data-library-reference.md +891 -0
  23. package/skills/agentforce-bot-upgrade/references/_vendored/instruction-resolution.md +658 -0
  24. package/skills/agentforce-bot-upgrade/references/_vendored/org-setup-for-adl.md +551 -0
  25. package/skills/agentforce-bot-upgrade/references/_vendored/patterns-by-requirement.md +88 -0
  26. package/skills/agentforce-bot-upgrade/references/_vendored/posture-and-determinism.md +215 -0
  27. package/skills/agentforce-bot-upgrade/references/extraction-blueprint.md +11 -4
  28. package/skills/agentforce-bot-upgrade/references/generate-agent-spec.md +19 -3
  29. package/skills/agentforce-bot-upgrade/references/handoff-output-format.md +82 -52
  30. package/skills/agentforce-bot-upgrade/references/input-contract.md +8 -8
  31. package/skills/agentforce-bot-upgrade/references/mapping-rules.md +19 -6
  32. package/skills/agentforce-bot-upgrade/references/post-conversion-enhancements-reference.md +65 -6
  33. package/skills/agentforce-bot-upgrade/references/quality-checklist.md +4 -4
  34. package/skills/agentforce-bot-upgrade/references/sf-cli-bot-reference.md +17 -3
  35. package/skills/agentforce-hyperclassifier-configure/README.md +24 -0
  36. package/skills/agentforce-hyperclassifier-configure/SKILL.md +111 -0
  37. package/skills/agentforce-hyperclassifier-configure/assets/customer-org.env.example +4 -0
  38. package/skills/agentforce-hyperclassifier-configure/assets/sample_descriptions.json +8 -0
  39. package/skills/agentforce-hyperclassifier-configure/assets/sample_evals.csv +17 -0
  40. package/skills/agentforce-hyperclassifier-configure/references/api-contract.md +41 -0
  41. package/skills/agentforce-hyperclassifier-configure/references/authentication.md +35 -0
  42. package/skills/agentforce-hyperclassifier-configure/references/evaluation.md +46 -0
  43. package/skills/agentforce-hyperclassifier-configure/references/installation.md +35 -0
  44. package/skills/agentforce-hyperclassifier-configure/references/onboarding.md +93 -0
  45. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/__init__.py +1 -0
  46. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/client.py +219 -0
  47. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/eca.py +178 -0
  48. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/evaluation.py +207 -0
  49. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/onboarding.py +191 -0
  50. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/optimizer.py +187 -0
  51. package/skills/agentforce-hyperclassifier-configure/scripts/hyperclassifier.py +111 -0
  52. package/skills/agentforce-hyperclassifier-configure/scripts/report_hyperclassifier.py +149 -0
  53. package/skills/agentforce-hyperclassifier-configure/scripts/setup_hyperclassifier.py +74 -0
  54. package/skills/agentforce-hyperclassifier-configure/scripts/tests/test_hyperclassifier_skill.py +887 -0
  55. package/skills/agentforce-offline-experimentation-run/scripts/btlib/judge.py +23 -31
  56. package/skills/agentforce-offline-experimentation-run/scripts/btlib/messages.py +2 -1
  57. package/skills/agentforce-offline-experimentation-run/scripts/btlib/sfap.py +118 -2
  58. package/skills/agentforce-offline-experimentation-run/scripts/build_report.py +2 -2
  59. package/skills/agentforce-offline-experimentation-run/scripts/resolve-token.sh +9 -2
  60. package/skills/agentforce-offline-experimentation-run/scripts/sfap_replay.py +12 -1
  61. package/skills/commerce-react-storefront-create/SKILL.md +54 -21
  62. package/skills/dx-lifecycle-center/SKILL.md +24 -18
  63. package/skills/dx-lifecycle-center/examples/workflows.md +57 -34
  64. package/skills/dx-lifecycle-center/references/connect-api.md +33 -4
  65. package/skills/dx-lifecycle-center/references/connect-org.md +59 -28
  66. package/skills/dx-lifecycle-center/references/deploy.md +3 -3
  67. package/skills/dx-lifecycle-center/references/hub-org.md +19 -3
  68. package/skills/dx-lifecycle-center/references/list-orgs.md +50 -24
  69. package/skills/dx-lifecycle-center/references/troubleshooting.md +22 -1
  70. package/skills/dx-lifecycle-center/scripts/hub-get.sh +41 -0
  71. package/skills/dx-lifecycle-center/scripts/resolve-environment.sh +151 -4
  72. package/skills/dx-packaging-convert-1gp-to-2gp-create/SKILL.md +63 -0
  73. package/skills/dx-packaging-convert-1gp-to-2gp-create/references/conversion-operations.md +252 -0
  74. package/skills/dx-packaging-move-to-2gp-migrate/SKILL.md +2 -3
  75. package/skills/dx-packaging-move-to-2gp-migrate/references/api-operations.md +10 -7
  76. package/skills/dx-packaging-push-upgrade-configure/README.md +47 -0
  77. package/skills/dx-packaging-push-upgrade-configure/SKILL.md +355 -0
  78. package/skills/dx-packaging-push-upgrade-configure/references/best-practices.md +61 -0
  79. package/skills/dx-packaging-push-upgrade-configure/references/cli-reference.md +148 -0
  80. package/skills/dx-packaging-push-upgrade-configure/references/objects.md +106 -0
  81. package/skills/dx-packaging-push-upgrade-configure/references/soql-recipes.md +144 -0
  82. package/skills/experience-afv-analytics-query/SKILL.md +239 -0
  83. package/skills/experience-afv-analytics-query/references/references.md +176 -0
  84. package/skills/experience-app-mcp-delivery-generate/SKILL.md +142 -0
  85. package/skills/experience-app-mcp-delivery-generate/references/eca-consumer-key.md +26 -0
  86. package/skills/experience-app-mcp-delivery-generate/references/mcp-config-delivery.md +38 -0
  87. package/skills/experience-app-mcp-delivery-generate/references/plugin-format-and-publishing.md +80 -0
  88. package/skills/experience-app-mcp-delivery-generate/scripts/developer_name.mjs +9 -0
  89. package/skills/experience-app-mcp-delivery-generate/scripts/discover_mcp_context.mjs +114 -0
  90. package/skills/experience-app-mcp-delivery-generate/scripts/generate_mcp_config.mjs +27 -0
  91. package/skills/experience-app-mcp-delivery-generate/scripts/generate_plugin.mjs +184 -0
  92. package/skills/experience-app-mcp-delivery-generate/scripts/mcp_config.mjs +57 -0
  93. package/skills/experience-app-mcp-delivery-generate/scripts/preflight.mjs +109 -0
  94. package/skills/experience-app-mcp-delivery-generate/scripts/retrieve_eca_consumer_key.mjs +143 -0
  95. package/skills/experience-app-mcp-generate/SKILL.md +174 -0
  96. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.eca-meta.xml +7 -0
  97. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaGlblOauth-meta.xml +15 -0
  98. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaOauth-meta.xml +6 -0
  99. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaOauthPlcy-meta.xml +12 -0
  100. package/skills/experience-app-mcp-generate/assets/__ECA_NAME___defaultPolicy.ecaPlcy-meta.xml +7 -0
  101. package/skills/experience-app-mcp-generate/assets/__MCP_SERVER_NAME__.mcpServerDefinition-meta.xml +5 -0
  102. package/skills/experience-app-mcp-generate/references/eca-fields.md +76 -0
  103. package/skills/experience-app-mcp-generate/references/mcp-objects.md +66 -0
  104. package/skills/experience-app-mcp-generate/references/tool-bindings.md +85 -0
  105. package/skills/experience-app-mcp-generate/references/troubleshooting.md +41 -0
  106. package/skills/experience-app-mcp-generate/references/ui-frameworks.md +19 -0
  107. package/skills/experience-app-mcp-generate/references/widget-resources.md +96 -0
  108. package/skills/experience-app-mcp-generate/scripts/activate_server.mjs +166 -0
  109. package/skills/experience-app-mcp-generate/scripts/check_setup_progress.mjs +212 -0
  110. package/skills/experience-app-mcp-generate/scripts/list_sites.mjs +211 -0
  111. package/skills/experience-app-mcp-generate/scripts/merge_tools.mjs +407 -0
  112. package/skills/experience-app-mcp-generate/scripts/preflight.mjs +127 -0
  113. package/skills/experience-app-mcp-generate/scripts/render_eca.mjs +144 -0
  114. package/skills/experience-app-mcp-generate/scripts/render_mcp_server.mjs +64 -0
  115. package/skills/experience-app-mcp-generate/scripts/retrieve_existing_prompts.mjs +145 -0
  116. package/skills/experience-app-mcp-generate/scripts/retrieve_existing_tools.mjs +72 -0
  117. package/skills/experience-app-mcp-generate/scripts/scan_tool_candidates.mjs +195 -0
  118. package/skills/experience-app-mcp-generate/scripts/utils/callback_url.mjs +36 -0
  119. package/skills/experience-app-mcp-generate/scripts/utils/developer_name.mjs +9 -0
  120. package/skills/experience-app-mcp-generate/scripts/utils/eca_check.mjs +156 -0
  121. package/skills/experience-app-mcp-generate/scripts/utils/metadata_path.mjs +13 -0
  122. package/skills/experience-app-mcp-generate/scripts/verify_server.mjs +118 -0
  123. package/skills/experience-cms-content-type-generate/SKILL.md +1 -1
  124. package/skills/nonprofit-fundraising-configure/SKILL.md +1 -1
  125. package/skills/nonprofit-fundraising-configure/references/mcp-invocation.md +52 -4
  126. package/skills/nonprofit-fundraising-configure/references/permission-targeting.md +19 -2
  127. package/skills/platform-custom-field-generate/SKILL.md +24 -16
  128. package/skills/platform-custom-metadata-type-generate/SKILL.md +1 -0
  129. package/skills/platform-custom-setting-generate/SKILL.md +1 -0
  130. package/skills/platform-dataspace-access-configure/SKILL.md +25 -10
  131. package/skills/platform-flexipage-generate/SKILL.md +7 -10
  132. package/skills/platform-flexipage-generate/references/mcp_action_examples.md +42 -38
  133. package/skills/platform-policy-rule-generate/SKILL.md +9 -7
  134. package/skills/platform-policy-rule-generate/references/condition-model.md +3 -3
  135. package/skills/platform-policy-rule-generate/references/conjunction-expression.md +9 -1
  136. package/skills/platform-policy-rule-generate/references/consumer-datacloud-ui.md +9 -1
  137. package/skills/platform-policy-rule-generate/references/examples/ExistsJoinRLS/policyRuleDefinitionSets/ExistsJoinRLS.policyRuleDefinitionSet +1 -2
  138. package/skills/platform-policy-rule-generate/references/examples/FieldReadDeny/policyRuleDefinitionSets/FieldReadDeny.policyRuleDefinitionSet +1 -2
  139. package/skills/platform-policy-rule-generate/references/examples/LastCharactersFieldMasking/policyRuleDefinitionSets/LastCharactersFieldMasking.policyRuleDefinitionSet +1 -2
  140. package/skills/platform-policy-rule-generate/references/examples/PrincipalFieldMatchRLS/policyRuleDefinitionSets/PrincipalFieldMatchRLS.policyRuleDefinitionSet +1 -2
  141. package/skills/platform-policy-rule-generate/references/examples/TaggedObjectAccess/policyRuleDefinitionSets/TaggedObjectAccess.policyRuleDefinitionSet +1 -0
  142. package/skills/platform-policy-rule-generate/references/headless-transport.md +2 -2
  143. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +1 -1
  144. package/skills/platform-policy-rule-generate/references/policy-shapes.md +33 -0
  145. package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
  146. package/skills/platform-policy-rule-generate/references/ui-compatibility.md +5 -5
  147. package/skills/platform-report-generate/SKILL.md +20 -1
  148. package/skills/platform-report-generate/references/summary-formulas-sorting-limits.md +118 -0
  149. package/skills/platform-report-generate/references/verification-checklist.md +12 -0
  150. package/skills/service-digital-engagement-channel-configure/SKILL.md +44 -107
  151. package/skills/service-digital-engagement-channel-configure/assets/messaging_channel_template.xml +2 -0
  152. package/skills/service-digital-engagement-channel-configure/examples/asa_agent_channel.xml +2 -2
  153. package/skills/service-digital-engagement-channel-configure/examples/auth_queue_channel.xml +58 -0
  154. package/skills/service-digital-engagement-channel-configure/examples/omni_flow_channel.xml +2 -2
  155. package/skills/service-digital-engagement-channel-configure/examples/omni_queue_channel.xml +3 -3
  156. package/skills/service-digital-engagement-channel-configure/references/channel_settings.md +18 -14
  157. package/skills/service-digital-engagement-channel-configure/references/onboarding_contract.md +16 -20
  158. package/skills/service-digital-engagement-channel-configure/references/prechat_params.md +10 -0
  159. package/skills/service-digital-engagement-channel-configure/references/recaptcha_handoff.md +38 -0
  160. package/skills/service-digital-engagement-channel-configure/references/user_verification.md +9 -0
  161. package/skills/service-digital-engagement-channel-configure/scripts/check-api-version.sh +4 -4
  162. package/skills/service-digital-engagement-channel-configure/scripts/normalize-channel-name.sh +12 -7
  163. package/skills/service-e911-configure/SKILL.md +242 -0
  164. package/skills/service-itsm-agentic-setup-agent-runtime-access-assign/SKILL.md +1 -1
  165. package/skills/service-itsm-agentic-setup-agentforce-coordinate/SKILL.md +1 -1
  166. package/skills/service-itsm-agentic-setup-agentforce-studio-configure/SKILL.md +1 -1
  167. package/skills/service-itsm-agentic-setup-agentforce-studio-validate/SKILL.md +1 -1
  168. package/skills/service-itsm-agentic-setup-employee-agent-configure/SKILL.md +1 -1
  169. package/skills/service-itsm-agentic-setup-fulfiller-agent-configure/SKILL.md +1 -1
  170. package/skills/service-itsm-agentic-setup-incident-management/SKILL.md +47 -44
  171. package/skills/service-itsm-agentic-setup-incident-management/examples/output-templates.md +110 -83
  172. package/skills/service-itsm-agentic-setup-incident-management/references/manage-incidents-with-ai.md +7 -3
  173. package/skills/service-itsm-agentic-setup-incident-management/references/priority-matrix.md +7 -5
  174. package/skills/service-itsm-agentic-setup-incident-management/references/sla-milestones.md +2 -2
  175. package/skills/service-itsm-agentic-setup-incident-management/references/status-checks.md +437 -0
  176. package/skills/service-itsm-agentic-setup-itsm-agentforce-permset-assign/SKILL.md +1 -1
  177. package/skills/agentforce-bot-upgrade/references/planner-workflow-reference.md +0 -78
  178. package/skills/dx-lifecycle-center/assets/widgets/connect-connected/connect-connected.json +0 -65
  179. package/skills/dx-lifecycle-center/assets/widgets/connect-connected/schema.json +0 -32
  180. package/skills/dx-lifecycle-center/assets/widgets/connect-sign-in/connect-sign-in.json +0 -57
  181. package/skills/dx-lifecycle-center/assets/widgets/connect-sign-in/schema.json +0 -21
  182. package/skills/dx-lifecycle-center/scripts/card-policy.jq +0 -71
  183. package/skills/dx-lifecycle-center/scripts/fill-widget.jq +0 -29
  184. package/skills/dx-lifecycle-center/scripts/widget.sh +0 -28
  185. package/skills/experience-content-media-image-generate/SKILL.md +0 -83
  186. package/skills/experience-content-media-image-generate/scripts/download-image.sh +0 -84
  187. package/skills/experience-content-media-stock-image-search/SKILL.md +0 -193
  188. package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +0 -102
@@ -0,0 +1,658 @@
1
+ <!-- Parent: adlc-author/SKILL.md -->
2
+ # Instruction Resolution
3
+
4
+ > How Agent Script instructions are processed at runtime: from static text to dynamic LLM prompts.
5
+
6
+ ---
7
+
8
+ ## 1. Runtime Lifecycle
9
+
10
+ AgentScript defines deterministic lifecycle hooks around an iterative LLM
11
+ reasoning loop:
12
+
13
+ ```text
14
+ before_reasoning (once per subagent execution)
15
+ -> render effective system.instructions and resolve
16
+ reasoning.instructions (every reasoning iteration)
17
+ -> LLM returns text and zero or more tool calls
18
+ -> tool calls: execute the planned batch; unless control hands off or
19
+ execution stops, render both instruction surfaces for another
20
+ reasoning iteration
21
+ -> no tool calls: advance to after_reasoning
22
+ -> after_reasoning (once per subagent execution, if reached)
23
+ ```
24
+
25
+ Do not confuse a new reasoning iteration after a tool call with
26
+ `after_reasoning`. The latter does not run after each tool.
27
+
28
+ ---
29
+
30
+ ## 2. Instruction Surfaces
31
+
32
+ | Surface | Runtime meaning | Authoring use |
33
+ |---|---|---|
34
+ | Global `system.instructions` | Default declarative system prompt, rendered on each reasoning iteration | Durable identity, safety, scope, and response invariants |
35
+ | Subagent `system.instructions` | Declarative system prompt rendered on each reasoning iteration; replaces the global value for that subagent | Rare specialist override that restates every invariant still required |
36
+ | `reasoning.instructions` | Runtime-resolved instructions rebuilt on every reasoning iteration | Current objective, relevant state, action guidance, and stop conditions |
37
+ | `before_reasoning` | Deterministic procedure that runs once before the reasoning loop | Preconditions, data preparation, and early transitions |
38
+ | `after_reasoning` | Deterministic procedure that runs if execution reaches the hook after the reasoning loop | Final state updates and post-response transitions |
39
+
40
+ Omit a subagent system override when the global instructions already apply. If
41
+ an override is necessary, copy the durable invariants that subagent must retain;
42
+ the compiler selects the subagent value instead of the global value.
43
+
44
+ Treat effective system and reasoning instructions as cumulative. Do not depend
45
+ on a model provider separating or prioritizing the AgentScript surfaces
46
+ differently unless the target runtime's public, versioned contract guarantees
47
+ that behavior. Their combined meaning must contain no contradiction, duplicate
48
+ policy, or reliance on one layer overriding the other.
49
+
50
+ ### System Instructions Are Dynamic Prompt Context, Not a Procedure
51
+
52
+ `system.instructions` may contain merge fields such as
53
+ `{!@variables.account_status}`. The runtime renders the selected global or
54
+ subagent value on each reasoning iteration, so a later iteration can receive
55
+ the current value.
56
+
57
+ System instructions are declarative prompt text. They do not support the
58
+ procedural `instructions: ->` form or runtime statements such as `run`, `set`,
59
+ `if`, or `transition`. Put deterministic procedures in lifecycle or reasoning
60
+ procedure blocks. A merge field only exposes a rendered value to the model; it
61
+ does not turn a system instruction into a runtime predicate or guarantee that
62
+ the model follows a requested branch.
63
+
64
+ ### Separate AgentScript Control from Model Instructions
65
+
66
+ Subagents and variables are AgentScript runtime concepts, not model knowledge.
67
+ The compiler and runtime select the current execution block, evaluate
68
+ conditions, run deterministic actions, update state, interpolate values, and
69
+ expose the currently available tools. Portable model instructions must not
70
+ depend on a provider exposing structured execution-block identity or direct
71
+ variable-store access unless the target runtime's public contract guarantees
72
+ it.
73
+
74
+ Developer documentation may explain subagents and variables because authors
75
+ need that mental model. Text sent to the model must instead state the concrete
76
+ task and response duty. Do not tell the model to inspect the active subagent or
77
+ read `@variables`.
78
+
79
+ ### Scope Response Duties by Branch
80
+
81
+ Do not put an unconditional response duty in the global layer when any branch
82
+ must route, verify, clarify, refuse, close, or escalate without answering. This
83
+ conflict is especially common in router-first agents:
84
+
85
+ ```agentscript
86
+ # WRONG: the effective prompt says both answer and do not answer.
87
+ system:
88
+ instructions: "Answer the user's questions helpfully."
89
+ start_agent agent_router:
90
+ reasoning:
91
+ instructions: ->
92
+ | Do not answer. Route the request.
93
+
94
+ # RIGHT: the global rule allows the current operating task to set posture.
95
+ system:
96
+ instructions: |
97
+ Perform only the current operating task described below. Answer the
98
+ underlying request only when that task calls for an answer. Otherwise
99
+ route, verify, clarify, refuse, or escalate as directed.
100
+ ```
101
+
102
+ Review the effective pair for every execution branch: global or replacement
103
+ system instructions plus the branch's resolved reasoning instructions. A scope
104
+ narrowing is compatible only when the global layer already permits that
105
+ narrowing. For every reachable LLM call, that effective pair must prescribe one
106
+ unambiguous response posture. A subagent system replacement must restate every
107
+ durable invariant it retains.
108
+
109
+ ### Instruction Rendering Before Each LLM Call
110
+
111
+ Before every reasoning iteration, the runtime renders the selected
112
+ `system.instructions` value and evaluates deterministic constructs in
113
+ `reasoning.instructions: ->`. This happens before the LLM sees either effective
114
+ instruction surface.
115
+
116
+ ### What Happens During Resolution
117
+
118
+ 1. **`if`/`else` evaluation**: Conditions are evaluated against current variable values. Only the matching branch is included in the prompt.
119
+ 2. **Variable injection**: `{!@variables.X}` tokens are replaced with current values.
120
+ 3. **`run` execution**: Deterministic `run @actions.X` calls execute and their outputs are captured.
121
+ 4. **`set` execution**: Variable assignments execute immediately.
122
+ 5. **`transition to`**: If reached during deterministic resolution, control
123
+ hands to the target before the current subagent invokes its planner.
124
+
125
+ ### Resolution Example
126
+
127
+ Given this instruction block:
128
+
129
+ ```agentscript
130
+ reasoning:
131
+ instructions: ->
132
+ # Completed-state check from a previous tool call
133
+ if @variables.order_status != "":
134
+ | Report order status {!@variables.order_status}, then stop.
135
+ transition to @subagent.confirmation
136
+
137
+ | Collect the order number, then use {!@actions.lookup_order} once.
138
+ ```
139
+
140
+ Before lookup, the LLM sees only:
141
+ ```text
142
+ Collect the order number, then use lookup_order once.
143
+ ```
144
+
145
+ After the tool stores `order_status`, the instructions are rebuilt. The
146
+ completed-state branch resolves and transitions without asking the LLM to call
147
+ the tool again.
148
+
149
+ ---
150
+
151
+ ## 3. LLM Processing
152
+
153
+ The AgentScript authoring contract defines deterministic resolution and the
154
+ inputs exposed to reasoning, not an exact provider message count. Reasoning
155
+ receives:
156
+
157
+ - One authored node-instruction value: the subagent system override when
158
+ present, otherwise the global `system.instructions`. Runtime base prompts and
159
+ metadata may add other system content outside AgentScript. Merge fields in
160
+ the selected value are rendered for the current reasoning iteration.
161
+ - Conversation history.
162
+ - The resolved `reasoning.instructions`, when non-empty.
163
+ - The currently available tools and their schemas.
164
+
165
+ Do not document or test an exact four-message structure. Tool schemas are not
166
+ necessarily encoded as a chat message, and message transport is not the
167
+ AgentScript authoring contract.
168
+
169
+ ### What the LLM Decides
170
+
171
+ Based on the assembled prompt, an LLM result may contain text and zero or more
172
+ available action calls. For an action call, the model selects the action and
173
+ fills slot parameters (`...`) from conversation context. A model-selected
174
+ transition is an action call; it is not a separate deterministic decision.
175
+
176
+ ### What the LLM Does NOT See
177
+
178
+ - Raw `if`/`else` blocks (already resolved before the iteration)
179
+ - Structured AgentScript execution-block identity or direct variable-store
180
+ access unless the target runtime explicitly provides it
181
+ - `run` statements (already executed before the iteration)
182
+ - `set` statements (already executed)
183
+ - `available when` conditions (already evaluated -- hidden actions are simply absent)
184
+ - `after_reasoning` source code (it is a runtime hook when reached, not authored
185
+ prompt text)
186
+
187
+ ---
188
+
189
+ ## 4. Tool Loop and Re-Resolution
190
+
191
+ The runtime may execute several model-selected calls from one planner result.
192
+ After that batch, it either follows a handoff or stop condition, or begins
193
+ another reasoning iteration and rebuilds both instruction surfaces from
194
+ current state.
195
+
196
+ ### Loop Sequence
197
+
198
+ ```text
199
+ 1. Resolve reasoning instructions
200
+ 2. LLM returns text and zero or more tool calls
201
+ 3. Planned tool calls execute -> configured outputs are captured
202
+ 4. Re-resolve reasoning instructions with updated variables
203
+ - State-dependent checks are evaluated again
204
+ - New data is injected into the prompt
205
+ 5. LLM reasons again with updated context
206
+ 6. Repeat unless execution hands off, pauses, reaches a limit, is cancelled, or
207
+ the planner returns no tool calls
208
+ ```
209
+
210
+ When the planner returns no tool calls, execution advances to
211
+ `after_reasoning`. A handoff, cancellation, confirmation pause, or runtime
212
+ limit can take a different path.
213
+
214
+ ### Post-Action Checks Need Exclusive Control
215
+
216
+ Placing a completed-state check near the top makes its precedence visible, but
217
+ position alone does not suppress later prompt fragments. Use mutually
218
+ exclusive predicates, `else`, or an actual transition when the completed path
219
+ must exclude first-entry guidance:
220
+
221
+ ```agentscript
222
+ reasoning:
223
+ instructions: ->
224
+ # Completed state owns this path.
225
+ if @variables.order_cancelled == True:
226
+ transition to @subagent.confirmation
227
+
228
+ else:
229
+ | Explain that you can help cancel the order and ask for its order
230
+ number.
231
+ ```
232
+
233
+ Without the `else` or transition, completed-state and first-entry duties can be
234
+ assembled in the same iteration. Here the target confirmation subagent owns the
235
+ success response. A transition exits the current subagent before its planner
236
+ runs; merely moving a prompt fragment does not.
237
+
238
+ ---
239
+
240
+ ## 5. Concise Reasoning Instructions
241
+
242
+ Keep `reasoning.instructions` task-local. Include only information that can
243
+ change the current tool choice or response:
244
+
245
+ 1. Checks backed by trusted outcomes or material invariants.
246
+ 2. Deterministic data loading required for this iteration.
247
+ 3. The current objective and only the resolved state it consumes.
248
+ 4. Action guidance, exclusions, and a stop condition.
249
+
250
+ Do not add a variable or branch merely to remind the model what happened in
251
+ surviving conversation history.
252
+
253
+ Keep persona, tone, disclosure, safety, and broad scope rules in the effective
254
+ system layer. Put tool-specific trigger details in action descriptions instead
255
+ of repeating them in the reasoning instructions.
256
+
257
+ ```agentscript
258
+ reasoning:
259
+ instructions: ->
260
+ # Trusted verification output controls the protected capability.
261
+ if @variables.is_verified == True:
262
+ | Complete the requested account task using the available action once.
263
+
264
+ if @variables.is_verified == False:
265
+ | Ask for the minimum information needed to verify identity. Do not use account-changing actions.
266
+ ```
267
+
268
+ ---
269
+
270
+ ## 6. Common Instruction Patterns
271
+
272
+ ### Pattern 1: Security Gate
273
+
274
+ Prevent access to sensitive actions until identity is verified:
275
+
276
+ ```agentscript
277
+ reasoning:
278
+ instructions: ->
279
+ if @variables.is_verified == False:
280
+ | Explain that identity verification is required before account
281
+ changes and ask for the user's email address.
282
+
283
+ if @variables.is_verified == True:
284
+ | Confirm successful verification and ask what account change the user
285
+ wants to make.
286
+
287
+ actions:
288
+ update_account: @actions.update_account_info
289
+ description: "Update account information"
290
+ available when @variables.is_verified == True
291
+ with field = ...
292
+ with value = ...
293
+ ```
294
+
295
+ The `available when` guard hides the action from the LLM until verification
296
+ passes. The conditional instructions tell the model which response duty is
297
+ current.
298
+
299
+ ### Pattern 2: Data-Dependent Instructions
300
+
301
+ Load data first, then tailor instructions based on the result:
302
+
303
+ ```agentscript
304
+ reasoning:
305
+ instructions: ->
306
+ run @actions.get_account_status
307
+ with account_id = @variables.account_id
308
+ set @variables.account_status = @outputs.status
309
+ set @variables.balance = @outputs.balance
310
+
311
+ | Account status: {!@variables.account_status}
312
+ Current balance: {!@variables.balance}
313
+
314
+ if @variables.account_status == "delinquent":
315
+ | IMPORTANT: This account is delinquent.
316
+ Collect payment before processing any other requests.
317
+ Offer payment plan options if customer cannot pay in full.
318
+
319
+ if @variables.account_status == "active":
320
+ | This account is in good standing.
321
+ Process requests normally.
322
+ ```
323
+
324
+ ### Pattern 3: Action Chaining
325
+
326
+ Execute one action, then use its output to drive the next:
327
+
328
+ ```agentscript
329
+ reasoning:
330
+ instructions: ->
331
+ # Post-action check: case was created in previous loop
332
+ if @variables.case_id != "":
333
+ run @actions.assign_case
334
+ with case_id = @variables.case_id
335
+ with priority = @variables.priority
336
+ transition to @subagent.case_confirmation
337
+
338
+ | Explain that issue details are needed to create a support case and ask
339
+ the user to describe the issue.
340
+ ```
341
+
342
+ ### Pattern 4: Machine-Known Gate
343
+
344
+ Use compound conditions when trusted machine state controls a material
345
+ capability. Do not persist the user's current intent merely to route it; let the
346
+ router infer current intent from the latest turn and conversation history.
347
+
348
+ ```agentscript
349
+ reasoning:
350
+ instructions: ->
351
+ if @variables.is_verified == True and @variables.account_locked == False:
352
+ | Complete the requested account task using the available action.
353
+
354
+ if @variables.is_verified == False:
355
+ | Ask for the minimum information needed to verify identity.
356
+
357
+ if @variables.account_locked == True:
358
+ | Do not use account-changing actions. Explain how to unlock the
359
+ account or escalate.
360
+ ```
361
+
362
+ ---
363
+
364
+ ## 7. Anti-Patterns to Avoid
365
+
366
+ ### Anti-Pattern 1: Re-Explaining Language Syntax
367
+
368
+ Keep this reference focused on instruction resolution. For supported flat
369
+ conditions, nested-condition limitations, and post-action conditionals, use the
370
+ canonical
371
+ [Conditional Control Flow Syntax](agent-script-core-language.md#conditional-control-flow-syntax)
372
+ section.
373
+
374
+ ### Anti-Pattern 2: Conflicting Entry and Completed-State Text
375
+
376
+ ```agentscript
377
+ # WRONG -- both fragments can survive when order_status is populated
378
+ reasoning:
379
+ instructions: ->
380
+ | Ask for the order number.
381
+
382
+ if @variables.order_status != "":
383
+ | Report the current order status.
384
+
385
+ # CORRECT -- the predicates make the duties exclusive
386
+ reasoning:
387
+ instructions: ->
388
+ if @variables.order_status != "":
389
+ | Report the current order status.
390
+ else:
391
+ | Ask for the order number.
392
+ ```
393
+
394
+ Moving a condition to the top can make precedence easier to read, but the
395
+ runtime resolves the whole procedure before invoking the planner. Position
396
+ alone does not exclude another prompt fragment. Use exclusive predicates or a
397
+ reached transition when only one duty should survive.
398
+
399
+ ### Anti-Pattern 3: Persona in Subagent Instructions
400
+
401
+ ```text
402
+ # WRONG -- Persona text duplicated in every subagent
403
+ reasoning:
404
+ instructions: |
405
+ You are a friendly, professional customer service agent.
406
+ Help the customer with their order.
407
+
408
+ # CORRECT -- Persona in system instructions, subagent has operational instructions only
409
+ system:
410
+ instructions: |
411
+ You are a friendly, professional customer service agent.
412
+
413
+ subagent order_support:
414
+ reasoning:
415
+ instructions: ->
416
+ | Help the customer check their order status.
417
+ | Ask for the order number if not provided.
418
+ ```
419
+
420
+ ### Anti-Pattern 4: Using `|` When `->` Is Needed
421
+
422
+ ```agentscript
423
+ # WRONG -- Using literal mode when conditionals are needed
424
+ reasoning:
425
+ instructions: |
426
+ if @variables.is_verified == True:
427
+ Show account details.
428
+
429
+ # The above sends the literal text "if @variables.is_verified == True:" to the LLM!
430
+
431
+ # CORRECT -- Use procedural mode for conditionals
432
+ reasoning:
433
+ instructions: ->
434
+ if @variables.is_verified == True:
435
+ | Show account details.
436
+ ```
437
+
438
+ ### Anti-Pattern 5: Missing Variable Injection Syntax
439
+
440
+ ```agentscript
441
+ # WRONG -- Variable name as literal text
442
+ reasoning:
443
+ instructions: ->
444
+ | Tell the user their order ID is @variables.order_id.
445
+
446
+ # CORRECT -- Use injection syntax
447
+ reasoning:
448
+ instructions: ->
449
+ | Tell the user their order ID is {!@variables.order_id}.
450
+ ```
451
+
452
+ ### Pattern: `after_reasoning` Lifecycle Actions
453
+
454
+ `run` is supported in `after_reasoning` through the common action mechanism.
455
+ The block runs when the subagent's reasoning loop reaches that lifecycle hook,
456
+ including a planner result with no tool calls. It is not an after-every-tool
457
+ hook and can be bypassed by other terminal paths such as a handoff. Use it only
458
+ when the follow-up belongs at that lifecycle point.
459
+
460
+ Do not use this lifecycle hook for an irreversible action merely because it is
461
+ deterministic; consequential-action preconditions still need explicit guards.
462
+
463
+ ```agentscript
464
+ # Log every completed reasoning turn.
465
+ after_reasoning:
466
+ run @actions.log_event
467
+ with event = "turn_completed"
468
+ ```
469
+
470
+ ### Anti-Pattern 7: Prose-Based Conditional Logic
471
+
472
+ ```agentscript
473
+ # WRONG -- Conditional behavior described in prose; the LLM must interpret
474
+ # these directives and may ignore, reorder, or misapply them
475
+ reasoning:
476
+ instructions: ->
477
+ | If the user is a VIP, offer priority support.
478
+ If they haven't been verified, ask for verification first.
479
+ If the refund has been approved, confirm it and end the conversation.
480
+ Check availability before booking.
481
+
482
+ # CORRECT when the conditions are trusted machine facts protecting material
483
+ # invariants. The LLM sees only the matching operating instructions.
484
+ reasoning:
485
+ instructions: ->
486
+ if @variables.refund_approved == True:
487
+ transition to @subagent.confirmation
488
+
489
+ if @variables.refund_approved == False and @variables.customer_verified == False:
490
+ | Explain that identity verification is required before proceeding and
491
+ ask for the user's email address.
492
+
493
+ if @variables.refund_approved == False and @variables.customer_verified == True:
494
+ | Help with the current account request.
495
+
496
+ if @variables.refund_approved == False and @variables.customer_verified == True and @variables.customer_tier == "vip":
497
+ | Mention that priority support is available.
498
+ ```
499
+
500
+ Why this matters: machine-known authorization, confirmation, action-result, and
501
+ external-ordering conditions must not depend on model discretion. AgentScript
502
+ resolves those branches before the model sees the prompt.
503
+
504
+ Do not manufacture state merely so conversational judgment can become an
505
+ `if/else`. Use a deterministic branch only when a named runtime consumer and
506
+ material cause justify it. Reserve prose for current intent, tone, phrasing,
507
+ and other decisions the model should interpret from the conversation.
508
+
509
+ ---
510
+
511
+ ## 8. Syntax Patterns Reference
512
+
513
+ ### Literal Mode (`|`)
514
+
515
+ Static text passed directly to the LLM. No evaluation occurs:
516
+
517
+ ```agentscript
518
+ instructions: |
519
+ Help the customer with their order.
520
+ Be professional and concise.
521
+ ```
522
+
523
+ Or with the `|` prefix on each line (inside procedural mode):
524
+
525
+ ```agentscript
526
+ instructions: ->
527
+ | Help the customer with their order.
528
+ Be professional and concise.
529
+ ```
530
+
531
+ ### Procedural Mode (`->`)
532
+
533
+ Enables conditionals, variable injection, and deterministic actions:
534
+
535
+ ```agentscript
536
+ instructions: ->
537
+ if @variables.condition == True:
538
+ | Instruction included when the condition is true.
539
+ else:
540
+ | Instruction included when the condition is false.
541
+ ```
542
+
543
+ ### Variable Injection
544
+
545
+ ```agentscript
546
+ | Tell the user order {!@variables.order_id} has status
547
+ {!@variables.status}.
548
+ ```
549
+
550
+ ### Deterministic Run
551
+
552
+ ```agentscript
553
+ run @actions.load_data
554
+ with param = @variables.value
555
+ set @variables.result = @outputs.field
556
+ ```
557
+
558
+ ### Deterministic Set
559
+
560
+ ```agentscript
561
+ set @variables.counter = @variables.counter + 1
562
+ ```
563
+
564
+ ### Deterministic Transition
565
+
566
+ ```agentscript
567
+ transition to @subagent.next_subagent
568
+ ```
569
+
570
+ ### Conditional Transition
571
+
572
+ ```agentscript
573
+ if @variables.all_collected == True:
574
+ transition to @subagent.confirmation
575
+ ```
576
+
577
+ ---
578
+
579
+ ## 9. Programmatic Trace Access
580
+
581
+ To verify how instructions were resolved at runtime, use the trace files generated by `sf agent preview`.
582
+
583
+ ### Trace File Location
584
+
585
+ ```text
586
+ .sfdx/agents/{BundleName}/sessions/{sessionId}/traces/{planId}.json
587
+ ```
588
+
589
+ ### Reading Instruction Resolution from Traces
590
+
591
+ ```bash
592
+ # Extract the resolved instructions that the LLM received
593
+ jq -r '.planTrace.steps[] | select(.type == "LLM_STEP") | .input' \
594
+ ~/.sf/sfdx/agents/MyAgent/sessions/*/traces/*.json
595
+
596
+ # Extract the LLM's response
597
+ jq -r '.planTrace.steps[] | select(.type == "LLM_STEP") | .output' \
598
+ ~/.sf/sfdx/agents/MyAgent/sessions/*/traces/*.json
599
+
600
+ # Check which variables were set during resolution
601
+ jq -r '.planTrace.steps[] | select(.type == "ACTION_STEP") | {name: .name, pre: .preVars, post: .postVars}' \
602
+ ~/.sf/sfdx/agents/MyAgent/sessions/*/traces/*.json
603
+ ```
604
+
605
+ ### Verifying Per-Iteration Resolution
606
+
607
+ To confirm that `if`/`else` blocks resolved correctly, compare the trace's `LLM_STEP` input against your `instructions: ->` block. The LLM input should contain only the branches that matched, with all `{!@variables.X}` tokens replaced with actual values.
608
+
609
+ If the trace shows unexpected instruction text:
610
+ 1. Check that you used `->` mode (not `|` mode) when conditionals are present
611
+ 2. Verify variable values at the time of resolution (check `preVars` on preceding `ACTION_STEP`)
612
+ 3. Confirm that `if` conditions use the correct comparison operators
613
+
614
+ ### Using STDM for Production Trace Analysis
615
+
616
+ For production agents, use the Session Trace Data Model (STDM) in Data Cloud to access trace data programmatically. The STDM captures `LLM_STEP` records with `input` and `output` fields that contain the resolved prompt and LLM response. This is useful for auditing instruction resolution at scale across hundreds of live sessions.
617
+
618
+ ---
619
+
620
+ ## 10. Resolution Across Subagent Transitions
621
+
622
+ When a subagent transition occurs (via `@utils.transition to @subagent.X` or
623
+ `transition to @subagent.X`), the current subagent stops resolving and the
624
+ target subagent begins its lifecycle. Conversation history and shared state are
625
+ retained:
626
+
627
+ 1. The current subagent's remaining instructions are NOT processed
628
+ 2. The new subagent's `before_reasoning:` runs (if present)
629
+ 3. The new subagent's `reasoning: instructions:` resolves for its first iteration
630
+ 4. The LLM receives the new subagent's assembled prompt
631
+
632
+ **Important**: Variables persist across transitions. A variable set in Subagent A is available in Subagent B. This is how you pass data between subagents:
633
+
634
+ ```agentscript
635
+ # Subagent A: Collect data
636
+ subagent collect_info:
637
+ reasoning:
638
+ instructions: ->
639
+ | Ask for the user's order number.
640
+ actions:
641
+ capture_order: @actions.get_order_id
642
+ with input = ...
643
+ set @variables.order_id = @outputs.order_id
644
+
645
+ after_reasoning:
646
+ if @variables.order_id != "":
647
+ transition to @subagent.process_order
648
+
649
+ # Subagent B: Use the data
650
+ subagent process_order:
651
+ reasoning:
652
+ instructions: ->
653
+ # order_id is available from Subagent A
654
+ | Processing order {!@variables.order_id}...
655
+ run @actions.get_order_details
656
+ with order_id = @variables.order_id
657
+ set @variables.order_status = @outputs.status
658
+ ```