Sub topic 2
Topics and instructions: scoping the agent's work
Prerequisites
This chapter assumes you know the basic Salesforce data model (objects, fields, records) and can find your way around Setup and Lightning Experience. It also assumes you have a general idea of what an AI agent and a large language model (LLM) are. The previous chapter explained how an agent reasons. This chapter covers the main way you control that reasoning: topics and their instructions.
Why topics exist
An agent that can do everything is hard to keep reliable. If every action and every rule were visible on every turn, the LLM would have many choices to weigh and many ways to pick wrongly. A topic narrows the choice.
A topic is a unit of work that groups the following:
- A name.
- A classification description, which says what kinds of requests belong to the topic.
- Instructions, which say how the agent should behave inside the topic.
- A set of actions the agent may use for that work.
At runtime the agent first picks a topic for the user's request. Only then does it reason about which action to run, using only that topic's instructions and actions.
The loop at the end matters. After an action returns, the agent can reply or plan another step within the same topic.
The classification description
The classification description is the routing signal. The agent compares the user's message to the description of every topic and chooses the best match. Write it as a statement of scope, not as a list of rules.
A good description does three things:
- Names the kind of work, such as "questions about a customer's account".
- Gives example verbs or tasks, such as "look up, summarize, update basic fields".
- Stays distinct from the other topics.
Two topics with overlapping descriptions cause misrouting. If "Account Support" and "Customer Service" both claim "questions about customers", the agent has no basis to choose between them. Draw the boundary in the descriptions themselves, for example by saying one handles account records and the other handles cases.
Instructions
Instructions are natural-language rules that apply once the topic is selected. They tell the agent three things:
- When to use each action.
- In what order to use actions.
- When to stop and ask the user for confirmation or clarification.
Here is an example topic for account work.
Topic: Account Support
Classification description:
Handle questions about a customer's account, such as looking up an account, summarizing it, or updating basic fields.
Instructions:
1. When the user names an account, first find the account record, then use the result for any later step.
2. Use the summary action when the user asks for an overview of an account.
3. Before updating a record, restate the field and the new value and ask the user to confirm.
4. If you cannot find exactly one matching record, ask the user to clarify instead of guessing.Each instruction in this example does a different job:
| Instruction | Job it does |
|---|---|
| 1. Find the record first | Sets ordering. Later actions need the record's ID, which the lookup returns. |
| 2. Use the summary action for overviews | Maps an intent to an action. |
| 3. Confirm before updating | Adds a safety checkpoint before a data change. |
| 4. Ask when not exactly one match | Defines the fallback for ambiguous results. |
Writing instructions that work
Instructions are guidance to an LLM, not code. The agent usually follows them but nothing guarantees it. Write them to make the right behavior the easy one.
Keep each instruction to one idea
"Look up the account, summarize it, and update the phone number if asked" packs three behaviors into one line. Split it so each rule can be tested and changed on its own.
Refer to actions by their names
Use the action's name as it appears in the topic. "Use Query Records to find open cases" is clearer than "check the database". A vague phrase leaves the agent to guess which action you mean.
State order and dependencies
If one action needs another's output, say so. The agent does not know that an update needs a record ID unless the instructions or the action's inputs make it clear.
Say what to do, and give the condition
"Ask the user to confirm before updating" is better than "be careful with updates". Pair every rule with the situation that triggers it.
Keep the list short
Every instruction competes for the agent's attention. Long lists with overlapping rules produce inconsistent behavior. Cover the behaviors that matter and leave out the obvious ones.
Instructions versus permissions
Instructions shape behavior. They do not enforce security. An instruction such as "never change the Owner field" is a request to the LLM, and it can fail. Real limits come from the platform: the running user's permissions, field-level security, and sharing rules. Use instructions to guide the agent and permissions to restrict it. A later chapter covers access control in detail.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| The agent answers from the wrong topic | Overlapping classification descriptions | Rewrite the descriptions so each has a distinct scope |
| The agent skips the lookup and asks for an ID | No instruction to find the record first | Add an ordering instruction |
| The agent updates records without asking | No confirmation rule | Add a confirm-before-update instruction |
| The agent guesses between similar records | No rule for ambiguous matches | Add an ask-for-clarification instruction |
| The agent refuses a request it should handle | The description is too narrow, or no topic fits | Broaden the description, or add a topic |
| The agent ignores a rule | Too many or conflicting instructions | Shorten the list and remove contradictions |
Topic size
A topic with too many actions is hard for the agent to use well, for the same reason a single all-purpose agent is. A topic with a single action may be too fine-grained, and requests that span two topics can lose context at the boundary. Group actions by the job the user is trying to do. Account lookup, summary, and basic updates belong together because one conversation often uses all three.
Summary of the working model
- The agent matches the request to a topic using classification descriptions.
- The topic's instructions and actions become the agent's working set.
- The agent chooses actions according to the instructions and the user's request.
- Platform permissions decide what those actions can actually read or change.
Exercise
A topic called "Account Support" has the instruction "Update the account when the user asks." Testing shows the agent sometimes changes a field after a vague request like "fix the phone thing." Rewrite the instruction set to reduce this problem. Name which of the four jobs from the example table you are adding.
Show answer
Add a confirmation rule and a clarification rule. For example: "Before updating a record, restate the field and the new value and ask the user to confirm," and "If the request does not name a specific field and value, ask the user to clarify instead of guessing." The confirmation rule is the safety checkpoint (job 3). The clarification rule is the fallback for ambiguity (job 4). You may also add an ordering rule to find the record first (job 1) so the update uses a verified record.
Exercise
Two topics, "Account Support" and "Customer Service", both have the classification description "Handle questions about customers." Users' account requests are routed unpredictably. What is the cause, and how do you fix it?
Show answer
The descriptions overlap, so the agent has no basis to prefer one topic. Rewrite each to claim a distinct scope. For example, "Account Support" handles looking up, summarizing, and updating account records, and "Customer Service" handles creating and resolving customer cases. Then retest with sample requests for each topic.