Sub topic 1
What You Are Testing: Topics, Instructions, and Actions
Prerequisites
This chapter assumes you have:
- Basic familiarity with Salesforce and the Setup menu.
- A Salesforce org with Agentforce enabled and access to Agentforce Builder.
- A basic idea of what an AI agent is: software that reads a request in natural language, decides what to do, and then does it or replies.
- An agent with at least one topic and one action. It can be a draft that you have not activated.
You do not need to have run a test conversation yet. This chapter explains what you are checking when you do. Later chapters cover the preview panel itself.
Why learn the parts before you test
A test conversation in Agentforce Builder shows you a reply. The reply alone rarely tells you what to fix. If the agent answers wrongly, the cause could be any of these:
- It picked the wrong topic.
- It picked the right topic but ignored an instruction.
- It called an action with a wrong or missing input.
- It called the right action, and the action returned something unexpected.
- It never called an action at all.
Each cause has a different fix, in a different place. If you know the building blocks, you can sort a failure into one of these groups quickly. That is most of what debugging an agent consists of.
The building blocks
An agent is a bundle of a few kinds of configuration. The exact labels in the builder change between releases, so treat the names below as concepts and check what your org shows.
| Block | What it is | What it controls |
|---|---|---|
| Agent-level settings | The agent's role, company context, and tone, plus the instructions that apply everywhere | The overall personality and the rules that hold in every topic |
| Topic | A category of request the agent can handle, such as order status | Whether the agent treats a request as in scope, and which instructions and actions apply |
| Instructions | Natural-language directions inside a topic | The order of steps, the conditions for using an action, and the wording and limits of replies |
| Action | A capability that does real work, such as a Flow, an Apex method, or a prompt template | Reading or changing data, or generating content, with defined inputs and outputs |
The agent's reasoning engine, a large language model working in a loop, connects these blocks. It reads the user's message, decides which topic applies, reads that topic's instructions, and decides whether to call an action or reply directly.
Topics
A topic has a name, a description that the engine uses to classify requests, and a scope. The scope states what the topic does and does not handle. It also has instructions and a list of actions that belong to it.
The classification description is the part you will edit most often after testing. The engine compares the user's message with the descriptions of all topics, so a description works as a routing rule. Two properties make descriptions fail:
- They are vague. "Handles customer questions" matches nearly everything, so it competes with every other topic.
- They overlap. If "Order Status" and "Returns" both mention "your order", requests like "I want to return my order" can land in either.
Requests that match no topic go to a fallback behavior. Depending on your configuration, this is a default off-topic response or a general handling topic. Check what your agent does here, because out-of-scope messages are some of the most important test cases.
Instructions
Instructions are plain-language directions that the engine reads while it is working inside a topic. They tell it how to behave, for example:
- Ask for the order number if the customer has not given one.
- Look up the order before you state a status.
- Never share information about orders that belong to someone else.
- Offer a return only if the order was delivered within 30 days.
Instructions are guidance for a language model, not code. The engine follows them most of the time, but it does not execute them exactly like a program does. This has three practical consequences for testing:
- You must test the same instruction with several phrasings of the request, not once.
- An instruction that is ambiguous will produce inconsistent behavior, and you can see that only by repeating tests.
- A rule that must never be broken, such as a permission check, should not rely on instructions alone. Put it in the action (for example, in the Flow or Apex that enforces sharing and field access), and use the instructions to explain it.
Actions
An action is the part that touches data or produces content. Each action has:
- A name and a description. The engine uses the description to decide when the action is relevant, just as it uses a topic description to route a request.
- Inputs, which are the values the action needs, such as an order number.
- Outputs, which are the values it returns, such as a status and a delivery date.
Several kinds of target can back an action, including Flows, Apex classes, and prompt templates. For testing, the kind matters less than the contract: what goes in, what comes out, and what happens when the input is missing or wrong.
The engine fills inputs from the conversation. If a user writes "Where is my order 00012345?", the engine can extract the order number and pass it in. If the user writes "Where's my stuff?", there is nothing to extract. A well-built agent asks a follow-up question. A poorly configured one may call the action with an empty or invented value. Watching for this is part of testing actions.
How one turn flows
Each user message goes through the same sequence. The diagram shows it for an order-status request.
Each arrow is a place where a test can fail:
- Message to topic. The wrong topic, or no topic, is selected.
- Topic to instructions. The right topic is selected, but its instructions are incomplete or contradict each other.
- Engine to action. The wrong action is chosen, or the right action receives wrong inputs.
- Action to engine. The action fails or returns data the engine does not use well.
- Engine to user. The data is correct, but the reply breaks a tone or content rule.
The preview panel and its reasoning trace let you see these steps. You can then say which arrow broke, instead of only saying that the answer was wrong.
Mapping symptoms to causes
When a test fails, start with the symptom and look at the most likely cause first.
| What you see in the reply | Most likely cause | Where to look first |
|---|---|---|
| The agent says it cannot help with a request you built a topic for | The topic description or scope does not match how the user phrased it | Topic classification description and scope |
| The agent answers from general knowledge instead of looking something up | No action was called, because the instructions or the action description did not make the action relevant | Topic instructions and action description |
| The agent answers in the wrong topic's style or applies the wrong rules | An overlapping topic won the classification | Descriptions of both topics |
| The agent asks for information you thought it already had | The action's input is marked as needed and the conversation had no value for it | Action inputs and instructions on collecting them |
| The agent states a wrong value | The action returned unexpected data, or the engine summarized it badly | The action's output, then the instructions about the reply |
| The agent agrees to something you forbade | The rule is missing, vague, or only in instructions | Instructions, and the action's own enforcement |
This table gives hypotheses, not verdicts. The reasoning trace, covered in a later chapter, is how you confirm which one is true.
A worked example: the order-support agent
The rest of this tutorial uses a hypothetical order-support agent. Here is its configuration, written as plain text so you can see everything at once.
Agent role: Order support assistant for an online shoe store.
Tone: Friendly and brief.
Topic: Order Status
Classification description: Customer asks where an order is,
whether it has shipped, or when it will arrive.
Scope: Reads order status only. Does not change orders.
Instructions:
1. If the customer has not given an order number, ask for it.
2. Use Look Up Order before stating any status.
3. Report only the status and the delivery date.
Actions: Look Up Order (input: order number; output: status, delivery date)
Topic: Returns
Classification description: Customer wants to return or exchange
an item they have received.
Scope: Explains the return policy and starts a return. Does not
handle refunds that were already issued.
Instructions:
1. Confirm the order was delivered within the last 30 days.
2. If it was not, explain the policy and do not start a return.
Actions: Start Return (input: order number, item; output: return label)Think about what this configuration lets you test, and where it is weak.
- "Where is my order 00012345?" should go to Order Status and call Look Up Order with
00012345. That is the plain case. - "I want to return the shoes I bought last week" should go to Returns. The phrase "bought last week" suggests the 30-day check applies. Does the agent know the order number? Instruction 1 requires a delivery check, but no instruction says to ask for the order number first. That is a gap in the instructions, and a test would expose it.
- "Can you change the shipping address on my order?" matches neither topic's scope. Order Status says it does not change orders. Whether the agent declines clearly, or wrongly lands in Order Status, is a result you can only learn by testing.
- "What's the weather like today?" is out of scope for everything. The agent should decline politely.
None of these cases needs a deployed agent. They all depend on the three blocks in this chapter: whether topics route correctly, whether instructions are complete, and whether actions get the right inputs.
Writing instructions that can be tested
You will revise instructions many times. Some habits make them easier to test:
- Make each instruction check a single condition. "Ask for the order number, confirm the delivery date, and offer a return" is three behaviors. If one fails, you cannot tell which.
- Name the action and the condition. "Use Look Up Order before stating any status" can be checked in a test. "Be accurate about orders" cannot.
- State limits positively when you can. "Report only the status and the delivery date" is easier for the engine to follow, and for you to test, than a long list of banned details.
- Keep instructions inside the topic where they apply. A rule placed at the agent level applies to every topic, which makes failures harder to trace.
- Avoid contradictions between topic scope and instructions. If the scope says "does not change orders" and an instruction describes changing an address, the outcome will vary from run to run.
Common errors when starting to test
- Testing only the happy path. Every agent handles "Where is my order 00012345?" well. Problems show up with vague, misspelled, multi-part, or out-of-scope messages.
- Changing several things at once. If you edit a topic description, two instructions, and an action in one pass, a passing result will not tell you which edit helped.
- Treating one pass as proof. Language-model behavior can vary between runs. A request that works once may fail on the third try, so repeat important tests.
- Blaming the action when the topic is wrong. If the agent did not call the action, the action may be fine. Check routing before debugging the Flow.
- Testing an action with data that does not exist. A "not found" reply from an action looks like a failing agent but is a data problem. Know which records you can use.
- Assuming the preview shows what customers will see. The preview is a testing surface. Channel, user permissions, and data in a deployed setting can differ. A later chapter covers deployment checks.
What you will do in the following chapters
With these definitions in place, the rest of the tutorial follows one loop: open the preview, send a test message, read the trace, find which block failed, change that block, reset, and test again. Each step in the loop corresponds to a block in this chapter. A topic problem is fixed in the topic description or scope. A step-order problem is fixed in the instructions. An input problem is fixed in the action definition or in the instructions that tell the agent how to collect that input.
Exercise
A customer writes "I need to send back the shoes I got last Tuesday." The agent replies with the order's shipping status instead of starting a return. Name the two blocks you would check first, and say what you would look for in each.
Show answer
Check the topic descriptions first, specifically Order Status and Returns, for overlap. The Order Status description may be broad enough to match any message that mentions an order, or the Returns description may not mention phrases like "send back". Then check the Returns topic's scope and instructions to see whether they cover the customer's wording. The action is probably not the problem, because the wrong action ran, which points to a routing error.
Exercise
The agent calls Look Up Order for the message "Where's my stuff?" and the action fails. Which block is most likely at fault, and what change would you make?
Show answer
The instructions and the action's input definition. The message contains no order number, so the engine had nothing to pass, and the topic instructions do not make it ask first. Add an instruction such as "If the customer has not given an order number, ask for it before calling Look Up Order", and confirm that the order number input is marked as required.
Exercise
Why should a rule such as "never reveal another customer's order" be enforced in the action as well as in the instructions?
Show answer
Instructions guide a language model and are not guaranteed to be followed in every run. An action backed by a Flow or Apex enforces access in code, so the rule holds even when the engine misreads or ignores an instruction.