Skip to main content

Agentforce: The Reasoning Engine

⚡ 1-Minute Summary
  • Instructions resolve top to bottom. Logic lines run. Prompt lines become English.
  • The model never sees your script. It sees only the finished prompt your logic built.
  • Shorter reasoning instructions produce more accurate agents. Verbosity is not thoroughness.
Module map
MODULE 2 root: 'What actually happens in one turn?'
├─ 2.1 Anatomy of one turn
├─ 2.2 How the prompt gets built
└─ 2.3 Why shorter instructions win

Anatomy of One Turn

๐Ÿ’ฌ In plain words: Every message follows the same seven steps: router, before-reasoning, instructions, model, tools, after-reasoning, reply. Learn this sequence and every design decision in Agentforce explains itself.
๐Ÿ“Œ Example: A Meridian customer says "is my power back yet?". The router picks the outage subagent. Before-reasoning verifies their meter. Instructions run a status action and branch. The model phrases the answer. After-reasoning logs the contact.
Concept
  • Every request begins at start_agent, including the very first one.
  • The router classifies the message to exactly one subagent, and can also set starting variable values.
  • before_reasoning then runs, on every request. It is deterministic setup — run actions, set variables, or transition away entirely.
  • reasoning.instructions resolve top to bottom. Logic lines execute; prompt lines accumulate; conditions gate what gets included.
  • The finished prompt goes to the model, which starts reasoning only at that point.
  • The model may call tools from reasoning.actions, and those results feed back into the loop.
  • after_reasoning runs when reasoning completes, on every request. Guards, escalation, logging.
  • The reply goes out and a trace records the whole path.
  • One rule with teeth: if a subagent transitions away partway through, its own after_reasoning does not run.
Utterance ↓ start_agent → classify to ONE subagent, set initial vars ↓ before_reasoning → deterministic setup (no prompt text allowed) ↓ instructions → logic lines run | prompt lines build English ↓ LLM → sees ONLY the resolved prompt ↓ reasoning.actions→ tools the model may choose ↓ after_reasoning → guards, escalation (skipped if you transitioned) ↓ Reply + trace
๐Ÿง  "Route, Set, Resolve, Ask, Tool, Guard, Reply." Seven steps, same order, every single turn.
๐Ÿงญ 360 Card — Anatomy of One Turn

Rule: know the seven steps in order. Every Agentforce design question resolves to one of them.

Gain: you can place any behaviour on the timeline and say exactly why it happened.

Price: none. This is the model, not a feature with a cost.

Limits: 60-second action timeout. Apex limits apply inside the turn, and the ReAct loop can call one action several times.

Mirror — treating the agent as a black box: you end up tuning prompts by trial and error with no theory of the failure.

Later: this sequence is also your debugging order. Read the trace in the same order the turn ran.

At volume: long reasoning chains cost credits and add latency. On voice, latency is dead air.

⚠ INTERVIEW TRAP: Do not say the model "decides which subagent to use". The router does that before the subagent's model call exists. Getting this backwards suggests you have never read a trace.

Core Q&A

Q: Walk me through what happens when a customer sends a message to an agent.
๐ŸŽฏ Say this first: Router picks one subagent, before-reasoning runs setup, instructions resolve into a prompt, the model answers, tools may fire, after-reasoning guards, reply plus trace.

A: Take it in order, because the order is the whole point.

  • Every request starts at the agent router, which classifies the message to exactly one subagent and can set initial variables.
  • That subagent's before-reasoning block runs next — deterministic setup, on every request.
  • Then the reasoning instructions resolve top to bottom. Logic lines execute actions and set variables; prompt lines build up English; conditions decide what gets included.
  • The finished prompt goes to the model. It starts reasoning only at that moment, and it sees nothing but that prompt.
  • It may call tools from the reasoning actions list, and results loop back.
  • after-reasoning then runs any final guards, and the reply goes out with a trace recorded.
  • The catch worth naming: if the subagent transitions away partway through, its own after-reasoning never runs.