Sub topic 1
The Monitor-and-Improve Loop
Prerequisites
This chapter assumes you have:
- Basic familiarity with Salesforce setup and Agentforce concepts: agents, topics, actions, and instructions.
- Built or edited a simple agent in Agentforce Builder.
- A working idea of what an LLM prompt is and what grounding means (supplying trusted data so the model answers from facts instead of guesses).
- Comfort with basic rates and counts, such as percentages and group-by summaries.
Later chapters cover each stage in detail. This one gives you the overall model so the rest has a place to attach.
Why an agent needs a loop
An Agentforce agent is not finished when you activate it. Its behavior depends on a language model reading your topic descriptions, instructions, and action descriptions, then choosing what to do. You cannot predict every phrasing a customer will use. Real conversations will find the gaps in your configuration.
The practical answer is a repeatable cycle: watch what the agent does, find the cause of the problems, change one thing, check that the change works, and release it. Teams that skip the cycle tend to fall into one of two patterns:
- Guess-and-edit. Someone hears about a bad answer, rewrites an instruction, and activates it. Nobody knows whether the fix worked or whether it broke another topic.
- Set-and-forget. The agent ships, nobody reads a conversation, and quality drifts as products, policies, and customer language change.
The loop replaces both with evidence at the start and evidence at the end.
The five stages
The loop has five stages: monitor, diagnose, change, test, and release. After release you monitor again, so the loop never ends.
| Stage | Question it answers | Typical evidence or tool |
|---|---|---|
| Monitor | Is the agent healthy, and where does it look unhealthy? | Usage analytics, resolution and escalation rates, user feedback |
| Diagnose | Why did a specific conversation go wrong? | Session records, message transcripts, the reasoning trace |
| Change | What is the smallest edit that fixes the cause? | Topic descriptions, instructions, action descriptions, grounding data |
| Test | Does the fix work, and did it break anything else? | A regression test set built from real conversations |
| Release | Did the metrics move after the new version went live? | Before and after metric comparison |
Exact screen and feature names change between Agentforce releases. Check your org's current documentation for where each capability lives. The stages stay the same.
What each stage depends on
Monitor
Monitoring starts with data the platform records about conversations: sessions, the messages inside them, and the steps the agent took to produce each reply. It also uses the audit and feedback data from the Einstein Trust Layer. You combine that data with metrics you chose in advance, such as resolution rate, escalation rate, and customer feedback signals.
Metrics tell you where to look. They do not tell you why something failed. A high escalation rate on one topic is a pointer, not a diagnosis.
Diagnose
Diagnosis means reading individual conversations and their reasoning trace. The trace shows which topic the agent selected, which action it chose, and what inputs it passed. You are looking for the earliest wrong decision. A wrong answer often comes from a wrong topic choice several steps earlier.
Once you find the cause, classify it. Common categories are a topic problem, an action problem, an instruction problem, a grounding or data problem, and a guardrail problem. The category decides which kind of change you make.
Change
Make the smallest edit that addresses the diagnosed cause. If the agent used the wrong topic because two descriptions overlap, fix the descriptions. Do not add ten new instructions to compensate. Small, single-cause changes are easier to test and easier to undo.
Test
Before you activate anything, run the changed agent against a regression test set. This is a saved collection of utterances with the expected topic, action, and response behavior. The best test cases come from real failed conversations, so each one proves that a known problem stays fixed.
Release and validate
Release the new version, then compare the same metrics you used in the monitor stage over a comparable period. If the target metric did not move, the diagnosis or the fix was wrong. Return to the diagnose stage.
A worked pass through the loop
Suppose a retail agent has two topics, Order Status and Returns.
- Monitor. The weekly review shows a rising escalation rate. Grouped by topic, most escalations come from Order Status, which should be a simple topic.
- Diagnose. You open several escalated sessions. In each one, the customer asks to send an item back, such as "I want to send back the shoes I bought last week." The reasoning trace shows the agent selected Order Status instead of Returns. The Order Status topic description reads "Handle questions about orders," which also describes returns.
- Classify. This is a topic scoping problem, not an action or grounding problem. The order lookup action worked correctly. It was just the wrong thing to run.
- Change. You narrow the topic description and add an explicit exclusion and fallback:
Handle questions about the status, tracking, and delivery date of an existing order. Do not handle returns, refunds, or cancellations.- Test. You turn the failed conversation into a test case: the utterance above, expected topic Returns, and an expected response that asks for the order number or return reason without giving a delivery date. You run it together with your existing test cases, including normal order-status questions, to confirm they still pass.
- Release and validate. You activate the new version. Over the next comparable period you check that Order Status escalations fell and that Returns conversations are now handled in the Returns topic. You also check that overall resolution rate did not drop.
Each stage produced something the next stage used: a pointer, a cause, a change, a test result, and a before and after comparison.
Rules that keep the loop honest
- Write down the metric before you change anything. Otherwise it is easy to pick a flattering number afterward.
- Change one cause at a time. If you edit three things and the metric improves, you do not know which edit helped.
- Compare like with like. Weekday and weekend traffic, seasonal peaks, and a new product launch can all move a rate without any change on your part. Compare comparable periods and note anything else that changed.
- Check for side effects. Topic descriptions compete with each other. Narrowing one can push traffic into another, so test neighbors as well as the target.
- Handle conversation data with care. Real conversations contain customer information. Reviewing them needs the same access control and privacy discipline as any other customer data. A later chapter covers this.
Common errors
- Treating a metric as a diagnosis. A low resolution rate does not say whether the cause is instructions, actions, or data. Read conversations before you edit.
- Fixing the symptom in the last step. If the agent chose the wrong topic, rewriting the response wording will not help. Find the earliest wrong decision in the reasoning trace.
- Reviewing only complaints. Conversations that were marked resolved can still contain wrong answers. Sample some successful sessions too, or you will only learn about failures customers bothered to report.
- Skipping tests because the change is small. One-line description edits can change topic routing for many utterances.
- Never going back to monitoring. A release is not the end. The validation step is the start of the next monitoring pass.
Exercise
In the worked example, the escalation rate rose for Order Status, and the trace showed the agent chose Order Status for return requests. Which stage of the loop does reading the trace belong to, and why is it not enough to simply rewrite the agent's reply wording?
Show answer
Reading the trace belongs to the diagnose stage. Rewriting the reply wording would not help because the earliest wrong decision was topic selection. The agent ran the wrong topic's logic, so the fix has to be in the topic descriptions, not in the final response.
Exercise
A teammate edits two topic descriptions and one action description in a single release, and the resolution rate improves by four points. Name two problems with relying on this result, and describe what you would do differently.
Show answer
First, with three changes at once you cannot tell which one caused the improvement, and one of them may have hurt while another helped. Second, without comparing comparable periods and checking a regression test set, the improvement could come from traffic changes. Instead, change one diagnosed cause at a time, run the full regression set before release, and compare the same metrics over a comparable period.