Agentforce runs a subagent’s after_reasoning block after the reasoning loop exits, on every request. The after_reasoning block can contain logic, actions, transitions, or other directives, but can’t contain the | (pipe) command. Typical use cases are to set customer-entered information into a variable, transition to a different subagent, or run an action.
You can’t use before_reasoning or after_reasoning in a subagent that uses the EinsteinHyperClassifier model.
Note
For example, this after_reasoning block sets the appointment duration based on the urgency level.
After Reasoning Instructions
1after_reasoning:->2 if @variables.urgency_level == "urgent":3 set @variables.estimated_duration = 154 if @variables.urgency_level == "routine":5 set @variables.estimated_duration = 30
Agentscript also supports a before_reasoning block with the same capability and syntax as the after_reasoning block. The before_reasoning block is functionally equivalent to adding logic to the beginning of a subagent’s instructions.
Note
Transitions in after_reasoning
If a subagent transitions to a new subagent partway through execution, the original subagent’s after_reasoning block isn’t run. When calling transitions in after reasoning, use transition to rather than @utils.transition to. For example:
Transitions in After Reasoning
1after_reasoning:2 if @variables.case_type != "":3 transition to @subagent.case_creation