@salesforce/afv-skills 1.36.0 → 1.38.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 (252) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-generate/README.md +20 -3
  3. package/skills/agentforce-generate/SKILL.md +253 -440
  4. package/skills/agentforce-generate/assets/agent-spec-template.md +6 -2
  5. package/skills/agentforce-generate/assets/agents/order-service.agent +16 -12
  6. package/skills/agentforce-generate/assets/agents/production-faq.agent +4 -4
  7. package/skills/agentforce-generate/assets/agents/router-first.agent +5 -5
  8. package/skills/agentforce-generate/assets/agents/template-single-subagent.agent +4 -4
  9. package/skills/agentforce-generate/assets/agents/verification-gate.agent +8 -6
  10. package/skills/agentforce-generate/assets/agents/voice-knowledge-grounded.agent +9 -9
  11. package/skills/agentforce-generate/assets/agents/voice-service-agent.agent +7 -7
  12. package/skills/agentforce-generate/assets/patterns/README.md +3 -3
  13. package/skills/agentforce-generate/assets/patterns/action-callbacks.agent +5 -5
  14. package/skills/agentforce-generate/assets/patterns/advanced-input-bindings.agent +6 -8
  15. package/skills/agentforce-generate/assets/patterns/bidirectional-routing.agent +11 -13
  16. package/skills/agentforce-generate/assets/patterns/critical-input-collection.agent +11 -16
  17. package/skills/agentforce-generate/assets/patterns/lifecycle-events.agent +2 -3
  18. package/skills/agentforce-generate/assets/patterns/llm-controlled-actions.agent +6 -7
  19. package/skills/agentforce-generate/assets/patterns/open-gate-routing.agent +3 -3
  20. package/skills/agentforce-generate/assets/patterns/prompt-template-action.agent +14 -19
  21. package/skills/agentforce-generate/assets/patterns/system-instruction-overrides.agent +11 -20
  22. package/skills/agentforce-generate/references/actions-reference.md +2 -2
  23. package/skills/agentforce-generate/references/agent-audit-and-repair.md +135 -0
  24. package/skills/agentforce-generate/references/agent-audit-candidate-verification.md +160 -0
  25. package/skills/agentforce-generate/references/agent-audit-diagnostic-catalog.md +156 -0
  26. package/skills/agentforce-generate/references/agent-audit-diagnostics-actions-state.md +176 -0
  27. package/skills/agentforce-generate/references/agent-audit-diagnostics-architecture-evaluation.md +68 -0
  28. package/skills/agentforce-generate/references/agent-audit-diagnostics-instructions-routing.md +283 -0
  29. package/skills/agentforce-generate/references/agent-audit-evaluation-loop.md +191 -0
  30. package/skills/agentforce-generate/references/agent-audit-repair-report.md +143 -0
  31. package/skills/agentforce-generate/references/agent-audit-scope-path-review.md +180 -0
  32. package/skills/agentforce-generate/references/agent-design-and-spec-creation.md +105 -59
  33. package/skills/agentforce-generate/references/agent-script-core-language.md +144 -61
  34. package/skills/agentforce-generate/references/agent-subagent-map-diagrams.md +33 -23
  35. package/skills/agentforce-generate/references/agent-validation-and-debugging.md +37 -11
  36. package/skills/agentforce-generate/references/agentscript-toolchain.md +112 -0
  37. package/skills/agentforce-generate/references/architecture-patterns.md +81 -18
  38. package/skills/agentforce-generate/references/common-control-flow-pitfalls.md +255 -0
  39. package/skills/agentforce-generate/references/control-flow-actions-sequencing.md +198 -0
  40. package/skills/agentforce-generate/references/control-flow-lifecycle-side-effects.md +87 -0
  41. package/skills/agentforce-generate/references/examples.md +22 -22
  42. package/skills/agentforce-generate/references/instruction-resolution.md +123 -83
  43. package/skills/agentforce-generate/references/known-issues.md +1 -2
  44. package/skills/agentforce-generate/references/optimization-pattern-1-data-flow.md +4 -0
  45. package/skills/agentforce-generate/references/optimization-pattern-2-deterministic-logic.md +33 -0
  46. package/skills/agentforce-generate/references/optimization-pattern-3-reference-syntax.md +32 -3
  47. package/skills/agentforce-generate/references/optimization-pattern-4-escalation.md +2 -2
  48. package/skills/agentforce-generate/references/patterns-by-requirement.md +3 -1
  49. package/skills/agentforce-generate/references/posture-and-determinism.md +103 -22
  50. package/skills/agentforce-generate/references/reference-map.md +19 -3
  51. package/skills/agentforce-generate/references/scoring-rubric.md +1 -1
  52. package/skills/agentforce-generate/references/voice-latency-heuristics.md +4 -0
  53. package/skills/agentforce-generate/references/voice-modality-reference.md +4 -4
  54. package/skills/agentforce-generate/references/zen-of-agentscript.md +139 -23
  55. package/skills/agentforce-generate/scripts/agentscript-sdk-loader.mjs +133 -0
  56. package/skills/agentforce-generate/scripts/index-agent.mjs +141 -0
  57. package/skills/agentforce-generate/scripts/setup-agentscript-sdk.mjs +337 -0
  58. package/skills/automation-sandbox-post-copy-config-generate/SKILL.md +1 -1
  59. package/skills/automation-sandbox-post-copy-configure/SKILL.md +433 -0
  60. package/skills/automation-sandbox-post-copy-configure/assets/api_request_templates.json +89 -0
  61. package/skills/automation-sandbox-post-copy-configure/examples/sample_config_input.json +40 -0
  62. package/skills/automation-sandbox-post-copy-configure/examples/sample_execution_summary.md +79 -0
  63. package/skills/automation-sandbox-post-copy-configure/references/api_endpoints.md +273 -0
  64. package/skills/automation-sandbox-post-copy-configure/references/authentication.md +94 -0
  65. package/skills/automation-sandbox-post-copy-configure/references/execution_phasing.md +93 -0
  66. package/skills/automation-sandbox-post-copy-configure/references/rules_gotchas.md +35 -0
  67. package/skills/automation-sandbox-post-copy-configure/scripts/classify-patch-result.mjs +88 -0
  68. package/skills/automation-sandbox-post-copy-configure/scripts/map-metadata-key.mjs +98 -0
  69. package/skills/automation-sandbox-post-copy-configure/scripts/plan-phases.mjs +98 -0
  70. package/skills/automation-sandbox-post-copy-configure/scripts/resolve-target-org.mjs +56 -0
  71. package/skills/design-systems-slds-validate/SKILL.md +14 -13
  72. package/skills/dx-code-analyzer-custom-rule-create/examples/xpath-examples.md +1 -1
  73. package/skills/dx-code-analyzer-custom-rule-create/references/xpath-patterns-security.md +1 -1
  74. package/skills/dx-org-devhub-configure/SKILL.md +268 -0
  75. package/skills/dx-org-devhub-configure/examples/status-output.md +39 -0
  76. package/skills/dx-org-devhub-configure/scripts/devhub.sh +650 -0
  77. package/skills/dx-org-devhub-configure/scripts/test-devhub.sh +116 -0
  78. package/skills/dx-org-manage/SKILL.md +135 -42
  79. package/skills/dx-org-manage/assets/derive-alias.sh +95 -0
  80. package/skills/dx-org-manage/assets/scratch-def.seed.json +6 -0
  81. package/skills/dx-org-manage/examples/README.md +1 -1
  82. package/skills/dx-org-manage/examples/scratch-orgs/delete_output.json +8 -0
  83. package/skills/dx-org-manage/examples/scratch-orgs/display_output.json +23 -0
  84. package/skills/dx-org-manage/examples/scratch-orgs/list_output.json +58 -0
  85. package/skills/dx-org-manage/examples/scratch-orgs/resume_output.json +38 -0
  86. package/skills/dx-org-manage/examples/scratch-orgs/success_definition_file.json +1 -1
  87. package/skills/dx-org-manage/examples/scratch-orgs/success_edition.json +1 -1
  88. package/skills/dx-org-manage/examples/scratch-orgs/success_shape.json +41 -0
  89. package/skills/dx-org-manage/examples/scratch-orgs/success_snapshot.json +1 -1
  90. package/skills/dx-org-manage/examples/snapshots/error_output.json +3 -3
  91. package/skills/dx-org-manage/references/creating-scratch-org.md +2 -2
  92. package/skills/dx-org-manage/references/creating-snapshot.md +1 -2
  93. package/skills/dx-org-manage/references/definition_file_options.md +24 -0
  94. package/skills/dx-org-manage/references/edition_types.md +10 -8
  95. package/skills/dx-org-manage/references/opening-org.md +11 -12
  96. package/skills/dx-org-manage/references/scratch-org-create.md +303 -0
  97. package/skills/dx-org-manage/references/scratch-org-operations.md +135 -0
  98. package/skills/experience-aura-lwc-migrate/SKILL.md +120 -0
  99. package/skills/experience-aura-lwc-migrate/references/aura-api-expert.md +170 -0
  100. package/skills/experience-aura-lwc-migrate/references/aura-data-expert.md +172 -0
  101. package/skills/experience-aura-lwc-migrate/references/aura-migration-guidelines.md +299 -0
  102. package/skills/experience-aura-lwc-migrate/references/aura-prd-framework.md +79 -0
  103. package/skills/experience-aura-lwc-migrate/references/aura-redundant-code-expert.md +24 -0
  104. package/skills/experience-aura-lwc-migrate/references/aura-reference-expert.md +140 -0
  105. package/skills/experience-aura-lwc-migrate/references/aura-resolver-expert.md +115 -0
  106. package/skills/experience-aura-lwc-migrate/references/aura-slots-expert.md +67 -0
  107. package/skills/experience-aura-lwc-migrate/references/aura-style-expert.md +62 -0
  108. package/skills/experience-aura-lwc-migrate/references/aura-to-lwc-completeness-checklist.md +188 -0
  109. package/skills/experience-aura-lwc-migrate/references/aura-values-expert.md +67 -0
  110. package/skills/experience-content-media-search/SKILL.md +17 -12
  111. package/skills/experience-content-media-stock-image-search/SKILL.md +192 -0
  112. package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +102 -0
  113. package/skills/experience-lds-best-practices-apply/SKILL.md +245 -0
  114. package/skills/experience-lds-best-practices-apply/references/adapter-apis.md +1640 -0
  115. package/skills/experience-lds-best-practices-apply/references/lds-data-consistency.md +126 -0
  116. package/skills/experience-lds-best-practices-apply/references/lds-expert.md +429 -0
  117. package/skills/experience-lds-best-practices-apply/references/lds-referential-integrity.md +322 -0
  118. package/skills/experience-lds-best-practices-apply/references/wire-adapter-types.md +1511 -0
  119. package/skills/experience-lds-graphql-generate/SKILL.md +222 -0
  120. package/skills/experience-lds-graphql-generate/references/generation-guide.md +236 -0
  121. package/skills/experience-lds-graphql-generate/references/generation-mutation.md +277 -0
  122. package/skills/experience-lds-graphql-generate/references/generation-query.md +237 -0
  123. package/skills/experience-lds-graphql-generate/scripts/fetch-lds-graphql-schema.sh +230 -0
  124. package/skills/experience-lds-graphql-generate/scripts/test-lds-graphql-query.sh +128 -0
  125. package/skills/experience-lwc-accessibility-validate/SKILL.md +112 -0
  126. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-1-1-non-text-content.md +88 -0
  127. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-i-lists.md +52 -0
  128. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-ii-tables.md +106 -0
  129. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iii-form-labels.md +78 -0
  130. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iv-regions.md +26 -0
  131. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-v-groups.md +66 -0
  132. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-5-identify-input.md +70 -0
  133. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-4-3-contrast.md +115 -0
  134. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-1-1-keyboard.md +47 -0
  135. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-4-link-purpose.md +39 -0
  136. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-6-headings-labels.md +50 -0
  137. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-1-pointer-gestures.md +54 -0
  138. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-2-pointer-cancellation.md +49 -0
  139. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-3-label-in-name.md +77 -0
  140. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-7-dragging-movement.md +45 -0
  141. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-1-on-focus.md +55 -0
  142. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-2-on-input.md +51 -0
  143. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-1-error-identification.md +84 -0
  144. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-2-labels-instructions.md +50 -0
  145. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-3-error-suggestion.md +64 -0
  146. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-i-name.md +105 -0
  147. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-ii-role.md +99 -0
  148. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-iii-value.md +97 -0
  149. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-1-1-non-text-content.md +83 -0
  150. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-1-use-of-color.md +62 -0
  151. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-10-resize-reflow.md +18 -0
  152. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-11-non-text-contrast.md +43 -0
  153. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-3-contrast.md +25 -0
  154. package/skills/experience-lwc-accessibility-validate/scripts/contrast-ratio.py +153 -0
  155. package/skills/experience-lwc-design-generate/SKILL.md +261 -0
  156. package/skills/experience-lwc-design-generate/references/figma-to-prd-blueprint.md +66 -0
  157. package/skills/experience-lwc-design-generate/references/prd-analysis-template.md +17 -0
  158. package/skills/experience-lwc-design-generate/scripts/check-component-name.sh +75 -0
  159. package/skills/experience-lwc-design-generate/scripts/detect-project-tools.sh +97 -0
  160. package/skills/experience-lwc-runtime-observe/SKILL.md +244 -0
  161. package/skills/experience-lwc-runtime-observe/examples/component-preview-and-dom.md +41 -0
  162. package/skills/experience-lwc-runtime-observe/scripts/extract-dom.sh +79 -0
  163. package/skills/experience-lwc-runtime-observe/scripts/open-frontdoor.sh +46 -0
  164. package/skills/experience-lwc-runtime-observe/scripts/verify-toolchain.sh +48 -0
  165. package/skills/experience-lwc-security-validate/SKILL.md +151 -0
  166. package/skills/experience-lwc-security-validate/examples/review-report.md +6 -0
  167. package/skills/experience-lwc-security-validate/examples/score-report.sarif.json +32 -0
  168. package/skills/experience-lwc-security-validate/references/lws-security-expert.md +986 -0
  169. package/skills/experience-lwc-security-validate/references/security-analysis.md +611 -0
  170. package/skills/experience-lwc-security-validate/scripts/check-lwc-import.sh +166 -0
  171. package/skills/experience-lwc-security-validate/scripts/validate-sarif.sh +131 -0
  172. package/skills/experience-lwr-site-generate/SKILL.md +1 -2
  173. package/skills/experience-ui-bundle-2gp-deploy/SKILL.md +454 -0
  174. package/skills/experience-ui-bundle-2gp-deploy/assets/CustomApplication.app-meta.xml +12 -0
  175. package/skills/experience-ui-bundle-2gp-deploy/assets/PermissionSet.permissionset-meta.xml +9 -0
  176. package/skills/experience-ui-bundle-2gp-deploy/scripts/find-bundle-package-dir.sh +53 -0
  177. package/skills/experience-ui-bundle-agentforce-client-generate/SKILL.md +104 -26
  178. package/skills/experience-ui-bundle-agentforce-client-generate/references/constraints.md +35 -24
  179. package/skills/experience-ui-bundle-agentforce-client-generate/references/examples.md +92 -1
  180. package/skills/experience-ui-bundle-agentforce-client-generate/references/style-tokens.md +2 -0
  181. package/skills/experience-ui-bundle-agentforce-client-generate/references/troubleshooting.md +14 -1
  182. package/skills/experience-ui-bundle-agentforce-client-generate/scripts/detect-framework.sh +67 -0
  183. package/skills/experience-ui-bundle-deploy/SKILL.md +83 -14
  184. package/skills/experience-ui-bundle-deploy/assets/Communities.settings-meta.xml +19 -0
  185. package/skills/experience-ui-bundle-deploy/assets/org-setup.config.template.json +5 -0
  186. package/skills/experience-ui-bundle-deploy/assets/social-login-auth-providers.apex +158 -0
  187. package/skills/experience-ui-bundle-deploy/references/config-scaffold.md +13 -1
  188. package/skills/experience-ui-bundle-deploy/references/social-login.md +179 -0
  189. package/skills/experience-ui-bundle-frontend-generate/SKILL.md +14 -0
  190. package/skills/experience-ui-bundle-mfa-configure/SKILL.md +6 -5
  191. package/skills/experience-ui-bundle-mfa-configure/references/social-login.md +15 -7
  192. package/skills/experience-ui-bundle-salesforce-data-access/SKILL.md +41 -5
  193. package/skills/experience-ui-bundle-salesforce-data-access/references/caching.md +10 -22
  194. package/skills/experience-ui-bundle-salesforce-data-access/references/graphql-hand-authoring.md +4 -19
  195. package/skills/experience-ui-bundle-salesforce-data-access/references/migration.md +5 -0
  196. package/skills/experience-ui-bundle-salesforce-data-access/references/sdk-api.md +33 -150
  197. package/skills/mobile-platform-native-capabilities-integrate/references/nfc.md +35 -0
  198. package/skills/platform-apex-generate/SKILL.md +8 -7
  199. package/skills/platform-apex-test-generate/SKILL.md +3 -1
  200. package/skills/platform-apex-test-run/SKILL.md +9 -8
  201. package/skills/platform-custom-field-generate/SKILL.md +7 -1
  202. package/skills/platform-lightning-app-coordinate/SKILL.md +3 -3
  203. package/skills/platform-lightning-type-widget-coordinate/SKILL.md +1 -1
  204. package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +1 -1
  205. package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +1 -1
  206. package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +3 -3
  207. package/skills/platform-mcp-tool-widget-coordinate/SKILL.md +43 -67
  208. package/skills/platform-mcp-tool-widget-coordinate/examples/action-name-source-prompt.md +1 -2
  209. package/skills/platform-mcp-tool-widget-coordinate/examples/apex-invocable-source-prompt.md +2 -3
  210. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-list-source-prompt.md +163 -0
  211. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-single-source-prompt.md +198 -0
  212. package/skills/platform-mcp-tool-widget-coordinate/examples/pasted-tool-output-prompt.md +0 -1
  213. package/skills/platform-mcp-tool-widget-coordinate/references/build-plan-format.md +17 -11
  214. package/skills/platform-mcp-tool-widget-coordinate/references/mcp-tool-output-discovery.md +48 -15
  215. package/skills/platform-mcp-tool-widget-coordinate/references/two-clt-modeling.md +73 -10
  216. package/skills/platform-mcp-tool-widget-coordinate/references/validation-gates.md +48 -8
  217. package/skills/platform-policy-rule-generate/SKILL.md +22 -12
  218. package/skills/platform-policy-rule-generate/references/deploy-errors.md +1 -1
  219. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +8 -29
  220. package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
  221. package/skills/platform-report-generate/SKILL.md +1 -1
  222. package/skills/platform-sharing-owd-configure/SKILL.md +20 -8
  223. package/skills/platform-sharing-owd-configure/references/access_levels.md +14 -1
  224. package/skills/platform-sharing-rules-generate/SKILL.md +67 -35
  225. package/skills/platform-sharing-rules-generate/examples/create-cases.md +16 -17
  226. package/skills/platform-sharing-rules-generate/examples/delete-cases.md +34 -79
  227. package/skills/platform-sharing-rules-generate/examples/edit-cases.md +13 -26
  228. package/skills/platform-sharing-rules-generate/scripts/count-remaining-rules.sh +33 -0
  229. package/skills/platform-value-set-generate/SKILL.md +6 -2
  230. package/skills/platform-widget-generate/SKILL.md +3 -5
  231. package/skills/platform-widget-generate/examples/conditional.json +18 -13
  232. package/skills/platform-widget-generate/examples/list-with-foreach.json +2 -2
  233. package/skills/platform-widget-generate/examples/single-object.json +2 -2
  234. package/skills/platform-widget-generate/references/schema-from-lightning-type.md +27 -6
  235. package/skills/platform-widget-generate/references/widget-bundle-layout.md +4 -3
  236. package/skills/service-itsm-agentic-setup-cmdb-access-assign/SKILL.md +287 -0
  237. package/skills/service-itsm-agentic-setup-cmdb-access-assign/references/mcp-invocation.md +260 -0
  238. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/SKILL.md +252 -0
  239. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/references/mcp-invocation.md +204 -0
  240. package/skills/service-itsm-agentic-setup-cmdb-configure/SKILL.md +259 -0
  241. package/skills/service-itsm-agentic-setup-cmdb-configure/references/mcp-invocation.md +188 -0
  242. package/skills/service-itsm-agentic-setup-cmdb-coordinate/SKILL.md +197 -0
  243. package/skills/service-itsm-agentic-setup-cmdb-coordinate/examples/output-templates.md +77 -0
  244. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/SKILL.md +316 -0
  245. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/references/mcp-invocation.md +221 -0
  246. package/skills/service-itsm-incident-priority-configure/SKILL.md +168 -0
  247. package/skills/service-itsm-incident-priority-configure/examples/matrix-operations.md +200 -0
  248. package/skills/service-itsm-incident-priority-configure/examples/render-matrix.md +54 -0
  249. package/skills/service-itsm-incident-priority-configure/examples/seed-full-matrix.md +52 -0
  250. package/skills/service-itsm-incident-priority-configure/references/sf-cli-invocation.md +264 -0
  251. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-source-prompt.md +0 -191
  252. package/skills/platform-policy-rule-generate/references/fixtures-index.md +0 -29
