Cert++
Close

Before and after reasoning in Agent Script

Key Takeaway

Actions in a subagent's reasoning instructions run in order, exactly as written, before the LLM receives the resolved prompt. The after_reasoning block runs on every request after the reasoning loop exits.

Agent Script lets a subagent run fixed, rule-based logic before and after the LLM reasons, in a before_reasoning block and an after_reasoning block. Both blocks run actions, set variables, and transition to other subagents exactly as written, so key business rules don't depend on the LLM reading natural language instructions correctly. The blocks are one way Agent Script combines reliable logic with flexible LLM reasoning.

Logic and prompts in a subagent

Agent Script is used in the new Agentforce Builder. In a subagent, Agent Script mixes two kinds of instructions. Programmatic logic is deterministic: it runs the same way every time. Programmatic logic handles workflow and business rules. Natural language prompts guide the agent's conversation more flexibly.

A simple way to sort them: logic is anything the agent must do before reasoning, and prompts are anything the agent should take into account during reasoning. In reasoning instructions, the | (pipe) command marks natural language text to add to the prompt.

Agentforce Specialist Study Guide

Checklist progress

0/204Learned

Explain the components and benefits of hybrid reasoning, including how Agent Script functions in Canvas and Script View

0/6

Benefits of hybrid reasoning

Learn this concept

Agent Script in Canvas View

Learn this concept

Agent Script in Script View

Learn this concept

Canvas versus Script View

Learn this concept

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Agentforce Specialist studiers.