Template expressions in agent instructions
Key Takeaway
Agentforce replaces {!@variables.name} in prompt text with the variable's actual value before the LLM reasons. Instructions resolve from top to bottom, so run the action that sets a variable in the logic section above the prompt line that references it.
Reasoning instructions tell an Agentforce agent how to handle a conversation inside a subagent. They mix deterministic logic with natural language prompts. In the prompt text, references such as {!@variables.name}, {!@actions.name} and {!@subagents.name} insert real data or point the LLM to a specific resource. Agentforce resolves these references before any LLM reasoning starts, so the LLM receives concrete, predictable instructions.
Logic instructions and prompt instructions
Reasoning instructions have two parts: logic instructions and prompt instructions.
| Logic instructions | Prompt instructions | |
|---|---|---|
| What it is | Deterministic or conditional expressions | Natural language for the LLM |
| What it does | Checks requirements, runs actions and sets variables | Passed to the LLM if its conditions are met |
| When it applies | Before reasoning: what the agent must do | During reasoning: what the agent should take into account |
| Strength | Reliably handles workflow and business rules | More flexibly guides conversation |
| How it's written | Expressions such as if, run and set | Text after the | (pipe) command |
| Variable reference | Bare, as in @variables.postal_code | Wrapped, as in {!@variables.postal_code} |
The pipe command allows indented multiline text. Prompt instructions can come before or after the logic instructions.