@@ -0,0 +1,198 @@
1
+ # AgentScript Action and Sequencing Pitfalls
2
+
3
+ Use this reference when action availability, ordered tool use, state timing, or
4
+ result handling may explain a behavior defect.
5
+
6
+ ## Contents
7
+
8
+ - [Actions that escape their intended branch](#actions-that-escape-their-intended-branch)
9
+ - [Impossible same-turn sequences](#impossible-same-turn-sequences)
10
+ - [State written too early](#state-written-too-early)
11
+ - [Stale, raw, or missing action results](#stale-raw-or-missing-action-results)
12
+
13
+ ## Actions that escape their intended branch
14
+
15
+ ### Pitfall: mentioning an action under one branch is assumed to scope it
16
+
17
+ Actions are defined for the reasoning scope, not nested under the visual prompt
18
+ paragraph that mentions them. Unless gated, an action remains available while
19
+ other branches are active.
20
+
21
+ ```agentscript
22
+ reasoning:
23
+ instructions: ->
24
+ if @variables.validation_succeeded == True:
25
+ | Use the {!@actions.submit} action.
26
+ actions:
27
+ submit: @actions.submit_request
28
+ ```
29
+
30
+ The `submit` action is still available when `validation_succeeded` is false.
31
+
32
+ Fix:
33
+
34
+ ```agentscript
35
+ submit: @actions.submit_request
36
+ available when @variables.validation_succeeded == True
37
+ ```
38
+
39
+ ### Pitfall: an action remains available after it succeeds
40
+
41
+ If repeating an action would duplicate a write, charge, message, or external
42
+ commitment, gate it on a result or idempotency value.
43
+
44
+ ```agentscript
45
+ submit: @actions.submit_request
46
+ available when @variables.validation_succeeded == True
47
+ available when @variables.submission_id == ""
48
+ set @variables.submission_id = @outputs.submission_id
49
+ ```
50
+
51
+ Do not depend only on prose such as “do not call this again.”
52
+
53
+ ## Impossible same-turn sequences
54
+
55
+ ### Pitfall: model-selected actions are written as imperative steps
56
+
57
+ `@utils.setVariables` is a normal model-selected state-update tool. If the
58
+ model calls it successfully, the runtime stores the values. The action does
59
+ not itself define a turn boundary or guarantee another reasoning iteration.
60
+ Prompt text does not execute the tool:
61
+
62
+ ```text
63
+ Call the state-setting action.
64
+ Then call the submission action.
65
+ ```
66
+
67
+ The model may call either action, call both in one batch, or return text without
68
+ calling either. The second action does not automatically follow merely because
69
+ the prompt lists it second.
70
+
71
+ Fix with the smallest suitable option:
72
+
73
+ - bind current-turn values directly to the real action with `...`;
74
+ - set trusted values deterministically before reasoning;
75
+ - pass fixed values through a purpose-built transition or action;
76
+ - return the required values from the first real action; or
77
+ - combine inseparable writes into one implementation that owns the complete
78
+ update.
79
+
80
+ ### Pitfall: ask now and capture the future answer now
81
+
82
+ ```text
83
+ Ask for the issue description.
84
+ Call the capture action with the issue description.
85
+ ```
86
+
87
+ The answer does not exist when the question is asked. Give that branch one
88
+ outcome: ask. On the later turn, capture or use the answer.
89
+
90
+ ### Pitfall: one branch requires several model-selected tools in order
91
+
92
+ The model may choose one tool, choose them in a different order, or produce a
93
+ response before the expected sequence is complete. If the order protects
94
+ authorization, correctness, or an external side effect, do not encode it only
95
+ as a tool list in prompt text.
96
+
97
+ Use deterministic post-action logic, gated actions with explicit intermediate
98
+ results, or one purpose-built action that owns the sequence.
99
+
100
+ ## State written too early
101
+
102
+ ### Pitfall: “complete” means “started”
103
+
104
+ Do not set:
105
+
106
+ ```agentscript
107
+ set @variables.operation_completed = True
108
+ ```
109
+
110
+ before the consequential action has returned a successful result.
111
+
112
+ Prefer state names that match the evidence:
113
+
114
+ ```text
115
+ validation_completed
116
+ operation_requested
117
+ operation_succeeded
118
+ ```
119
+
120
+ If the runtime cannot observe the final external side effect, use a weaker name
121
+ such as `operation_initiated` instead of claiming completion.
122
+
123
+ ### Pitfall: workflow state advances on failure
124
+
125
+ Do not advance a stage, close a gate, or hide retry behavior merely because an
126
+ action was attempted. Branch on the trusted action result and preserve a safe
127
+ retry or failure path.
128
+
129
+ ### Pitfall: state exists only to imitate dialogue stages
130
+
131
+ Avoid `current_step`, `question_asked`, or `has_greeted` when the available
132
+ conversation history already supplies the required continuity. Add state for a
133
+ named runtime consumer or when a value must outlive the usable history window;
134
+ give it the reset, correction, and failure behavior relevant to its use cases.
135
+
136
+ ### Pitfall: one phase is represented several ways
137
+
138
+ Pairs such as `q1_asking`/`q1_answered`, plus `current_step` and completion
139
+ flags, can describe contradictory workflow positions. When deterministic
140
+ sequencing is truly required, prefer one explicit phase value and keep separate
141
+ state only for durable facts or trusted action inputs.
142
+
143
+ Before adding state, list its producer, consumer, reset, failure behavior, and
144
+ valid combinations with neighboring variables.
145
+
146
+ ## Stale, raw, or missing action results
147
+
148
+ ### Pitfall: “checked” is set before the result is usable
149
+
150
+ Do not mark validation complete while its result still needs model-driven
151
+ parsing:
152
+
153
+ ```agentscript
154
+ set @variables.validation_output = @outputs.raw_json
155
+ set @variables.validation_checked = True
156
+ ```
157
+
158
+ Later conditions can read old or default structured values and choose the wrong
159
+ branch. The raw output has resolved, but its derived fields have not.
160
+
161
+ Fix:
162
+
163
+ - Prefer typed action outputs.
164
+ - Otherwise normalize the raw result deterministically.
165
+ - Mark the check complete only after all branch inputs are stored.
166
+ - If normalization must be model-driven, use an explicit reasoning boundary so
167
+ producing the raw result and consuming its parsed fields cannot occur in one
168
+ half-populated state.
169
+
170
+ ### Pitfall: raw JSON controls important branches
171
+
172
+ Do not ask the model to extract authorization, eligibility, confirmation, or
173
+ success flags from display-oriented text when those flags determine tool
174
+ availability or a consequential transition. Return typed, machine-checkable
175
+ outputs.
176
+
177
+ ### Pitfall: the script branches on a value no producer returns
178
+
179
+ For every condition and `available when`, trace the value backward:
180
+
181
+ ```text
182
+ consumer -> stored variable -> action output or deterministic assignment
183
+ ```
184
+
185
+ If no reachable producer exists, the branch is dead or depends on an accidental
186
+ default.
187
+
188
+ ### Pitfall: independent conditions overlap
189
+
190
+ Sequential top-level condition blocks are evaluated independently. This is a
191
+ pitfall only when predicates can overlap, leave an unintended gap, or require
192
+ first-match priority. Complementary predicates such as `X == value` and
193
+ `X != value` are mutually exclusive and do not overlap. When authoring new
194
+ first-match alternatives, prefer `if / else if / else`; use independent blocks
195
+ when multiple branches may run or mutual exclusion is explicit. Do not rewrite
196
+ equivalent control flow in a bounded repair solely for style. Spell the clause
197
+ `else if`; Python-style `elif` is invalid. Verify the effective prompt for each
198
+ reachable state.
@@ -0,0 +1,87 @@
1
+ # AgentScript Lifecycle and Side-Effect Pitfalls
2
+
3
+ Use this reference when per-turn lifecycle code, transitions, repeated
4
+ reasoning, or competing side-effect owners may explain a behavior defect.
5
+
6
+ ## Lifecycle code that overwrites later work
7
+
8
+ ### Pitfall: `before_reasoning` resets a value every turn
9
+
10
+ `before_reasoning` runs once when that subagent execution begins. A transition,
11
+ including a self-transition, can start another subagent execution in the same
12
+ user turn. An unconditional assignment there can erase a value captured or
13
+ inferred earlier.
14
+
15
+ Review every lifecycle assignment by asking:
16
+
17
+ - Is this an initialization or an unconditional reset?
18
+ - Can a later branch legitimately change it?
19
+ - When and where is it cleared?
20
+
21
+ Initialize only when the value is unset, or let the destination subagent own its
22
+ own intent.
23
+
24
+ ### Pitfall: a transition reprocesses the same customer message
25
+
26
+ A transition can start the target subagent during the same customer turn. The
27
+ target may receive the message that completed the prior gate, not a fresh
28
+ request. Make the target coherent for that arrival path or transition only when
29
+ the target has enough explicit state to act safely.
30
+
31
+ ### Pitfall: same-iteration instructions assume a deterministic pause
32
+
33
+ Deterministic lifecycle statements continue resolving after a `run` stores its
34
+ output. A nearby `|` block adds text to the model's next prompt; it does not
35
+ pause runtime execution so the model can act before the following `set` or
36
+ condition.
37
+
38
+ Remember the execution order:
39
+
40
+ ```text
41
+ 1. Resolve deterministic run, set, and if statements and assemble all | text.
42
+ 2. Send the completed prompt to the model, which may call a tool or respond.
43
+ ```
44
+
45
+ For example, this is unsafe when the parsed fields still hold defaults:
46
+
47
+ ```agentscript
48
+ run @actions.validate
49
+ set @variables.raw_result = @outputs.output
50
+ | Parse the raw result and store the derived flags.
51
+ set @variables.validation_checked = True
52
+ ```
53
+
54
+ Use typed outputs, deterministic normalization, a purpose-built action that
55
+ owns the operation, or an explicit reasoning boundary. A guarded
56
+ self-transition can serve as a boundary
57
+ when the runtime offers no smaller supported stage: the first pass stores the
58
+ raw result and exits; re-entry builds a fresh prompt from that result; the next
59
+ model action stores all derived fields and the completion flag together.
60
+ Document that pattern as a phase boundary, not as a generic loop.
61
+
62
+ ## Competing owners for one side effect
63
+
64
+ ### Pitfall: two mechanisms both appear to perform the same operation
65
+
66
+ Examples:
67
+
68
+ - one action is named “validate and submit,” followed by another submit action;
69
+ - an external action performs transfer, followed by a utility escalation;
70
+ - a transition and a delegated subagent both own completion.
71
+
72
+ Choose one owner for each external side effect. Document whether other actions
73
+ prepare, validate, invoke, or verify it.
74
+
75
+ ### Pitfall: model text is treated as proof
76
+
77
+ A promise, confirmation, or tool name in the model response is not evidence
78
+ that an external action occurred. An instruction such as `Call
79
+ escalate_to_live_engineer` only asks the model to select that tool. The model
80
+ may instead answer “I'm transferring you,” and a text-only response is a valid
81
+ reasoning result. Verify separately:
82
+
83
+ ```text
84
+ configured -> available -> invoked -> executed -> effected
85
+ ```
86
+
87
+ Advance consequential state only at the strongest layer the runtime can prove.
@@ -53,7 +53,7 @@ subagent greeting:
53
53
  reasoning:
54
54
  instructions: ->
55
55
  | Welcome the user warmly.
56
- | Ask how you can help them today.
56
+ Ask how you can help them today.
57
57
  ```
58
58
 
59
59
  Companion `bundle-meta.xml` (MUST be this exact content -- no extra fields):
@@ -137,7 +137,7 @@ subagent knowledge_search:
137
137
  | Found article {!@variables.article_id}. Here are the details.
138
138
 
139
139
  | Search the knowledge base using the search_articles action.
140
- | Present results clearly. Do not fabricate article content.
140
+ Present results clearly. Do not fabricate article content.
141
141
 
142
142
  actions:
143
143
  search: @actions.search_articles
@@ -164,10 +164,10 @@ subagent account_support:
164
164
  description: "Reset status"
165
165
  is_displayable: True
166
166
 
167
- reasoning:
168
- instructions: ->
169
- | I can help with password resets and account access.
170
- | Ask for the employee's email, then use the reset_password action.
167
+ reasoning:
168
+ instructions: ->
169
+ | Explain that you can help with password resets and account access.
170
+ Ask for the employee's email, then use the reset_password action.
171
171
 
172
172
  actions:
173
173
  reset: @actions.reset_password
@@ -270,14 +270,14 @@ subagent order_support:
270
270
  description: "Tracking URL"
271
271
  is_displayable: True
272
272
 
273
- reasoning:
274
- instructions: ->
275
- if @variables.order_status != "":
276
- | Order {!@variables.order_id} status: {!@variables.order_status}
277
-
278
- | What is your order number? I will look it up for you.
279
- | Use the get_order action to retrieve order details.
280
- | Do not guess order status -- always use the action result.
273
+ reasoning:
274
+ instructions: ->
275
+ if @variables.order_status != "":
276
+ | Report order {!@variables.order_id} with exact status
277
+ {!@variables.order_status}. Do not guess or paraphrase it.
278
+ else:
279
+ | Ask for the order number, then use the get_order action to
280
+ retrieve the details.
281
281
 
282
282
  actions:
283
283
  lookup: @actions.get_order
@@ -307,11 +307,11 @@ subagent return_support:
307
307
  description: "Return authorization ID"
308
308
  is_displayable: True
309
309
 
310
- reasoning:
311
- instructions: ->
312
- | I can help with your return request.
313
- | Please provide your order number and the reason for the return.
314
- | Use the initiate_return action to start the process -- do not fabricate return IDs.
310
+ reasoning:
311
+ instructions: ->
312
+ | Explain that you can help with the return. Ask for the order
313
+ number and reason.
314
+ Use the initiate_return action to start the process -- do not fabricate return IDs.
315
315
 
316
316
  actions:
317
317
  start_return: @actions.initiate_return
@@ -345,8 +345,8 @@ subagent confirmation:
345
345
  description: "Confirm the completed action"
346
346
  reasoning:
347
347
  instructions: ->
348
- | Your request has been processed. Reference: {!@variables.case_id}
349
- | Is there anything else I can help with?
348
+ | Confirm that the request was processed, provide exact reference
349
+ {!@variables.case_id}, and ask whether the user needs anything else.
350
350
  actions:
351
351
  new_request: @utils.transition to @subagent.agent_router
352
352
  description: "Start a new request"
@@ -393,7 +393,7 @@ subagent main:
393
393
  instructions: ->
394
394
  if @variables.customer_verified == True:
395
395
  | You are speaking with a verified customer.
396
- | Help them with their request.
396
+ Help them with their request.
397
397
  else:
398
398
  | Please verify the customer's identity first.
399
399
  actions: