Sub topic 8
Controlling what the agent and user see
This chapter assumes you can already define an action with inputs and outputs in Agentforce Builder. You should also know the difference between an Apex invocable method and a Flow. Here you will learn how each output of an action reaches the agent, the user, or both, and how to choose the right destination for each output.
Two audiences for every output
An action returns a set of output values. Each value can go to two different places:
- The agent. The large language model (LLM) that reads the output, reasons about it, and writes the reply.
- The user. The person in the conversation, who can see the output directly in the chat window.
These are separate decisions. An output can be visible to the agent only, to the user only, to both, or to neither. The agent can also pass an output to a later action without ever showing it to anyone.
Builder exposes this as two settings on each output. The exact wording varies by release, so check your org's UI.
| Setting | Meaning when enabled |
|---|---|
| Filter from agent | The agent's reasoning does not see the value. The agent cannot quote it, summarize it, or base decisions on it. |
| Show in conversation | The platform displays the value to the user in the chat, without relying on the agent to repeat it. |
How the settings combine
Four combinations are possible, and each suits a different purpose.
| Filter from agent | Show in conversation | Result | Typical use |
|---|---|---|---|
| Off | Off | The agent sees the value and decides whether to mention it. | Status, dates, and amounts the agent should explain in its own words. |
| Off | On | The agent sees the value, and the user also sees it displayed. | A result the user should see verbatim, such as a tracking number or a formatted summary. |
| On | On | The user sees the value, but the agent does not. | Content the agent should not interpret or alter, such as a legal notice or a long record list. |
| On | Off | Neither sees the value in the reply. It is available only for passing along. | Internal record IDs, tokens, and intermediate values for the next action. |
Deciding what the agent should see
Start from the question the agent must answer. Let the agent see an output when it needs the value to do one of these things:
- Explain the result to the user in plain language.
- Choose the next step, such as deciding whether to offer a refund.
- Ask a clarifying question that depends on the result.
Hide an output from the agent when it adds noise or risk:
- Technical identifiers. A 15- or 18-character record ID gives the LLM nothing useful to say. It may even repeat the ID to the user.
- Large payloads. Long JSON or text blobs consume context and can distract the agent from the actual question.
- Values the agent might change when repeating them. Quoted policy text and exact figures are examples.
- Data that should not enter the LLM's context at all, according to your own data-handling rules.
> Visibility settings control presentation. They do not control access.
Showing values to the user directly
A value the agent summarizes is a paraphrase. A value shown in the conversation is exact. Choose "Show in conversation" when exact wording or formatting matters, for example:
- A confirmation number the user will copy.
- A list of records the user needs to pick from.
- A message produced by a deterministic process, such as a prompt template or a formatted Flow text.
If you show a value and leave it visible to the agent, the user can see it twice: once as the displayed item and once in the agent's reply. Avoid this by writing the output description so that the agent does not repeat the value. For example: "Displayed to the user already. Do not repeat it; refer to it as 'the details above'."
If you show a value and filter it from the agent, the agent does not know what the user saw. It cannot answer follow-up questions about that content. Give the agent a second, short output that summarizes what happened. It might be called Result Message, and it holds text such as "Showed the customer three matching orders."
Passing values between actions
Some outputs exist only to feed the next step. A search action finds an order, and an update action needs that order's Salesforce ID. The user never needs to read that ID.
The pattern is:
- The first action returns the ID as an output.
- You filter the output from the agent and do not show it.
- The output is stored in a variable, and the second action receives it as an input.
The variable travels along with the conversation state. This is more reliable than asking the agent to remember a long ID and retype it into the next call. LLMs sometimes transpose or invent characters in identifiers.
Example: one Apex response, three visibility choices
This Apex action looks up an order. It returns an ID for chaining, a status the agent should explain, and a formatted summary the user should see exactly as written.
public with sharing class GetOrderDetails {
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 Record Id'
description='Salesforce record Id of the order. For use by later actions only. Never show this to the customer.'
)
public Id orderId;
@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='Order Summary'
description='A formatted summary shown to the customer already. Do not repeat it in your reply.'
)
public String summary;
@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 Details'
description='Looks up one order by its order number. Use when the customer asks about an order.'
)
public static List<Response> getDetails(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 Id, OrderNumber, Status, TotalAmount
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.orderId = o.Id;
res.status = o.Status;
res.summary = 'Order ' + o.OrderNumber + ' | Status: ' + o.Status
+ ' | Total: ' + o.TotalAmount;
res.message = 'Order ' + r.orderNumber + ' has status ' + o.Status + '.';
}
results.add(res);
}
return results;
}
}In Builder you would then configure the outputs like this:
| Output | Filter from agent | Show in conversation | Reason |
|---|---|---|---|
| Order Record Id | On | Off | Used only to chain to a later action. |
| Order Status | Off | Off | The agent explains it in its own words. |
| Order Summary | On | On | The user sees the exact text. The agent does not rewrite it. |
| Result Message | Off | Off | Tells the agent what happened, including the not-found case. |
Note that Result Message stays visible to the agent in every case. This is deliberate. The agent needs at least one readable output to understand the outcome, even when the other values are hidden.
Edge cases and common mistakes
- Hiding every output. If you filter all outputs from the agent, it has nothing to base its reply on. It may say the action worked when it did not, or it may guess. Always keep one plain-language output visible.
- Showing a value the agent also repeats. The user sees duplicate text. Fix it in the description, or filter the value from the agent.
- Relying on the description to hide data. A description such as "Never show this to the customer" is guidance to the LLM, not enforcement. For genuinely sensitive values, use the filter setting or stop returning the value.
- Filtering a value the agent needs for a decision. If the agent must decide between two paths based on a value, such as an order total, it must see that value.
- Empty outputs. An output left empty is still an output. Describe it ("Empty if no order was found") so the agent does not treat blank as an error.
- Forgetting follow-ups. Content shown to the user but filtered from the agent cannot be discussed by the agent. Pair it with a summary output.
Testing visibility settings
After configuring outputs, run the agent in the Builder preview and check the reasoning trace for each case.
- A successful lookup. Confirm which outputs appear in the trace and which appear in the chat.
- A not-found lookup. Confirm that the agent relays
Result Messageand does not invent a status. - A follow-up question about displayed content, such as "What was the total on that order?" Check whether the agent can answer. If it cannot, add a visible summary output.
- A chained flow. Confirm that the ID reaches the second action without appearing in any reply.
Exercise
A Flow action returns three outputs: Case Record Id, Case Status, and Resolution Article Text, a long, legally reviewed paragraph the customer must see word for word. Choose "Filter from agent" and "Show in conversation" settings for each output, and explain one risk of your choice for the article text.
Show answer
Case Record Id: filter from agent on, show in conversation off, since it is only for chaining to later actions. Case Status: both off, so the agent sees it and explains it in its own words. Resolution Article Text: filter from agent on, show in conversation on, so the user sees the exact reviewed wording and the agent cannot rewrite it. The risk is that the agent does not know what the user saw, so it cannot answer follow-up questions about the text. Fix this by adding a short visible output, such as Result Message, saying that the article was displayed to the customer.