@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,112 @@
1
+ # AgentScript Compiler Setup and Provenance
2
+
3
+ For every authoring, repair, or audit task with an existing `.agent` file, run
4
+ the bundled compiler locally before target-org validation. This is the cheap,
5
+ repeatable first pass even when the customer has an authenticated org. The
6
+ customer should not need to clone this skills repository or modify their
7
+ project dependencies.
8
+
9
+ ## Provider order
10
+
11
+ Use the first working local provider and record it:
12
+
13
+ 1. an explicit `AGENTSCRIPT_SDK_ENTRY` override, when the user supplied one;
14
+ 2. the last successfully verified SDK in the skill-owned cache;
15
+ 3. an AgentScript SDK already installed in the customer project or skill host;
16
+ 4. the public npm package installed into the skill-owned cache;
17
+ 5. a fresh build from the public `salesforce/agentscript` source repository.
18
+
19
+ After the local pass, use target-org validation when an authenticated org is
20
+ available. The two checks are complementary: the local compiler provides fast
21
+ feedback, while the org establishes what that deployment target accepts. Use a
22
+ bounded static review only when no local compiler or org validation surface is
23
+ available.
24
+
25
+ An absent or unauthenticated org is not a reason to skip the local compiler.
26
+ Local compilation does not require org access. Do not report “no org” as the
27
+ cause of **compiler not used**; attempt the local providers below and report the
28
+ actual setup or loading failure if none works.
29
+
30
+ Compiler setup must not become an all-or-nothing gate. Try each applicable
31
+ install provider once. If installation fails, retain the error, continue with
32
+ the strongest remaining validation surface, and state **compiler not used**
33
+ with the cause rather than abandoning the authoring or audit result.
34
+
35
+ ## Install from npm
36
+
37
+ Resolve the installed `agentforce-generate` skill directory and run:
38
+
39
+ ```bash
40
+ node <skill-directory>/scripts/setup-agentscript-sdk.mjs --npm --json
41
+ ```
42
+
43
+ The setup script installs the pinned public
44
+ `@sf-agentscript/agentforce` package into the user cache, not the customer
45
+ project or global npm prefix. It then runs a compiler smoke test and records the
46
+ resolved package version and entry point.
47
+
48
+ If evidence indicates that the bundled npm pin is behind the currently
49
+ published package, retry once with an exact newer version or `latest` and retain
50
+ the resolved version:
51
+
52
+ ```bash
53
+ node <skill-directory>/scripts/setup-agentscript-sdk.mjs \
54
+ --npm --version latest --force --json
55
+ ```
56
+
57
+ Do not call a package current merely because `latest` resolved. Compare its
58
+ diagnostics with the syntax under review, the public source revision when
59
+ needed, and the deployment org before release.
60
+
61
+ ## Build from public source
62
+
63
+ Use the source fallback when the npm package is unavailable, cannot load, or
64
+ appears older than the syntax under review:
65
+
66
+ ```bash
67
+ node <skill-directory>/scripts/setup-agentscript-sdk.mjs \
68
+ --source --source-ref main --force --json
69
+ ```
70
+
71
+ This downloads `https://github.com/salesforce/agentscript.git` into the same
72
+ skill-owned cache, records the exact fetched commit, installs its pinned pnpm
73
+ dependencies, builds the Agentforce SDK and its dependencies, and runs the same
74
+ compiler smoke test. It requires Git, either pnpm or Corepack-provided pnpm, and
75
+ the operating-system build prerequisites required by the selected public
76
+ source revision. A missing native build prerequisite is an installation failure
77
+ to report and fall back from; it is not a reason to abandon the audit.
78
+
79
+ Use a tag or commit with `--source-ref` when reproducibility matters. A source
80
+ build can be newer than the deployment org; it is evidence about that source
81
+ revision, not proof that an org accepts the same syntax.
82
+
83
+ ## Use and report the compiler
84
+
85
+ Run the bundled indexer after setup:
86
+
87
+ ```bash
88
+ node <skill-directory>/scripts/index-agent.mjs <agent-file>
89
+ ```
90
+
91
+ The JSON result includes a `compiler` object. Always carry these fields into
92
+ the audit or authoring report:
93
+
94
+ - provider: ambient npm, cached npm, public source, or explicit entry;
95
+ - exact npm package and resolved version, when applicable;
96
+ - exact source commit, when applicable;
97
+ - compiler entry path;
98
+ - whether target-org validation also ran.
99
+
100
+ If the indexer was not run, say so. If it failed before loading a compiler,
101
+ report **compiler not used** and the reason. Never describe a prompt-only or
102
+ regex inspection as compiler validation.
103
+
104
+ ## Overrides and cache
105
+
106
+ - `AGENTSCRIPT_SDK_ENTRY` selects a specific built SDK entry file.
107
+ - `AGENTFORCE_GENERATE_CACHE` selects a different cache root.
108
+ - `XDG_CACHE_HOME` changes the standard cache root.
109
+
110
+ The default cache is `.cache/agentforce-generate` under the current user's home
111
+ directory. Setup writes only below the selected cache root and does not install
112
+ global packages.
@@ -0,0 +1,277 @@
1
+ # Architecture Patterns
2
+
3
+ > Architecture mechanics reference. Start with `references/patterns-by-requirement.md`
4
+ > to choose patterns by scenario, then use this file for implementation details.
5
+
6
+ > All architecture patterns below work for both `AgentforceServiceAgent` and `AgentforceEmployeeAgent`. The only difference is that employee agents cannot use `@utils.escalate` or `connection messaging:` — replace escalation with a `@utils.transition` to a help subagent or an action that creates a case/ticket.
7
+
8
+ ## When to Use Each Pattern
9
+
10
+ These are composable mechanics, not stages or a hierarchy. Start with the
11
+ smallest architecture that satisfies the requirements, then add each
12
+ independently required gate or post-action behavior.
13
+
14
+ | Pattern | Use When |
15
+ |---------|----------|
16
+ | Single Scope | Default. One domain `start_agent` block, zero `subagent` blocks, and one compatible set of instructions, actions, authority, and escalation behavior |
17
+ | Router-First Architecture | Multiple genuine domains require different objectives, instructions, actions, authority, or escalation behavior; use HyperClassifier when the router is transition-only and routing latency matters |
18
+ | Verification Gate | Sensitive data, payments, or PII require identity verification first |
19
+ | Post-Action Re-resolution | Trusted action output must drive a named follow-up instruction, gate, or action input |
20
+
21
+ ## Smallest Architecture First
22
+
23
+ Default to one domain `start_agent` block and zero `subagent` blocks. Do not
24
+ create an `agent_router` that only transitions to that one domain. Add a
25
+ subagent only when the boundary changes at least one of:
26
+
27
+ ```text
28
+ objective | instructions | available actions | authority | escalation behavior
29
+ ```
30
+
31
+ Use `start_agent agent_router` only when multiple genuine domains require
32
+ current-intent classification. Verification gates and post-action
33
+ re-resolution are independent mechanics that can be combined with either a
34
+ single-subagent or router-first design. Linear sequencing is workflow-local
35
+ external ordering, not a default conversation architecture.
36
+
37
+ ## Router-First Architecture Mechanics
38
+
39
+ A central `agent_router` routes to specialized subagents. Transition paths should be use-case-driven: subagent -> subagent when workflow continues naturally, and subagent -> router when the conversation needs reclassification.
40
+
41
+ ```agentscript
42
+ start_agent agent_router:
43
+ description: "Route user requests to the appropriate subagent"
44
+
45
+ model_config:
46
+ model: "model://sfdc_ai__DefaultEinsteinHyperClassifier"
47
+
48
+ reasoning:
49
+ actions:
50
+ to_orders: @utils.transition to @subagent.order_support
51
+ description: "Order questions"
52
+ to_returns: @utils.transition to @subagent.return_support
53
+ description: "Return or refund requests"
54
+ to_general: @utils.transition to @subagent.general_support
55
+ description: "General questions"
56
+
57
+ subagent order_support:
58
+ description: "Handle order inquiries"
59
+ reasoning:
60
+ instructions: ->
61
+ | Help the customer with their order.
62
+ actions:
63
+ lookup: @actions.get_order
64
+ description: "Look up order"
65
+ to_returns: @utils.transition to @subagent.return_support
66
+ description: "Continue to return workflow when needed"
67
+ ```
68
+
69
+ > **Routing lives in `start_agent`** -- put classification transitions in `start_agent agent_router:`. Do NOT create a separate routing-only subagent (e.g. `main_menu`, `central_hub`) -- that duplicates the router, adds an extra LLM hop (~3-5s latency), and confuses the platform. A transition back to router is optional and should only be added when the use case requires reclassification.
70
+
71
+ ### Fast routing with Einstein HyperClassifier
72
+
73
+ Use HyperClassifier when the node has one job: select one transition from the
74
+ current request and conversation context. Adding this model configuration makes
75
+ the block a restricted router node rather than a general reasoning node:
76
+
77
+ ```agentscript
78
+ model_config:
79
+ model: "model://sfdc_ai__DefaultEinsteinHyperClassifier"
80
+ ```
81
+
82
+ It is a good fit when multiple genuine domains already justify a router and
83
+ classification latency matters. The router selects a destination; the target
84
+ subagent handles the request and produces the user-facing response.
85
+
86
+ The restrictions are part of the design:
87
+
88
+ - reasoning actions must be `@utils.transition`;
89
+ - `before_reasoning` and `after_reasoning` are not supported;
90
+ - it cannot classify from images;
91
+ - it cannot fill action inputs, run domain actions, set variables, escalate, or
92
+ delegate to a connected agent;
93
+ - it cannot ask a clarifying question directly. When ambiguity needs a
94
+ conversation, transition to a clarification or fallback subagent.
95
+
96
+ Use `available when` to remove routes based on trusted runtime state before
97
+ classification. Give every route a distinct description that states its
98
+ positive scope and important exclusions. Treat those descriptions as the
99
+ primary classification contract. Keep `reasoning.instructions` concise: state
100
+ the shared routing duty, such as selecting exactly one route without answering,
101
+ and put route-specific boundaries in the action descriptions. Add a fallback
102
+ route only when the agent has an intended fallback behavior.
103
+
104
+ An instruction-free router is structurally valid. It can preserve an optimized
105
+ one-step routing path in runtimes where router instructions compile into a
106
+ lifecycle hook, but use that form only when the action descriptions fully carry
107
+ the routing contract and preview traces confirm the intended optimization.
108
+ Instructions are not prohibited by HyperClassifier; this is a measured latency
109
+ tradeoff, not a language requirement.
110
+
111
+ When adding HyperClassifier to an existing compatible router, preserve its
112
+ instruction block unless changing that contract is separately required. An
113
+ `instructions: ->` block containing only `|` prompt text is valid; do not
114
+ normalize it to `instructions: |` as part of the model-config repair merely
115
+ because it has no runtime statements.
116
+
117
+ Keep an ordinary reasoning model when the entry node must answer, clarify,
118
+ collect information, manipulate state, invoke non-transition actions, inspect
119
+ images, or use lifecycle hooks. HyperClassifier is an optimization for a
120
+ compatible router, not a reason to create more subagents.
121
+
122
+ Validate structure, then validate routing behavior:
123
+
124
+ ```bash
125
+ sf agent validate authoring-bundle --json --api-name <BundleName> -o <OrgAlias>
126
+ sf agent preview start --json --use-live-actions --authoring-bundle <BundleName> -o <OrgAlias>
127
+ ```
128
+
129
+ Preview positive and negative examples for every route, ambiguous boundary
130
+ utterances, follow-up turns, unavailable-route states, and the intended
131
+ fallback. Inspect the selected transition in the trace; response text alone
132
+ does not prove routing.
133
+
134
+ Without HyperClassifier, transition actions on an ordinary reasoning node
135
+ remain model-selected and the node can respond instead. That flexibility is
136
+ useful when conversation at the entry node is intentional.
137
+
138
+ ## Verification Gate
139
+
140
+ Users must pass through identity verification before accessing protected subagents. Use when handling sensitive data, payments, or PII. Uses deterministic routing (`instructions: ->`) so the gate cannot be bypassed by LLM conversational drift.
141
+
142
+ ```agentscript
143
+ variables:
144
+ is_verified: mutable boolean = False
145
+
146
+ start_agent agent_router:
147
+ description: "Route through identity verification"
148
+ reasoning:
149
+ instructions: ->
150
+ if @variables.is_verified == False:
151
+ transition to @subagent.identity_verification
152
+
153
+ | Select the best tool to call based on conversation history and the user's current intent.
154
+ actions:
155
+ to_account: @utils.transition to @subagent.account_mgmt
156
+ description: "Account management"
157
+ available when @variables.is_verified == True
158
+ to_refund: @utils.transition to @subagent.refund_processor
159
+ description: "Process a refund"
160
+ available when @variables.is_verified == True
161
+
162
+ subagent identity_verification:
163
+ description: "Verify customer identity"
164
+ reasoning:
165
+ instructions: ->
166
+ if @variables.is_verified == True:
167
+ | Identity verified. Ask which protected task to continue.
168
+ else:
169
+ | Ask for the minimum information needed to verify identity.
170
+ actions:
171
+ verify_email: @actions.verify_identity
172
+ description: "Verify customer email"
173
+ set @variables.is_verified = @outputs.verified
174
+
175
+ to_account: @utils.transition to @subagent.account_mgmt
176
+ description: "Account management"
177
+ available when @variables.is_verified == True
178
+
179
+ escalate_now: @utils.escalate
180
+ description: "Transfer to human"
181
+ ```
182
+
183
+ `is_verified` has one trusted writer (`verify_identity`) and named consumers
184
+ (the authorization transitions). Define its expiry, reset, correction, and
185
+ cancellation behavior. No mutable variable is needed for the user's ordinary
186
+ follow-up context.
187
+
188
+ ## Post-Action Re-resolution
189
+
190
+ The subagent can re-resolve after an action completes. Persist action output
191
+ only when a named later runtime consumer needs the exact value. Make
192
+ post-action and first-entry duties mutually exclusive; placing the post-action
193
+ check first can make that ownership easier to review, but position alone does
194
+ not exclude another fragment:
195
+
196
+ ```agentscript
197
+ variables:
198
+ risk_score: mutable number = -1
199
+
200
+ subagent retention_review:
201
+ description: "Use a returned risk score to select retention guidance"
202
+ reasoning:
203
+ instructions: ->
204
+ # POST-ACTION CHECK (first for readability, exclusive by predicate)
205
+ if @variables.risk_score >= 80:
206
+ | Use the returned risk score {!@variables.risk_score}. Offer
207
+ the approved high-risk retention options.
208
+ else if @variables.risk_score >= 0:
209
+ | Use the returned risk score {!@variables.risk_score}. Follow
210
+ the standard retention policy.
211
+ else:
212
+ | Explain that a risk assessment is needed before making an offer.
213
+ actions:
214
+ assess_risk: @actions.load_risk_score
215
+ with customer_id = ...
216
+ available when @variables.risk_score < 0
217
+ set @variables.risk_score = @outputs.score
218
+ ```
219
+
220
+ Here `risk_score` is trusted action output consumed by prompt branches and the
221
+ repeat-prevention gate. Define when a new request resets or refreshes it.
222
+
223
+ ## Migrating to Multi-Domain Router-First Architecture
224
+
225
+ Refactor a flat agent only after identifying multiple genuine domains whose
226
+ boundaries change objective, instructions, actions, authority, or escalation
227
+ behavior:
228
+
229
+ 1. **Prove the boundaries** — group related intents unless behavior changes
230
+ 2. **Move instructions and actions** from the monolithic subagent into specialized subagents. Each subagent needs BOTH its Level 1 action definitions (under `subagent > actions`) AND Level 2 action invocations (under `subagent > reasoning > actions`).
231
+ 3. **Create `start_agent agent_router:`** with transition actions pointing to each specialized subagent
232
+ 4. **Add transitions based on workflow needs** — subagent -> subagent for continuous workflows, or subagent -> router for reclassification turns
233
+ 5. **Re-preview immediately** — verify subagent routing works before making further changes
234
+
235
+ **Common migration mistakes:**
236
+ - Creating a separate `main_menu` subagent instead of using `start_agent agent_router:` as the hub — adds an unnecessary LLM hop
237
+ - Leaving action definitions in `start_agent` instead of moving them to specialized subagents — all actions visible in all subagents, confusing the planner
238
+ - Routing everything back to router by default, even when a direct subagent-to-subagent transition better matches the workflow
239
+ - If trace shows `topic: "DefaultTopic"`, check that subagent descriptions contain keywords matching test utterances
240
+
241
+ ## Multi-Intent Handling
242
+
243
+ When a user sends requests for multiple domains in one message, route one
244
+ domain and preserve the remaining request in conversation history:
245
+
246
+ ```agentscript
247
+ start_agent agent_router:
248
+ description: "Route one domain request at a time"
249
+ reasoning:
250
+ instructions: |
251
+ You are a router only. Do NOT answer questions directly.
252
+ If the user asks about multiple domains in one message, route to
253
+ the first domain. After that task is complete, remind the user
254
+ about the other request from conversation history.
255
+ ```
256
+
257
+ No queue variable is needed while the original turn survives in conversation
258
+ history. Persist a queue only if exact external ordering must outlive the
259
+ configured history window, and then define its writer, consumer, reset, expiry,
260
+ correction, and cancellation behavior.
261
+
262
+ ## Handling Incomplete Action Inputs
263
+
264
+ - Use `with param = ...` (slot-fill) for inputs the LLM should extract from conversation
265
+ - Add instructions that tell the LLM to invoke the action with whatever data is available
266
+ - Anti-pattern: Making the LLM ask for ALL inputs before invoking
267
+
268
+ ## Controlling Opportunistic Action Chains
269
+
270
+ In long action chains (A->B->C->D), the LLM may invoke downstream actions as soon as prerequisites are met. To control this:
271
+
272
+ - Add explicit gating in instructions: "Only invoke generate_resolution if the user explicitly asks"
273
+ - Use `available when` guards when successful external output, authorization,
274
+ confirmation, or required ordering supplies a machine-checkable precondition
275
+ - Distinguish between "analyze only" and "full resolution" workflows in instructions
276
+
277
+ Anti-pattern: Leaving action chains ungated so the LLM runs the entire pipeline for every query.
@@ -0,0 +1,255 @@
1
+ # Common AgentScript Control-Flow Pitfalls
2
+
3
+ Use this checklist when authoring, reviewing, debugging, or optimizing an
4
+ AgentScript workflow. It focuses on mistakes that look reasonable in the source
5
+ but do not mean what their formatting suggests.
6
+
7
+ For an audit, use the contents below as a lookup after the initial artifact
8
+ scan. Read the sections that match a named observation; do not delay a ranked
9
+ finding or repair by reviewing every pitfall first.
10
+
11
+ ## Contents
12
+
13
+ - [The simple mental model](#the-simple-mental-model)
14
+ - [Variable visibility and condition ownership](#variable-visibility-and-condition-ownership)
15
+ - [Prompt text that looks like code](#prompt-text-that-looks-like-code)
16
+ - [Repeated prompt markers](#repeated-prompt-markers)
17
+ - [Step labels without runtime state](#step-labels-without-runtime-state)
18
+ - [Focused continuation references](#focused-continuation-references)
19
+ - [Review checklist](#review-checklist)
20
+
21
+ ## The simple mental model
22
+
23
+ AgentScript has three different execution surfaces:
24
+
25
+ 1. Deterministic constructs such as `if`, `run`, `set`, `transition to`, and
26
+ lifecycle hooks execute in the runtime.
27
+ 2. Text introduced by `|` becomes instructions for the model.
28
+ 3. Actions under `reasoning.actions` become tools the model may choose.
29
+
30
+ Do not rely on indentation, numbering, or imperative words inside prompt text
31
+ to behave like runtime control flow.
32
+
33
+ ## Variable visibility and condition ownership
34
+
35
+ ### Pitfall: the model is expected to read stored state
36
+
37
+ The runtime can evaluate and bind `@variables.X`. The model cannot inspect the
38
+ variable store directly. Inside `|` text, a bare variable reference contributes
39
+ only its literal name; it does not inject the stored value. The same value could
40
+ still be visible if it was separately interpolated or preserved in conversation
41
+ or tool history:
42
+
43
+ ```agentscript
44
+ # Model sees the characters "@variables.case_summary", not the summary value.
45
+ | Explain @variables.case_summary to the customer.
46
+
47
+ # Model receives the current value.
48
+ | Explain this case summary: {!@variables.case_summary}
49
+ ```
50
+
51
+ Do not add interpolation when the text merely names a parameter:
52
+
53
+ ```agentscript
54
+ | Set next_destination to "self_service".
55
+ ```
56
+
57
+ That instruction asks the model to supply a value; it does not ask the model to
58
+ read the current value.
59
+
60
+ ### Pitfall: interpolation is mistaken for deterministic control
61
+
62
+ ```agentscript
63
+ # BAD when this must be an exact branch
64
+ | If {!@variables.account_status} == "blocked":
65
+ do the blocked-account steps.
66
+ ```
67
+
68
+ The merge field reveals the value, but the model still performs the comparison
69
+ and decides whether to comply. If the runtime fact must always select the same
70
+ branch, use AgentScript control:
71
+
72
+ ```agentscript
73
+ if @variables.account_status == "blocked":
74
+ | Help the customer recover access to the blocked account.
75
+ ```
76
+
77
+ Keep situation-aware judgment with the model:
78
+
79
+ ```agentscript
80
+ | If the user wants to speak with a human, use
81
+ {!@actions.escalate_to_support}.
82
+ ```
83
+
84
+ Do not convert conditions mechanically. Ask whether the decision is an exact
85
+ trusted fact with a mandatory consequence or an interpretation of natural
86
+ language and context.
87
+
88
+ ## Prompt text that looks like code
89
+
90
+ ### Pitfall: indented prompt text appears scoped
91
+
92
+ ```agentscript
93
+ if @variables.lookup_failed == True:
94
+ | Failure path:
95
+ Call {!@actions.create_ticket}.
96
+ ```
97
+
98
+ The indentation after `|` formats model-visible prose. It does not place
99
+ `create_ticket` inside the deterministic `if`.
100
+
101
+ Fix:
102
+
103
+ - Use the `if` to select the prompt text.
104
+ - Use `available when` to select the action schema.
105
+
106
+ ```agentscript
107
+ reasoning:
108
+ instructions: ->
109
+ if @variables.lookup_failed == True:
110
+ | Explain that the lookup failed. If the customer asks to create a
111
+ ticket, use the ticket action.
112
+ actions:
113
+ create_ticket: @actions.create_ticket
114
+ available when @variables.lookup_failed == True
115
+ ```
116
+
117
+ ### Pitfall: prompt verbs are mistaken for commands
118
+
119
+ Inside a pipe block, these are ordinary words:
120
+
121
+ ```text
122
+ Show | Ask | Call | Set | Stop | Continue | Go to
123
+ ```
124
+
125
+ They may guide the model, but they do not:
126
+
127
+ - send a response deterministically;
128
+ - mutate a variable;
129
+ - execute an action;
130
+ - stop runtime resolution; or
131
+ - transition to another subagent.
132
+
133
+ Use runtime `set` and `transition to` for deterministic state-based behavior.
134
+ Expose an action when the model should judge whether to act.
135
+
136
+ ### Pitfall: stronger wording is used as enforcement
137
+
138
+ Repeating `MANDATORY`, `DO NOT SKIP`, or `IMMEDIATELY` does not create a runtime
139
+ guarantee. If ordering or eligibility matters, represent it with machine-known
140
+ state, action inputs, `available when`, deterministic action chaining, or one
141
+ purpose-built implementation that owns the sequence.
142
+
143
+ ## Repeated prompt markers
144
+
145
+ ### Pitfall: every sentence starts a new `|` fragment
146
+
147
+ Inside one contiguous prompt block, use one `|` marker and continue subsequent
148
+ lines beneath its content:
149
+
150
+ ```agentscript
151
+ reasoning:
152
+ instructions: ->
153
+ | Explain the available options.
154
+ Ask which option the user prefers.
155
+ Keep the answer concise.
156
+ ```
157
+
158
+ A same-scope run of `|`-prefixed sentences is valid syntax, but each marker
159
+ starts another prompt fragment. It does not create a stage, pause, priority, or
160
+ control boundary. Repeating the marker adds visual noise and can make the
161
+ resolved prompt harder to review.
162
+
163
+ Start another `|` after a runtime statement or branch when a new prompt
164
+ fragment is structurally required. Preserve existing structural indentation,
165
+ and compile after cleanup. Treat this as a Surface readability repair unless
166
+ prompt inspection or evaluation shows a behavioral consequence.
167
+
168
+ ## Step labels without runtime state
169
+
170
+ ### Pitfall: step numbers are treated as a workflow engine
171
+
172
+ ```agentscript
173
+ if @variables.ready == True:
174
+ | Step 4 — Submit the request.
175
+ ```
176
+
177
+ The model may see “Step 4” without Steps 1–3. AgentScript includes only the
178
+ prompt branches that resolve true during the current reasoning iteration.
179
+ Numbering does not prove that earlier work happened.
180
+
181
+ Fix:
182
+
183
+ - Remove step numbers when they are only explanatory labels.
184
+ - If earlier work is a real prerequisite, gate the later action on trusted
185
+ output from that work.
186
+
187
+ ```agentscript
188
+ submit: @actions.submit_request
189
+ available when @variables.validation_succeeded == True
190
+ ```
191
+
192
+ ### Pitfall: a prompt depends on missing context
193
+
194
+ Each resolved prompt fragment should make sense with the other fragments that
195
+ can accompany it in the same reachable state. Avoid instructions
196
+ such as “continue to the next step,” “use the result above,” or “as described
197
+ earlier” when the referenced fragment may not survive conditional resolution.
198
+
199
+ Name the actual objective and relevant state in the branch:
200
+
201
+ ```agentscript
202
+ if @variables.validation_succeeded == True:
203
+ | Validation succeeded. Submit the verified request.
204
+ ```
205
+
206
+ ### Pitfall: stored state is assumed to be model-visible
207
+
208
+ Storing an action output in `@variables` makes it available to runtime
209
+ conditions and later bindings. It does not automatically insert the value into
210
+ model-facing instructions. When the model must read a stored value, inject it
211
+ explicitly:
212
+
213
+ ```agentscript
214
+ if @variables.lookup_result != "":
215
+ | Use this lookup result: {!@variables.lookup_result}
216
+ ```
217
+
218
+ Prefer typed outputs and deterministic conditions when the value controls
219
+ authorization, eligibility, routing, or another consequential decision.
220
+
221
+ ## Focused continuation references
222
+
223
+ - [Action and Sequencing Pitfalls](control-flow-actions-sequencing.md) — action availability, same-turn sequences, state timing, stale results, missing producers, and overlapping conditions.
224
+ - [Lifecycle and Side-Effect Pitfalls](control-flow-lifecycle-side-effects.md) — per-turn resets, self-transitions, same-iteration assumptions, competing owners, and response text mistaken for proof.
225
+
226
+ ## Review checklist
227
+
228
+ For every reasoning branch:
229
+
230
+ - [ ] Does the resolved prompt make sense without hidden earlier “steps”?
231
+ - [ ] Is every stored value the model must read explicitly injected?
232
+ - [ ] Is every exact trusted comparison owned by runtime control when its
233
+ consequence must not vary?
234
+ - [ ] Are semantic intent and ambiguity left to model judgment?
235
+ - [ ] Does the branch have one next outcome?
236
+ - [ ] Are `Show`, `Ask`, `Call`, `Set`, and `STOP` being used only as prose?
237
+ - [ ] Are material actions gated independently of the prompt paragraph?
238
+ - [ ] Can any action remain available after success and repeat?
239
+ - [ ] Does prompt text request a tool call while later deterministic logic
240
+ assumes that call has already happened?
241
+ - [ ] Does the branch ask for and consume the same future answer?
242
+ - [ ] Are ordered tool calls enforced by the runtime when order matters?
243
+ - [ ] Is every completion flag backed by a complete, usable result?
244
+ - [ ] Is every condition value produced on every reachable path?
245
+ - [ ] Are typed outputs used for machine-controlled decisions?
246
+ - [ ] Are independent conditions intentionally cumulative or provably mutually
247
+ exclusive, and is first-match priority expressed with an
248
+ `if / else if / else` chain when it matters?
249
+ - [ ] Can lifecycle logic overwrite a legitimate later value?
250
+ - [ ] Does state encode durable evidence rather than duplicating history or
251
+ representing one phase with overlapping latches?
252
+ - [ ] Is the reasoning burden appropriate for the deployed target model?
253
+ - [ ] Does exactly one mechanism own each external side effect?
254
+ - [ ] Do tests inspect action availability and external results, not only final
255
+ model text?