Sub topic 2
The reasoning engine behind the agent
This chapter assumes you know basic Salesforce concepts (objects, records, Setup), have seen Flow or Apex at a high level, and have a general idea of what a large language model (LLM) does. Here you will learn what the reasoning engine is, what it does on each turn, and which parts of its behavior you control.
What the reasoning engine is
An Agentforce agent is made of topics, instructions, and actions. Those parts are only configuration. The reasoning engine is the component that reads that configuration and a user's message, then decides what to do next.
The engine uses an LLM to make its decisions. The LLM does not run your Flows or Apex code. It chooses, and the platform carries out the choice. This split matters for debugging. A wrong result can come from a bad choice by the engine or from a failure in the action it chose. Those are different problems with different fixes.
What the engine reads
On each turn the engine builds a prompt from several sources:
- The user's latest message and the earlier conversation.
- The agent's topics, each with its classification description.
- The instructions and scope of the current topic.
- The actions available in that topic, with their names and descriptions.
- Variables that hold values from earlier in the conversation.
The LLM sees only this text. It does not see your org's setup or your intent. If a fact is not in the prompt, the engine cannot use it.
What the engine decides
The engine makes three kinds of decisions:
- Which topic fits the request. It compares the message to each topic's classification description.
- Which action to run, if any. It compares the request to the instructions and to each action's description.
- What to say. It writes the reply from the results it has.
The engine can also ask the user for a missing input, such as an order number, before it runs an action.
The arrow from the action back to the engine is important. The engine reads the action's output and may choose another action or write the reply. The reasoning loop chapter covers this cycle in detail.
What you control and what you do not
You do not edit the LLM. You steer it through the text and structure you give it.
| You control | You do not control |
|---|---|
| Topic descriptions and scope | The model's internal weights |
| Instructions inside a topic | The exact wording of its reasoning |
| Which actions exist and their descriptions | Whether two runs choose identically in every case |
| What data actions return | Facts missing from the prompt |
Because the engine is probabilistic, a vague description can produce a different choice on a different day. Clear, specific text lowers that risk. It does not remove it, so you test with realistic requests.
Common errors
- Blaming the model first. Most wrong choices trace to overlapping topic descriptions or vague action descriptions.
- Assuming the engine knows your data. It knows only what is in the prompt and what actions return.
- Assuming it will call an action it was never given. If an action is not assigned to the topic, the engine cannot choose it.
- Expecting code-like determinism. The same request can be worded differently, and edge cases may route differently.
Exercise
A customer asks "Where is my order?" and the agent replies without running the Get Order Status action. Name two places in the configuration you would check first, and say why the LLM's weights are not one of them.
Show answer
Check the topic's classification description and instructions (the request may have gone to the wrong topic, or the instructions may not tell the agent to look up the order). Also check that Get Order Status is assigned to that topic and that its description says what it does. The weights are not something you can edit. You steer the engine only through the text and structure in its prompt.