Sub topic 1
How an agent turns a request into a response
An Agentforce agent does not run a fixed script. For each message, it decides which job the message belongs to, reasons about how to do that job, and then calls the tools that job allows. This chapter explains that loop. The later chapters cover each part in detail.
Prerequisites
This chapter assumes you know the following:
- Basic Salesforce concepts: objects, fields, and records.
- How to move around Salesforce Setup.
- What a large language model (LLM) does at a high level: it reads text and produces text.
- Flow or Apex are helpful for the action chapters, but you don't need them here.
The three building blocks
An agent is built from three parts that work together.
| Part | What it is | Question it answers |
|---|---|---|
| Topic | A named group of related work, such as order status | "Which job is this request about?" |
| Instructions | Written guidance attached to a topic | "How should I handle this job?" |
| Actions | Things the agent can run, such as a Flow or Apex method | "What can I read or change?" |
A topic holds both its instructions and its actions. The agent can only use the instructions and actions of the topic it has chosen. This is what keeps one job from leaking into another.
What happens to one request
Suppose a customer writes: "Where is my order 1042?"
- Classify. The LLM compares the message to each topic's name and classification description. It picks the best match, here an Order Status topic.
- Read the scope and instructions. The agent loads the chosen topic's scope and instructions. They tell it what the job covers and which steps to follow.
- Plan. The agent decides what it needs. Here it needs an order number, and the customer gave one.
- Act. The agent selects an action from the topic, such as Get Order Status. It fills the action's inputs from the conversation. Here the input is the order number 1042.
- Respond. The action returns an output. The agent reads it and writes a reply, following the instructions.
Steps 3 to 5 can repeat. An agent may call one action, read the result, and then call another before it replies.
Why each part matters
The agent's choices come from the text you write. That makes your wording the main thing you control.
- If the classification description is vague, the agent may pick the wrong topic, or two topics may compete for the same request.
- If the instructions are loose, the agent improvises. Two customers with the same question can get different handling.
- If an action's name and description are unclear, the agent may skip it, choose the wrong one, or pass bad inputs.
Here is a short example of a topic definition. The classification description tells the agent when to choose the topic, and the scope tells it where the job ends.
Topic name: Order Status
Classification description:
Handle customer questions about where an existing order is and what its current status is. Do not use for returns, refunds, or new orders.
Scope:
Your job is to look up the status of an existing order and report it. You cannot change or cancel orders.Notice the "Do not use for" sentence. It tells the agent what to leave to other topics, which reduces overlap.
Where you do this work
You create and edit topics, instructions, and actions in Agentforce Builder, the workspace for agents in Salesforce. It also lets you test a conversation and see which topic and actions the agent chose. The next chapter walks through its layout.
Exercise
A customer writes "I want my money back for order 1042." The agent has an Order Status topic and a Returns and Refunds topic. Describe the order in which the agent handles this, and name the text that decides which topic is chosen.
Show answer
The agent first classifies the message by comparing it to each topic's name and classification description. The refund request matches Returns and Refunds, and the Order Status description says not to use it for refunds. The agent then applies that topic's scope and instructions, selects an action from that topic if needed, fills its inputs, reads the output, and writes the reply. The classification description decides the topic.