Sub topic 3
Names, labels, and descriptions the agent reads
This chapter assumes you know what an Agentforce agent, topic, and action are. It also assumes you can read basic Apex or build a Flow with input and output variables. Here we look at the text you attach to an action and how the agent's language model uses it.
The agent only sees text
The agent cannot read your Apex code or open your Flow canvas. When it reasons about what to do, it sees a description of each action. That description is built from the metadata you wrote:
- The action's name and its instructions.
- The name, label, and description of each input.
- The name, label, and description of each output.
- The data type of each input and output.
The model compares the customer's request with these descriptions. It picks an action, works out which values to pass in, and later reads the output to write a reply. If the text is vague, the model has to guess, and guesses show up as wrong calls, invented values, or confusing answers.
Treat this metadata as a prompt you write once and the model reads on every turn.
The metadata is used twice. It guides the choice and input filling before the target runs. It guides the interpretation of results after the target runs.
Names, labels, and descriptions are different things
Each element can carry up to three kinds of text. They do different jobs.
| Text | Who mainly uses it | What to put there |
|---|---|---|
| API name | Developers, code, and Flow references | A stable identifier such as `orderNumber`. It still gives the model a hint, so keep it meaningful. |
| Label | The agent and admins | A short human phrase such as `Order Number`. |
| Description | The agent | The rules of use: what the value is, an example, when to ask, and what to avoid. |
The API name is hard to change after other things depend on it. The label and description are easy to edit, so most of your tuning happens there. Avoid names like var1, input, result, or Id. A label such as Result forces the model to infer meaning from context, and it may infer wrong.
What a good description contains
A useful description answers questions the model would otherwise guess at. For an input, cover these points:
- What the value is. Say which object or concept it identifies.
- What it looks like. Give a concrete example, such as
00000101. - Where it comes from. Say whether the customer provides it or an earlier action returns it.
- What to do if it is missing. Say "Ask the customer" or "Do not guess."
For an output, cover these points:
- What the value means. Name the concept, not the field.
- What values to expect. List typical values such as
DraftorActivated. - What an empty value means. Say when it will be blank and why.
Here is a weak and a strong version of the same metadata side by side.
Weak input description:
Label: Id
Description: The id
Stronger input description:
Label: Order Number
Description: The order number the customer provided, for example 00000101. Ask the customer if it was not given. Do not guess.
Weak output description:
Label: Result
Description: Output of the action
Stronger output description:
Label: Order Status
Description: Current status of the order, such as Draft or Activated. Empty if no order was found.The weak input says nothing about which record the Id belongs to. The model might pass a Salesforce record Id, a case number, or something it made up. The strong version fixes the format with an example and blocks guessing with a direct instruction.
Descriptions are instructions, so write them as instructions
The model treats description text as guidance. Short imperative sentences work well: "Ask the customer if it was not given." "Use when the customer asks where their order stands." Compare these two phrasings of an action description.
- Vague: "Order lookup."
- Clear: "Looks up the status of one order by its order number. Use when the customer asks where their order stands."
The clear version states what the action does, its scope ("one order"), and the trigger condition. The scope matters. If you later add an action that lists all of a customer's orders, the model needs the word "one" to tell the two apart.
Also write for contrast with neighboring actions. If two actions could plausibly handle the same request, each description should say when it is the right choice. Overlapping descriptions are a common cause of the agent picking the wrong action.
Where you write this text
The place depends on the target type.
- Apex invocable method. Set
labelanddescriptionon@InvocableMethodfor the action. Set them on each@InvocableVariablefor inputs and outputs. - Flow. Give each input and output variable a meaningful API name and fill in its Description field. Mark variables as available for input or output. The Flow's own description describes the action.
- Agentforce Builder. When you add an action to a topic, the builder shows the action's instructions and each input and output. You can adjust the text there, and the builder's text is what the agent reads for that topic. The exact field names in the builder can change between releases, so check the current screens.
The next example is the Apex version of the strong metadata above. Read the label and description values as if you were the model.
public with sharing class GetOrderStatus {
public class Request {
@InvocableVariable(
label='Order Number'
description='The order number the customer provided, for example 00000101. Ask the customer if it was not given. Do not guess.'
required=true
)
public String orderNumber;
}
public class Response {
@InvocableVariable(
label='Order Status'
description='Current status of the order, such as Draft or Activated. Empty if no order was found.'
)
public String status;
@InvocableVariable(
label='Result Message'
description='A short plain-language message describing the outcome, including when no order matches the number.'
)
public String message;
}
@InvocableMethod(
label='Get Order Status'
description='Looks up the status of one order by its order number. Use when the customer asks where their order stands.'
)
public static List<Response> getStatus(List<Request> requests) {
Set<String> numbers = new Set<String>();
for (Request r : requests) {
numbers.add(r.orderNumber);
}
Map<String, Order> byNumber = new Map<String, Order>();
for (Order o : [SELECT OrderNumber, Status FROM Order WHERE OrderNumber IN :numbers WITH USER_MODE]) {
byNumber.put(o.OrderNumber, o);
}
List<Response> results = new List<Response>();
for (Request r : requests) {
Response res = new Response();
Order o = byNumber.get(r.orderNumber);
if (o == null) {
res.message = 'No order was found with number ' + r.orderNumber + '.';
} else {
res.status = o.Status;
res.message = 'Order ' + r.orderNumber + ' has status ' + o.Status + '.';
}
results.add(res);
}
return results;
}
}Three details are worth noting:
- The method label and description tell the model what the action does and when to use it.
- The
orderNumberdescription includes an example and a rule about missing values. - The
messageoutput is described as covering the no-match case, so the model knows to read it whenstatusis empty.
The code also handles bulk requests, which invocable methods must do. That is a code concern. The model never sees it.
Common mistakes
- Describing the implementation instead of the meaning. "Maps to Order.Status__c" tells the model nothing useful. Say what the value means to a customer.
- Leaving descriptions blank. The label alone is often too thin. A blank description is the most common cause of poor input filling.
- Reusing generic names across actions. Several actions with an input called
Idmake the model's job ambiguous. Name the concept:Order Number,Case Number,Account Name. - Writing very long descriptions. Every action's text is read on each turn. Long descriptions cost tokens and bury the important rule. Aim for one to three sentences.
- Contradicting the topic instructions. If the topic says "always confirm the order number" and the input description says "use any number you find," the model gets mixed signals. Chapter 12 covers aligning them.
- Relying on internal jargon. If your company calls an order a "booking" internally but customers say "order," use the customer's word, or mention both.
A quick review process
Use this checklist for each action before you ship.
- Does the action description state what it does, its scope, and when to use it?
- Does every input label name a concept, with a description that includes an example?
- Does every input say what to do when the value is missing?
- Does every output describe its meaning and its empty case?
- Do any two actions have descriptions that overlap? If so, add contrast.
- Are the words consistent with the words customers use?
Later chapters build on this. They cover how required inputs trigger questions to the user, how types shape what the model can fill, and how to read agent traces to see what the model actually did with your text.
Exercise
An action has an input labeled "Id" with the description "The id". Customers often give an order number such as 00000101, but the agent sometimes passes a made-up value. Rewrite the label and description so the agent behaves better, and name the two parts of the new description that most directly prevent made-up values.
Show answer
Label: "Order Number". Description: "The order number the customer provided, for example 00000101. Ask the customer if it was not given. Do not guess." The example fixes the expected format, and the instructions "Ask the customer if it was not given" and "Do not guess" tell the model what to do instead of inventing a value.
Exercise
An output called "Result" returns an empty string when no order matches. Rewrite its label and description so the agent can explain the empty case to the customer.
Show answer
Label: "Order Status". Description: "Current status of the order, such as Draft or Activated. Empty if no order was found." Pairing this with a separate "Result Message" output that states in plain language when no order matches gives the agent text it can relay directly.
Exercise
You have two actions, "Get Order Status" and "List Customer Orders". Both descriptions say "Finds orders." Why is this a problem, and how would you fix it?
Show answer
The descriptions overlap, so the model cannot tell which action fits a request and may pick the wrong one. Make each description state its scope and trigger. For example: "Looks up the status of one order by its order number. Use when the customer asks where their order stands." and "Lists recent orders for the current customer. Use when the customer asks to see all their orders and has not given an order number."