Sub topic 6
Topic instructions: guiding the agent's reasoning
Topic instructions are the part of a topic that tells the agent how to work once it has chosen that topic. This chapter covers what instructions do, where they sit in the agent's reasoning, and what happens when they are vague or contradictory. The next chapter covers writing technique in detail.
This chapter assumes you know basic Salesforce concepts (objects, fields, records) and can navigate Setup. It also assumes you have a general idea of what a large language model does. You should already have read about topic names, classification descriptions, and scope.
Where instructions fit in the request flow
An agent handles a request in two stages. In the first stage it decides which topic the request belongs to. It does this using the topic name, the classification description, and the scope. Instructions play no part in that choice. In the second stage, with a topic selected, the agent reasons about what to do next. Instructions are the main guidance for that stage.
This split has a practical consequence. If the wrong topic is selected, no amount of editing instructions will fix it. Fix the classification description or scope instead. If the right topic is selected but the agent behaves badly, the problem is in the instructions or the actions.
What instructions are
Instructions are natural-language directions attached to one topic. Each instruction is a separate entry, and the agent reads all of them when the topic is active. They typically cover:
- What information to collect from the customer before acting.
- Which action to use, and when.
- How to handle each result an action can return.
- How to phrase the reply, including length and tone.
- What the agent must never do or say.
Instructions apply only while their topic is active. A rule in the Order Status topic has no effect in the Returns topic. If a rule must hold everywhere, such as a rule about protecting other customers' data, repeat it in each topic where it matters. Check whether your agent also has agent-level instructions where such rules can live once.
Instructions versus scope
Scope and instructions can look similar because both are written in sentences. They answer different questions.
| Part | Question it answers | Used when |
|---|---|---|
| Classification description | Does this request belong here? | Choosing the topic |
| Scope | What is this topic's job, and where does it end? | Choosing the topic and bounding the work |
| Instructions | Given that we are here, what do I do step by step? | Reasoning inside the topic |
A useful test: if a sentence describes a situation, it belongs in the classification description or scope. If it describes an action or a behavior, it belongs in the instructions.
A worked example
Here are instructions for the Order Status topic from earlier chapters:
1. Ask the customer for their order number if they have not given one.
2. Use the Get Order Status action with that order number.
3. If the action returns 'Not found', tell the customer you could not find the order and ask them to check the number.
4. Otherwise, state the status in one sentence.
5. Never share details about orders that belong to other customers.Each line does a distinct job:
- Step 1 sets a precondition. The agent should not call the action without an order number, so it collects one first.
- Step 2 names the action and its input. This connects the instruction to a specific entry in the topic's action list.
- Step 3 handles a failure result. Without it, the agent has to improvise when the action returns nothing useful.
- Step 4 handles the normal result and limits the reply length.
- Step 5 is a guardrail. It states a prohibition rather than a step.
The order matters because steps 1 to 4 describe a sequence in time. The guardrail is not part of the sequence, so it comes last.
Instructions guide the model, they do not execute
Instructions are read by a large language model. They are not code. The agent interprets them, and interpretation can vary. Keep three points in mind.
First, instructions influence behavior but do not guarantee it. A model usually follows a clear instruction, but it may deviate when the request is unusual or when instructions conflict. For rules where a failure is costly, add enforcement outside the instructions. Examples are permissions on the data, or a user-mode query in an Apex action so field and object access still apply.
Second, the agent can only use what it has. An instruction that says "Use the Get Order Status action" works only if that action is added to the topic. If the name in the instruction does not match the action's label, the agent may skip it or pick another action. Use the exact action label.
Third, the agent reasons from the whole conversation. A customer who gives an order number in their first message should not be asked for it again. Step 1 says "if they have not given one" for this reason. Instructions should state the condition under which a step applies.
Common failure patterns
These problems appear often when a topic is first tested.
Instructions that restate the classification description. A first instruction such as "Help customers with order status" adds nothing, because the topic was already chosen. Start with the first real step.
Conflicting instructions. Suppose one line says "Always confirm the order number before looking it up" and another says "Look up the order immediately." The agent has to pick one, and different conversations may resolve it differently. Read your instructions together and remove contradictions.
Missing result handling. Instructions that say how to call an action but not what to do with each result leave the agent guessing. List the outcomes you expect, such as found, not found, or an error, and say what to do for each.
Vague wording. "Be helpful when the status is unclear" cannot be tested. "If the status is 'On hold', tell the customer the order is on hold and that support can explain why" can be.
Too many instructions. Long lists dilute the important lines. If a topic needs dozens of rules, it probably covers more than one job and should be split into two topics with distinct scopes.
Behavior outside the scope. If instructions tell the agent to cancel an order but the scope says it cannot change orders, the topic contradicts itself. Keep instructions inside the limits the scope sets.
Choosing what to write
Before adding an instruction, ask whether the agent would get this wrong without it. If the model would behave correctly by default, such as greeting politely, the instruction costs space and adds a chance of conflict. Write instructions for the places where your business needs something specific:
- Required information before an action runs.
- The order of actions when one result feeds another.
- Handling of each action outcome.
- Exact wording or limits, such as "one sentence".
- Prohibitions that matter to your business.
When you edit instructions in Agentforce Builder, change one thing at a time and test again. If you rewrite five lines and the behavior improves, you will not know which edit helped. Testing and refining gets its own chapter later.
Quick reference
- Instructions are used after topic selection, not during it.
- They apply only inside their own topic.
- They are guidance for a language model, so add hard enforcement where the stakes are high.
- Name actions by their exact label.
- State conditions ("if they have not given one") and handle each result.
- Keep them inside the topic's scope.
Exercise
A customer asks, "Can you cancel my order 10442?" The Order Status topic has the scope "look up the status of an existing order and report it. You cannot change or cancel orders." The agent still tries to cancel because one instruction says "Do whatever the customer asks about their order." Which part of the topic should you change, and why?
Show answer
Change the instructions. The topic was selected correctly (the request is about an existing order) and the scope is already clear, so the fault is the instruction that contradicts it. Replace that line with something specific, such as "If the customer asks to change or cancel an order, tell them you can only report order status." Editing the classification description would not help, because topic selection is not the problem.
Exercise
Look at these two instructions in one topic: "Always ask for the customer's email before looking up an order" and "Use the Get Order Status action as soon as you have an order number." Describe the problem and give a rewrite.
Show answer
They conflict. If the customer gives an order number, the first line says to ask for an email and the second says to run the action immediately, so the agent's behavior will vary between conversations. Decide which rule you want, then write one ordered sequence. For example: "1. Ask for the order number if it was not given. 2. Use the Get Order Status action with that order number." Drop the email step unless the action actually needs the email as an input.