Sub topic 6
Checking That Actions Run with the Right Inputs
This chapter covers the step after topic selection: confirming that the agent runs the correct action and fills in its inputs correctly. It assumes you can open the conversation preview in Agentforce Builder and start a test conversation. It also assumes you have an agent with at least one topic and one action, and that you know how topic classification works. You should be comfortable with the Salesforce Setup menu. You should also have a basic idea of what an AI agent is.
Why actions deserve their own check
A topic decides what the agent is trying to do. An action is what the agent does. In Agentforce, an action is a unit of work the agent can call, such as a Flow, an Apex method, or a prompt template. Actions look up records, create or update data, and generate text.
An agent can pick the right topic and still fail. It may call the wrong action, or call the right action with a wrong or missing input. It may also skip an action and answer from its own language ability, which produces a reply that sounds plausible but isn't backed by data.
Each of these failures looks different in the preview, and each has a different fix. Checking actions separately from topics lets you find the cause faster.
What an action needs to run
Every action has a definition that the agent reads before it decides to use it. The parts that matter for testing are listed below.
| Part | What it is | Why it matters in testing |
|---|---|---|
| Name and description | Text that tells the agent what the action does | The agent uses it to decide whether the action fits the request |
| Inputs | Named values the action needs, such as an order number | The agent must find or ask for each required input |
| Outputs | Values the action returns | The agent uses them to write its reply |
| Instructions for inputs | Optional guidance on how to fill an input | Controls formatting and when to ask the user |
| Required flag | Whether the input must have a value | A required input with no value should make the agent ask a question |
The action's name and description guide action choice. The topic's instructions guide when the action should be used. Both are text that the agent reads, so both are things you can change after a failed test.
How the agent runs an action
When a user message arrives, the agent works through several steps in order.
- It selects a topic.
- It reads the actions that belong to that topic.
- It decides whether an action fits the request.
- It collects the inputs. Each input can come from the user's message, from earlier in the conversation, or from context such as the signed-in user's record.
- If a required input is missing, it asks the user.
- It runs the action and receives the outputs.
- It writes a reply based on the outputs and the topic's instructions.
Each box in this diagram is a place where a test can fail. The rest of the chapter shows how to check each one.
Testing an action in the preview
Use the order-support agent from the earlier chapters. It has an Order Status topic with an action named Look Up Order. That action takes one required input, the order number.
Start with the typical request from your test set:
Where is my order 00012345?Send it in the preview. Then check three things.
- Did the action run? The reasoning trace should show the Look Up Order action being selected and run. If you see only a reply and no action, the agent answered without data.
- Were the inputs right? The trace shows the value passed to each input. The order number should be
00012345, with no extra characters, and the leading zeros should be intact. - Does the reply match the outputs? The status in the reply should match the status the action returned. In simulated mode, the output is generated, so compare against the example you set. In live mode, compare against the real record.
Record the result with the test template from the plan:
Test: "Where is my order 00012345?"
Expected topic: Order Status
Expected action: Look Up Order (input: order number 00012345)
Expected reply: States the order's current status
Result: pass or fail
Notes: If it fails, record the topic and action shown in the reasoning trace.Include the input value in the expected action line. A test that only says "action runs" passes even when the input is wrong.
The input checks that find the most bugs
Most input problems fall into a few patterns. Write one test for each pattern that applies to your action.
The input is in the message
The user supplies the value in the first message. The agent should extract it exactly. Watch for these errors:
- Leading zeros dropped, so
00012345becomes12345. - Extra words included, such as
order 00012345passed as the whole value. - A different number picked, when the message holds two numbers, such as an order number and a date.
Test the last case with a message like this:
I ordered on 3 March, and order 00012345 has not arrived.The value passed to the order number input should still be 00012345.
The input is missing
The user does not give the value. The agent should ask for it and should not invent one. Send this:
Where is my order?A correct run shows the agent asking for the order number, and the action does not run yet. If the trace shows the action running with a made-up or empty value, the input is not marked as required, or the instructions do not tell the agent to ask.
The input comes from earlier in the conversation
Test whether the agent reuses a value that the user gave before. Send two messages in the same conversation:
1. Where is my order 00012345?
2. And when will it arrive?The second message has no order number. The agent should reuse 00012345 from the first message. If it asks again, you may want to add an instruction that tells it to reuse known values. If it reuses a value when the user has switched to a different order, that is a worse bug. Add a third message, such as "What about order 00067890?", and confirm the new number replaces the old one.
The input comes from context
Some inputs should not come from the user at all. For example, an action may need the current customer's ID. The agent should take it from the session context. Check in the trace that the value matches the signed-in or test user. If the agent asks the user for something it should already know, fix the input's source in the action configuration or the instructions.
The input is invalid
The user gives a value in the wrong form:
Where is my order ABC?Decide what you want. You may want the agent to ask again, or to explain the expected format. Whichever you choose, write it into the expected reply, then test it. If the action runs and returns an error, check that the reply is clear and does not show raw error text to the customer.
Choosing the right action when several exist
A topic often has more than one action. An Order Status topic might hold Look Up Order and Track Shipment. The agent picks between them using their names and descriptions.
Write tests that separate the two:
- "Where is my order 00012345?" should use Look Up Order.
- "What carrier has my package?" should use Track Shipment.
- "Where is my package?" is ambiguous. Decide which action you want, then check the agent's choice.
Vague descriptions cause most wrong-action errors. A description like "Gets order data" overlaps with "Gets shipping data." A description like "Returns the current status of an order from its order number" does not.
Actions that change data
Some actions change data, such as one that updates a shipping address. These carry more risk, so test them more carefully.
- Use simulated mode first, so you can check the inputs without changing records.
- Switch to live mode only in a sandbox or with test records.
- Check that the agent confirms the details before it runs the action, if your instructions require that.
- Check that it does not run the action when the request is only a question, such as "Can I change my address after I order?"
Reading action details in the trace
The reasoning trace lists the steps the agent took. For an action, look for four items:
- The action name that was selected.
- The inputs, with their values.
- The outputs returned.
- Any error message.
Compare the inputs and outputs with your expected values. The table below maps what you see to a likely cause and a first fix.
| What you see | Likely cause | First fix |
|---|---|---|
| No action in the trace, but a confident reply | The agent did not think an action was needed | Make the topic instructions say when to use the action |
| Wrong action selected | Overlapping action descriptions | Rewrite the descriptions so they differ |
| Right action, input value altered | Unclear input description | Add input instructions, such as "Keep leading zeros" |
| Right action, empty or invented input | Input not required, or no instruction to ask | Mark it required and add an instruction to ask |
| Action runs twice | Instructions encourage a retry | Review the instruction wording |
| Error returned | Problem in the Flow or Apex, or a permission problem | Test the action outside the agent |
The last row matters. If the trace shows the right action and the right inputs, but the action fails, the agent is working correctly. The fault lies in the action itself. Run the Flow or Apex directly with the same inputs to confirm that. Changing instructions will not fix it.
Simulated and live results are not the same
In simulated mode, the agent does not call the real action. Outputs are generated from the action's definition. A passing simulated test confirms that the agent selected the action and built the inputs. It does not confirm that the action works.
In live mode, the action runs. A passing live test confirms the whole chain, but only for the records you used.
A sound sequence is to settle input handling in simulated mode, then run a smaller set of tests in live mode to confirm the real results.
Fixing and retesting
When a test fails, change one thing at a time. Edit the input instruction, the action description, or the topic instruction. Then reset the conversation and run the same utterance again. A reset clears the earlier messages, so values from the failed run cannot affect the new one. This is important for input tests, because the agent may reuse a value from earlier in the conversation.
Keep failed tests in your set after they pass. They protect against the same bug returning when you change instructions later.
Common mistakes
- Checking only the reply text. A correct-sounding reply can come from an action that ran with wrong inputs, or from no action.
- Testing with one order number. Try numbers with leading zeros, numbers of different lengths, and a message with two numbers.
- Testing missing-input cases in the middle of a conversation. Earlier messages may supply the value. Reset first.
- Treating a simulated pass as proof that the action works.
- Changing several instructions at once, so you cannot tell which change fixed the problem.
Exercise
You send "I ordered on 3 March, and order 00012345 has not arrived." The reasoning trace shows the Order Status topic and the Look Up Order action, and the order number input is 3. The reply says the order was not found. What went wrong, and what is your first change before you retest?
Show answer
The topic and action are correct, so the fault is in input extraction. The agent picked the number from the date instead of the order number. Add an instruction to the order number input, for example "Use the order number, which is eight digits. Do not use dates or quantities." Then reset the conversation and send the same message again. Confirm the trace now shows 00012345.
Exercise
You test "Where is my order?" and the trace shows Look Up Order running with an empty order number, followed by an error. List two changes that would make the agent ask for the number first.
Show answer
Mark the order number input as required, and add an instruction to the topic or input that says to ask the customer for the order number when it is not given. After either change, reset and resend the message. The trace should show no action run and a reply that asks for the number.
Exercise
A teammate says the agent works because every simulated test passed. Give two things the simulated tests did not show.
Show answer
They did not show that the action itself runs without error, because simulated mode does not call the real Flow or Apex. They also did not show that the real outputs match the reply, or that permissions allow the action to read the records. Live tests in a sandbox are needed for those.