Sub topic 10
Writing descriptions that steer the choice
This chapter assumes you know basic Salesforce concepts (objects, records, Setup), have seen Flow or Apex at a high level, and know roughly what a large language model does. You should also know the parts of an agent: topics, instructions, and actions.
Why descriptions matter
An Agentforce agent does not run code to decide what to do. Its reasoning engine reads text and asks a large language model (LLM) to choose. For each request, the model sees the text you wrote and picks the best match:
- Topic classification description. The model reads these to choose a topic.
- Topic scope and instructions. The model reads these to decide what is allowed inside the chosen topic.
- Action names and descriptions. The model reads these to choose an action.
- Input names and descriptions. The model reads these to decide what values to collect or pass in.
If this text is vague, overlapping, or missing, the model guesses. Most "the agent picked the wrong action" problems trace back to the text, not to the model.
The levels of description
Descriptions work at three levels. Each level narrows the choice for the next.
An error at an early level carries forward. If the wrong topic is chosen, the right action may not even be available, because actions belong to topics.
Writing a topic classification description
The classification description answers one question: when should this topic handle a request? Write it from the customer's point of view and name the kinds of requests it covers.
A weak description:
Order stuff.A stronger description:
Handles customer questions about the status of an existing order, such as where it is or when it will arrive.The stronger version names the object (an existing order), the intent (status), and gives example phrasings ("where it is", "when it will arrive"). Use these habits:
- Start with a verb. "Handles", "Answers", "Helps with".
- Name the user's goal, not your system. "Where is my package" is closer to what users say than "queries the Order object".
- Give examples of phrasing. The model matches meaning, so examples help it generalize.
- Keep topics distinct. If two descriptions could both fit the same request, the model will flip between them.
Writing scope and instructions
Scope states what the topic does and, just as important, what it does not do. Instructions tell the agent how to behave inside the topic.
Topic: Order Support
Classification description: Handles customer questions about the status of an existing order, such as where it is or when it will arrive.
Scope: Look up order status and explain it. Does not process returns, refunds, or changes to an order.
Instructions:
- Ask for the order number if the customer has not given one.
- Use the order status action to look up the order before answering.
- If the order cannot be found, say so and do not guess.
Actions: Get Order StatusNotice what each part does:
- The scope's "does not process returns" sends refund requests elsewhere, to a Returns topic.
- The first instruction fills a missing input before the action runs.
- The second instruction links a situation to a specific action by name.
- The third instruction defines behavior for the failure case, so the agent does not invent an answer.
Instruction writing rules
| Do | Avoid | Why |
|---|---|---|
| One behavior per instruction | Long paragraphs with several rules | Short rules are easier for the model to follow and for you to test |
| Name the action in the instruction | "Use the right tool" | The model can link the instruction to an action only if the names match |
| State the condition: "If the order cannot be found..." | Unconditional "Always apologize" | Conditions tell the model when a rule applies |
| Say what to do | Only say what not to do | Prohibitions alone leave the agent without a next step |
| Keep instructions inside the topic's scope | Rules about unrelated topics | Out-of-scope text adds noise and can conflict with other topics |
Writing action descriptions
An action description answers: what does this do, and when should it be used? Include what it returns, because the model uses that to decide whether the output will answer the request.
The Apex action from the spine shows where this text lives:
public with sharing class OrderStatusAction {
public class Request {
@InvocableVariable(label='Order Number' description='The order number the customer provided' required=true)
public String orderNumber;
}
public class Response {
@InvocableVariable(label='Status' description='Current status of the order, or Not Found')
public String status;
}
@InvocableMethod(label='Get Order Status' description='Looks up the current status of an order by its order number')
public static List<Response> getStatus(List<Request> requests) {
Set<String> orderNumbers = new Set<String>();
for (Request r : requests) {
orderNumbers.add(r.orderNumber);
}
Map<String, String> statusByNumber = new Map<String, String>();
for (Order o : [SELECT OrderNumber, Status FROM Order WHERE OrderNumber IN :orderNumbers]) {
statusByNumber.put(o.OrderNumber, o.Status);
}
List<Response> results = new List<Response>();
for (Request r : requests) {
Response res = new Response();
res.status = statusByNumber.containsKey(r.orderNumber) ? statusByNumber.get(r.orderNumber) : 'Not Found';
results.add(res);
}
return results;
}
}Four pieces of text are visible to the agent:
- The method
label: "Get Order Status". - The method
description: says it looks up status by order number. - The
Requestvariable description: says the value is the number the customer provided. - The
Responsevariable description: says the value can be "Not Found", so the agent knows that result is expected and not an error.
Compare two descriptions
| Quality | Label | Description |
|---|---|---|
| Weak | `Process Order` | `Handles orders` |
| Strong | `Get Order Status` | `Looks up the current status of an order by its order number` |
"Process Order" could mean create, update, cancel, or look up. The strong version contains a specific verb ("looks up"), the data (status), and the key input (order number).
Edge cases and failure modes
Overlapping actions
Suppose a topic has Get Order Status and Get Order Details, with descriptions "Gets order information" for both. The model cannot tell them apart. Fix the descriptions so each states a different output, for example "Returns only the status value" and "Returns line items, prices, and shipping address". If two actions truly do the same job, remove one.
Overlapping topics
A request such as "I want to return my order and see where it is" matches two topics. Scope text helps here. A clear exclusion ("Does not process returns") keeps each topic narrow. You may also decide the agent should handle one part and then the other across turns. Test these cases on purpose.
Descriptions that match the wrong words
The model matches meaning, but wording still biases it. If your action description says "customer lookup" and your topic is about orders, a request like "look up my order" may be pulled toward the customer action. Review descriptions for words that fit a neighboring action.
Inputs the model cannot fill
If an input description says "The internal record ID" the agent has nothing in the conversation to supply it from. Describe inputs in terms the user can provide ("the order number the customer provided") or that earlier actions return. Mark an input required=true only when the action cannot run without it.
Descriptions that drift from behavior
If you change what an action does but leave the old description, the agent keeps using the old meaning. Update the text whenever the logic changes, and treat it as part of the change, as you would a method signature.
Too much text
Long descriptions are not safer. Every topic and action competes for the model's attention. A description with several sentences of background dilutes the one sentence that matters. Aim for one or two sentences for a description and a short list for instructions.
A revision workflow
Descriptions are tested by running requests, so improve them in loops:
- Write a short list of sample requests for each topic, including near-misses that belong elsewhere.
- Run them in the testing tools and note the topic and action chosen.
- For each wrong choice, find which description attracted it, and which should have.
- Change one description at a time. Changing several makes it hard to tell what helped.
- Rerun the full list, not only the failing request, to catch regressions.
Later chapters cover the testing and tracing tools in detail. For now, treat any wrong choice as feedback about the text.
Exercise
A topic has two actions. "Find Case" has the description "Gets case information." "Find Case History" has the description "Gets case details." A customer asks, "What happened on my case last week?" and the agent calls the wrong one. Rewrite both descriptions so the choice is clear, and explain what you changed.
Show answer
Possible rewrite: "Find Case" becomes "Returns the current status, priority, and owner of a case, given a case number." "Find Case History" becomes "Returns the dated list of changes and comments made on a case, given a case number." The original descriptions were interchangeable ("information" and "details" mean the same thing to the model). The rewrite names a distinct output for each action. The request about what happened last week now matches the history description because it asks for events over time.
Exercise
A teammate adds the instruction "Never discuss other customers' orders" to Order Support to keep data private. Is that enough? What should you do instead?
Show answer
No. An instruction is a request to the model, so it can fail. Enforce privacy with permissions, sharing rules, and with sharing Apex so the action cannot return other customers' records. Keep the instruction as a guide to behavior, not as the control.
Exercise
Why does a topic's scope say what the topic does not do?
Show answer
Exclusions keep neighboring topics distinct. With "Does not process returns, refunds, or changes", a refund request is less likely to be classified into Order Support, and the model has a clear signal to route it to another topic.