Sub topic 2
Topics and instructions: scoping the agent's work
This chapter assumes you know the Salesforce data model (objects, fields, records), can navigate Setup, and have a general idea of what an AI agent and a large language model are. It builds on the previous chapter, where you saw how an agent reasons about a request.
What a topic is
A topic is a bounded area of work for an agent. It groups three things:
- A name and a classification description, which tell the agent what kind of request belongs here.
- Instructions, which tell the agent how to behave once it is in the topic.
- Actions, the capabilities the agent may use inside the topic.
An agent usually has several topics, such as account support, order status, or general FAQ. Scoping work into topics keeps each set of instructions short and keeps the agent from using actions that don't fit the request.
How the agent picks a topic
When a user sends a message, the agent first compares it with the classification description of each topic and selects the best match. Only the instructions and actions of that topic are then available for the reply. The agent does not read every topic's instructions at once.
This has a practical effect. If the classification description is vague or overlaps with another topic, the agent may route requests to the wrong place, and no instruction can fix that afterward.
Writing the classification description
Describe the requests the topic handles, in plain language, and name the objects or tasks involved. Compare these two:
| Weak description | Stronger description |
|---|---|
| Account stuff | Handle questions about a customer's account, such as looking up an account, summarizing it, or updating basic fields. |
The stronger version gives the agent concrete verbs to match against the user's message.
Writing instructions
Instructions are natural-language guidance. They can tell the agent when to use each action, in what order, and when to ask the user for confirmation or clarification. Here is an example for an account support topic:
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 line does a different job:
- Instruction 1 sets an order: find the record, then act on it.
- Instruction 2 maps a kind of request to a specific action.
- Instruction 3 adds a confirmation step before a change.
- Instruction 4 says what to do when the result is ambiguous.
Common errors
- Writing instructions that are too long. Each one should be a single, testable rule.
- Overlapping topics. Two topics that both claim "account questions" make routing unreliable.
- Leaving out the failure case. If no instruction covers zero or multiple matches, the agent may guess.
- Relying on instructions for security. Instructions guide behavior, but they do not grant or restrict data access. Permissions do that, as a later chapter explains.
Exercise
A user asks, "Change the phone number on the Acme account." Which instructions from the Account Support example apply, and in what order?
Show answer
Instruction 1 applies first: find the Acme account record. Instruction 4 applies if the search doesn't return exactly one match, so the agent asks the user to clarify. Once one record is found, Instruction 3 applies: the agent restates the field (phone) and the new value, and asks the user to confirm before updating.