Sub topic 16
Best practices and common pitfalls
This chapter pulls together the practices that make standard Agentforce actions reliable. It assumes you can already add a standard action to a topic in Agentforce Builder, you know what inputs and outputs are, and you have run a test conversation. You should also know the basics of permission sets and profiles. Most problems come from a small set of causes: topics that overlap, instructions that are vague, actions that are too broad, and tests that cover only the happy path.
Keep topics narrow and distinct
The agent first picks a topic, then picks actions inside it. If it picks the wrong topic, nothing after that can fix the result.
- Give each topic one job, described in the classification description. "Handle questions about a customer's account" is better than "Handle customer stuff."
- Avoid two topics whose descriptions could both match the same request. If "Account Support" and "Order Help" both claim "look up details," the agent will switch between them unpredictably.
- Add only the actions a topic needs. Each extra action is another option the agent can pick wrongly, so a topic with four relevant actions is usually more reliable than one with fifteen.
- Name and describe actions in the language users use. The agent reads these descriptions when it decides what to run.
Write instructions that say when, in what order, and what to ask
Good topic instructions are short, numbered, and specific about conditions. They do three things: say when to use an action, say what must happen before it, and say when to ask the user.
Topic: Account Support
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.Compare that with a weak version such as "Help with accounts and be careful with changes." It gives the agent no trigger, no order, and no definition of "careful."
Some habits that help:
- Use one instruction per behavior. Long paragraphs with several rules bury the rule that matters.
- Describe the situation, not the internal mechanism. "When the user asks for an overview" is clearer than a rule that depends on guessing which input is filled.
- State the fallback. "If you cannot find exactly one matching record, ask" covers the case where the lookup returns nothing or several results.
- Do not use instructions to enforce security. They guide behavior, but they are not access control. Use permissions for that (see below).
Design inputs and outputs deliberately
The agent fills inputs from the conversation or from earlier action outputs. Missing or ambiguous inputs are a common cause of wrong results.
- Give every input a clear description, including the expected format (for example, "Account name as the user typed it" versus "18-character record ID").
- Mark an input as one the agent must collect from the user only when the user really has to supply it. Values that can come from an earlier lookup should come from there.
- Prefer passing a record ID from a previous output over asking the agent to re-type a name. Names are ambiguous, and IDs are not.
- Keep outputs small and relevant. Large outputs that the agent does not need add noise to the conversation.
Treat writes differently from reads
Reading a record is low risk. Creating or updating one changes data, so it deserves more care.
- Require confirmation before every create or update, as in instruction 3 above.
- Look up the record first, and update only when exactly one match exists.
- Limit which fields can be changed. An update action that can touch any field is harder to reason about than one scoped to a few.
- Test update flows with a user who has read-only access, to confirm the failure is clean and the agent says so.
Remember who the action runs as
Standard actions run on behalf of the user who is talking to the agent, so object permissions, field-level security, and sharing rules apply. This has practical consequences.
- A test run by an administrator may succeed where the same request from a sales user fails. Always test with a representative user.
- If the agent says it cannot find a record, check whether the user can see it before changing instructions.
- Give users permission to use the agent and access the objects and fields its actions touch. Grant only what is needed.
- The Einstein Trust Layer applies protections to prompts and responses, such as masking sensitive data before it reaches a model. It does not replace sharing and field security, and you should not rely on it as the only safeguard.
Custom Apex actions follow the same principle. The example in this tutorial declares public with sharing class OpenCaseCounter so that sharing rules are enforced. Leaving out with sharing can expose records the user should not see.
Test beyond the happy path
Use the conversation preview in Agentforce Builder to try requests, then inspect which topic was chosen, which actions ran, what inputs they received, and what they returned. Use batch testing for repeatable checks once the basics work.
A useful test set includes:
- A clear request that should work.
- The same request phrased three different ways.
- A request with no matching record.
- A request with several matching records.
- A request from a user without access.
- A request outside every topic's scope.
- An update that the user declines at the confirmation step.
When a result is wrong, look at the action calls before editing anything. The cause is usually one of three things: the wrong topic was selected, the right action got the wrong input, or the action returned something unexpected.
Common pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Overlapping topic descriptions | The agent picks different topics for similar requests | Rewrite descriptions so each covers a distinct job |
| Too many actions in one topic | The agent picks an unrelated action | Remove actions the topic does not need, or split the topic |
| Vague action or input descriptions | Wrong action or wrong input values | Rewrite descriptions in the users' words, with formats |
| No ambiguity rule | The agent guesses between several matching records | Add an instruction to ask when there is not exactly one match |
| Updates without confirmation | Unwanted data changes | Add a confirm-before-write instruction |
| Testing only as an admin | Works in testing, fails for real users | Test with representative users and permission sets |
| Relying on instructions for security | A rule is skipped in some conversations | Enforce with permissions and validation |
| Forcing a standard action to do a custom job | Long, brittle instructions | Move to a custom Flow, Apex, or prompt template action |
Decide when to stop adjusting a standard action
Standard actions cover common work. If you need business logic that must run the same way every time, such as a calculation, a multi-object update, or a call to another system, instructions will not give you that guarantee. Build a custom action and keep the topic instructions simple.
A short checklist before release
- Each topic has one clear job and a distinct description.
- Each topic contains only the actions it needs.
- Instructions state when to use actions, the order, and when to ask.
- Writes require confirmation, and ambiguous lookups prompt a question.
- You tested with users who have realistic permissions.
- You reviewed the action calls for both successful and failed conversations.
Exercise
A user asks the agent to update the phone number on "Acme." Your org has two accounts named Acme. The agent updates one of them without asking. Name two changes to the topic instructions that would prevent this.
Show answer
First, add an instruction to find the account record before any update and to ask the user to clarify unless exactly one record matches. Second, add an instruction to restate the field and new value and get the user's confirmation before the update action runs. If a guarantee is needed, also restrict the update to specific fields or use a custom action that checks the match.
Exercise
A request works in your test as an administrator but fails for a sales user, with the agent saying it cannot find the record. What is the most likely cause, and what should you check first?
Show answer
Standard actions run as the user, so the sales user probably lacks access to the record, object, or field through sharing, object permissions, or field-level security. Check what that user can see in Salesforce before editing the instructions or actions.