Sub topic 10
Testing and Debugging the Template and the Agent
This chapter assumes you have built a prompt template in Prompt Builder and added it to a topic as an action. It also assumes you know basic Salesforce record access. You will test in two places, because a wrong answer can come from the template or from the agent.
Test in two layers
Prompt Builder tests the template alone. Agent Builder tests the whole agent: topic selection, action selection, input mapping, and the final reply. Test the template first. If the template is wrong, every agent test above it fails for the same reason.
| Layer | Tool | Question it answers |
|---|---|---|
| Template | Prompt Builder preview | Does this record produce a good prompt and a good response? |
| Agent | Agent Builder conversation preview | Does the agent pick the right topic and action, and pass the right input? |
Test the template in Prompt Builder
In the template's workspace, select a record for each input (for example, one Case) and run the preview. The preview shows two things you should read separately:
- The resolved prompt, which is the template text after merge fields are replaced with real values.
- The model response to that resolved prompt.
Always read the resolved prompt first. Most template bugs are visible there.
Typical symptoms and causes:
- A blank value after a label, such as
Description:with nothing after it. The field is empty on that record, or the running user cannot see it. - The merge field text appears literally. The field reference is misspelled or the input name does not match.
- The response invents facts. The template does not tell the model what to do when data is missing.
- The response ignores a rule. The rule is buried or contradicts another line.
Preview with at least three records: a complete one, one with empty fields, and one with unusually long text. The empty-field case checks your "say it is unknown" rule.
Case number: 00001026
Subject: Router keeps rebooting
Status: Working
Description:
Rules:
- Use at most five sentences.
- Use only the information above. If something is missing, say it is unknown.A good response to this resolved prompt says the description is unknown. If the model fills one in, tighten the rule. For example, add "Never guess the cause of the problem."
Test the agent in Agent Builder
Open the agent and use the conversation preview. Send realistic user messages, not the wording you wrote in the topic. For the case hand-off topic, try:
- "Summarize case 00001026 for my call."
- "What's going on with that router case?" (no case number)
- "Create a case for me." (out of scope)
Expected behavior: the first calls the action. The second asks for the case number. The third does not call the action and does not use the Case Hand-off topic.
Use the preview's reasoning or plan details, where your org shows them, to see which topic was chosen, which action ran, and what inputs it received. This tells you where the failure is.
Diagnose common failures
| Symptom | Likely cause | Fix |
|---|---|---|
| Agent answers without calling the action | Instructions do not say when to use it | Name the action in an instruction |
| Wrong topic runs | Overlapping classification descriptions | Narrow descriptions and scope |
| Action runs with a wrong or missing record | Input not collected or mapped | Add an instruction to ask for the case number |
| Agent rewrites the output and changes facts | No instruction on output handling | Tell it to return the output unchanged |
| Works in preview, fails for another user | Different field or record access | Test as that user's profile and permission sets |
Change one thing at a time
Fix one cause, rerun the same message, and compare. If you edit the topic and the template together, you will not know which change helped. Keep a short list of test messages and expected outcomes so you can rerun them after every change.
Exercise
In the agent preview, the user asks for a case summary and the reply contains a made-up cause for the problem. The action ran with the correct case. Where do you look first, and why?
Show answer
Open the template in Prompt Builder and preview it with that case. Read the resolved prompt to check that the fields are filled. Then check whether the rules tell the model to say "unknown" for missing data and not to guess causes. Because the action ran with correct input, topic and mapping are not the problem.