Sub topic 16
Running the Loop as a Routine
This chapter assumes you have built a simple agent in Agentforce Builder and know topics, actions, and instructions. It also assumes you can read rates and group-by summaries. Earlier chapters covered each step of the monitor, diagnose, change, test, and release loop. This chapter covers how to run those steps on a schedule, so improvement keeps happening after the first round of fixes.
Why a one-time cleanup is not enough
An agent changes in production even when nobody edits it. Customers ask new questions. Products, policies, and knowledge articles change. Connected data and flows change too. A fix that worked in March can stop working in June because a knowledge article was rewritten or an action's backing flow was edited by another team.
A routine makes this drift visible early. It also keeps the work small. Reviewing 20 conversations every week is easier than auditing 2,000 after a complaint.
The loop has five steps. The routine assigns each one a rhythm, an owner, and an output.
Set a cadence
Different checks need different frequencies. A daily look catches breakage. A monthly look catches slow drift. The table below is a starting point. Adjust it to your conversation volume.
| Cadence | Activity | Output |
|---|---|---|
| Daily | Glance at the dashboard for sudden changes in volume, escalation rate, or errors | A flag raised to the owner, or nothing |
| Weekly | Review a sample of sessions, with extra weight on escalated and negatively rated ones | A short list of classified failures |
| Every two weeks or monthly | Make changes, run the regression set, release | A new agent version and a change note |
| Quarterly | Revisit success metrics, topic list, and access to conversation data | Updated targets and a cleaned-up review process |
Low-volume agents can drop the daily check and review weekly. High-volume agents may need an automated alert instead of a manual glance.
Assign owners
A routine fails when everyone assumes someone else is watching. Name a person for each role. One person can hold several roles on a small team.
- Agent owner. Decides what to change and approves releases.
- Reviewer. Reads sampled conversations and classifies failures.
- Builder. Edits topics, instructions, actions, and grounding.
- Data steward. Controls who can see conversation data and for how long.
The reviewer and builder should be able to talk to each other directly. Most wasted effort comes from a reviewer describing a problem in vague terms ("the agent seems off") that the builder cannot act on.
Sample deliberately
You cannot read every conversation. Choose a sample that finds problems quickly. Mix three kinds:
- Escalated sessions. The agent gave up or was told to hand off. These show the gaps the agent already knows about.
- Low-feedback sessions. Customers rated the response poorly, or a thumbs-down was recorded.
- Random resolved sessions. The agent claims success. A random sample checks that "resolved" means what you think it means.
The third group matters because a rising resolution rate can hide wrong answers. If the agent closes a session without a handoff, the data may count it as resolved even when the customer left unhappy.
Keep a review log
A review log turns individual observations into trends. Each row records one finding. A spreadsheet is enough.
The script below summarizes a week's log. It uses the same kind of group-by summary as earlier chapters, but groups by failure category instead of topic. The field names are illustrative and do not come from an Agentforce schema.
from collections import Counter
# Hypothetical weekly review log. Field names are illustrative.
findings = [
{"session": "s11", "topic": "Returns", "category": "instruction"},
{"session": "s14", "topic": "Returns", "category": "topic_selection"},
{"session": "s19", "topic": "Order Status", "category": "action"},
{"session": "s23", "topic": "Returns", "category": "topic_selection"},
{"session": "s27", "topic": "Billing", "category": "grounding"},
]
by_category = Counter(f["category"] for f in findings)
by_topic = Counter(f["topic"] for f in findings)
print("Findings by category:", by_category.most_common())
print("Findings by topic:", by_topic.most_common())
top_topic, count = by_topic.most_common(1)[0]
print(f"Review {top_topic} first ({count} of {len(findings)} findings).")Run against this log, it reports that Returns has three of five findings. Two of those are topic-selection errors, so the next change is probably a topic description rewrite, not a new action.
Counting findings over several weeks shows whether a fix held. If "topic_selection" findings for Returns drop from three a week to zero after a release, the change worked. If they come back a month later, something upstream changed.
Keep the regression set growing
The regression test set is your safety net. Each routine pass should add to it.
- Turn every confirmed failure into a test case before you fix it. Record the utterance, the expected topic, the expected action, and the expected response behavior.
- Run the test fails first. A test that passes before the fix does not prove the fix.
- Tag each case with the failure category and the date. When a test starts failing later, the tag tells you what kind of regression it is.
- Remove or rewrite cases when policy changes on purpose. A stale test that demands an old return window will block good releases.
Test case: Cancellation request is not handled by the order status topic
Date added: 2026-11-24
Category: topic_selection
User utterance: Please cancel the order I placed this morning.
Expected topic: Cancellations
Expected action: none until the order number is confirmed
Expected response: Asks for the order number, does not give a delivery date.Run the full set before every release. Also run it when something upstream changes, even if you did not edit the agent. Examples are a knowledge article rewrite, a flow edit, or a platform release.
Compare before and after
Every release needs a before-and-after comparison, and the comparison needs a fixed window. Compare the two weeks before a release with the two weeks after, and keep the traffic mix in mind. If a seasonal sale changed the question mix, a drop in resolution rate may reflect different questions rather than a worse agent.
Check three things:
- The metric you aimed at moved in the right direction. For example, escalations in the target topic fell.
- Neighboring metrics did not get worse. Narrowing a topic can push questions into another topic and raise its escalation rate.
- The sample you reviewed by hand agrees with the numbers. If the dashboard says resolution improved but sampled sessions look the same, question the metric.
Write a one-paragraph change note for each release: what changed, which failure it targeted, test results, and the metric you expect to move. The note is what lets a new team member, or you in six months, understand why the agent behaves as it does.
Common problems with routines
- The sample is always the same kind. If you only read escalations, you never learn about confident wrong answers.
- No one owns the log. The log is filled in for two weeks, then abandoned.
- Releases bundle many changes. If you change three topics and one action at once, you cannot tell which change moved the metric. Release small sets, or at least keep the change note specific.
- Review access grows without control. Reviewers accumulate access to customer conversations. Revisit who can see conversation data each quarter, and remove access that is no longer needed.
- Metrics never change. If the agent's job changes, for example it starts handling billing, the old success metrics may no longer fit. Revisit them quarterly.
A sample month
A concrete schedule shows how the pieces fit.
- Week 1. The reviewer samples 20 sessions: 8 escalated, 6 low-rated, 6 random resolved. Findings go in the log.
- Week 2. The reviewer repeats the sample. The owner reads both weeks of the log and picks the two most frequent failure patterns.
- Week 3. The builder edits the affected topic descriptions or actions. Each failure becomes a regression test. The full set runs, and the results go in the change note.
- Week 4. The owner approves and releases. The team starts the two-week comparison window and keeps reviewing samples as normal.
At the end of the next cycle, the owner compares metrics and decides whether to keep, adjust, or roll back the change.
Exercise
Your weekly review log shows five findings for the Returns topic, and four of them are "topic_selection" failures where returns questions went to the Order Status topic. Which change do you make first, and how do you confirm after release that it worked?
Show answer
Start with the topic descriptions. Narrow the Order Status description to say it covers status, tracking, and delivery date, and say it excludes returns, refunds, and cancellations. Add each failed utterance to the regression set with the expected topic Returns, and confirm the tests fail before the change and pass after it. After release, compare the two weeks before and after. The topic_selection findings for Returns should fall, the escalation rate for Returns should drop, and the Order Status escalation rate should not rise. Also check a sample of sessions by hand.
Exercise
Resolution rate rose from 62% to 71% the week after a release, but the sampled sessions look unchanged. What do you check before declaring success?
Show answer
Check whether the mix of questions changed (for example, a sale brought many easy order-status questions), whether the change altered how sessions are counted as resolved (for example, fewer handoffs recorded rather than more problems solved), and whether a random sample of "resolved" sessions shows correct answers. Compare the same windows on the same topics. Only credit the release if the targeted failures fell and the sampled sessions agree.