Sub topic 14
Testing the Agent and Inspecting Action Calls
This chapter assumes you have added at least one standard action to a topic in Agentforce Builder. It also assumes you know basic Salesforce permissions. You will learn to run a test conversation, read the action trace, and fix common problems.
Why inspect more than the reply
An agent can give a fluent answer even when an action failed or never ran. The reply alone does not show what happened. You need to check three things: which topic was chosen, which actions ran, and what each action received and returned.
Run a test conversation
Open your agent in Agentforce Builder and use the conversation preview panel. Type a request as a real user would. Run the preview as yourself first. Then test with a user who has fewer permissions, because actions run on behalf of the user.
Use a short test script for each topic:
- A request that should match the topic and use an action.
- A request that names a record that does not exist.
- A request that matches two records.
- A request that is out of scope for the topic.
Read the action trace
After each reply, open the interaction details (the plan or trace view in the preview). It lists the steps the agent took. Look for these items:
| Item | What to check |
|---|---|
| Selected topic | Did the request land in the topic you expected? |
| Actions run | Did the expected actions run, in the expected order? |
| Action inputs | Were the values correct, such as the record ID or the field name? |
| Action outputs | Did the result contain the data the reply uses? |
| Final reply | Does the reply match the outputs, with no invented facts? |
Common problems and fixes
- Wrong topic selected. The classification description is too broad or overlaps another topic. Rewrite it so each topic has a distinct scope.
- Action never runs. The topic instructions do not say when to use it. Add a line such as "Use the summary action when the user asks for an overview."
- Wrong input value. The agent guessed. Tell it to run a lookup action first and use that result, or to ask the user when the value is unclear.
- Empty output. The user may lack access to the object or fields. Check the permission set of the test user.
- Reply contains facts not in the output. Tighten the instructions so the agent answers only from action results.
- Update runs without asking. Add an instruction to restate the change and ask for confirmation first.
Change one thing at a time
After each fix, rerun the same script. If you change the topic description and the instructions together, you cannot tell which change helped. Keep the failing request as a regression test and repeat it after later edits.
Exercise
In a test, the agent says "Your account was updated," but the record has not changed. Where do you look first, and what do you check?
Show answer
Open the action trace for that turn. Check whether the update action ran at all, what inputs it received (record ID, field, value), and what it returned. If it did not run, or returned an error, the reply was not based on a real result. Also check that the test user has edit access to the record and field.
Exercise
Why should you test with a user who has fewer permissions than you?
Show answer
Actions run on behalf of the user and respect their access. A user without access to a field or object may get empty or partial results, which you will not see when testing as an administrator.