Sub topic 2
What Agentforce records about a conversation
This chapter assumes you have built a simple agent in Agentforce Builder and know what topics, actions, and instructions are. You should also know that an LLM prompt can be grounded in company data. Data Cloud object names and setup steps change between releases. Treat the names below as a working model and confirm them in your org.
Why the record matters
You can't improve an agent from the final answer alone. A wrong answer might come from the wrong topic, a wrong action, a missing record, or a vague instruction. Each cause needs a different fix. The conversation record shows which one happened.
Agentforce stores a conversation at several levels of detail. Later chapters in this tutorial depend on knowing these levels, so learn them first.
The four levels of a conversation record
Think of one conversation as a tree. The layers below follow the Session Tracing data model that Agentforce writes to Data Cloud. Exact object and field names depend on your release.
| Level | What it represents | Typical contents |
|---|---|---|
| Session | One conversation from start to end | Agent and version, channel, start and end time, how it ended |
| Interaction (turn) | One user request and the agent's handling of it | Which topic was chosen, timing, the overall input and output |
| Step | One unit of work inside a turn | Topic classification, an action call, an LLM call, a grounding lookup |
| Message | Text that was exchanged | The customer's utterance and the agent's reply |
Sessions
A session is the container. It records which agent and version handled the conversation, the channel (for example a messaging window or an embedded service), when it started and ended, and how it ended. An ending might be a normal close, a timeout, or a transfer to a human.
The session is the unit most metrics count. "Resolution rate" and "escalation rate" are usually fractions of sessions, so the way a session ends matters for the metrics chapter.
Interactions
A session holds one or more interactions, often called turns. An interaction begins with a user message and finishes when the agent produces a reply. This is where the agent's first big decision is recorded: the topic it picked for that request.
A single session can touch several topics. A customer might ask about an order and then about a return. Check the topic at the interaction level, not only at the session level.
Steps
Steps are the most useful level for diagnosis. Inside one turn the agent may:
- Classify the request into a topic.
- Decide which action to run.
- Call the action, such as a flow, an Apex method, or a prompt template, with inputs.
- Receive the action's output.
- Call the LLM to compose the reply from instructions, the output, and any grounding data.
Each of these can appear as a step with its own name, inputs, outputs, and result. A step list lets you replay the decision path. The reasoning trace you will read in a later chapter is built from this level.
Messages
Messages hold the text of the conversation. They are the easiest level to read, and they hide the most. A reply that sounds fine can still come from the wrong topic. A poor reply can come from an action that returned an empty result. Always read messages together with steps.
What the record can and cannot tell you
The record shows what the agent did. It does not show why the model preferred one choice over another. You infer the cause by comparing the evidence with your configuration.
- Topic choice. You can see which topic was chosen. You can compare the utterance with that topic's description and with the description of the topic you expected.
- Action choice. You can see whether an action ran, which inputs it received, and what came back.
- Final text. You can see the reply. You can check whether it uses facts that appear in the action output or grounding results.
- Not visible. Anything the agent never received. If a knowledge article was never retrieved, the record shows the missing lookup, not the article's contents.
Where you review it
You will usually meet this data in three places.
- Agentforce Builder preview and testing tools. These show the reasoning for conversations you run yourself. Use them for reproducing a problem and checking a fix.
- Data Cloud. When session tracing is enabled, the session, interaction, step, and message records are stored as Data Cloud objects. You can query them, build reports, and join them to other customer data.
- Agentforce analytics and dashboards. These summarize the same records into counts and trends. A later chapter covers them.
Session tracing is not on by default in every org. It needs Data Cloud and the right permissions. If your org has no traces, enabling them is your first task, because everything after this chapter depends on them.
Working with exported records
Once data is out of the org, a few lines of code can already answer useful questions. The example below uses a hypothetical export. The field names are illustrative and are not an Agentforce schema. It flattens sessions into steps and counts how often each step type fails, which tells you where to look first.
from collections import Counter
# Hypothetical export. Field names are illustrative, not an Agentforce schema.
sessions = [
{
"id": "s1",
"interactions": [
{
"topic": "Order Status",
"steps": [
{"type": "topic_selection", "ok": True},
{"type": "action", "name": "Get Order", "ok": True},
],
}
],
},
{
"id": "s2",
"interactions": [
{
"topic": "Order Status",
"steps": [
{"type": "topic_selection", "ok": True},
{"type": "action", "name": "Get Order", "ok": False},
],
}
],
},
]
failures = Counter()
for session in sessions:
for interaction in session["interactions"]:
for step in interaction["steps"]:
if not step["ok"]:
label = step.get("name", step["type"])
failures[(interaction["topic"], label)] += 1
for (topic, label), count in failures.most_common():
print(f"{topic} / {label}: {count} failed step(s)")Running it prints Order Status / Get Order: 1 failed step(s). The result points at one action in one topic. That is a far narrower starting point than "the agent gives bad answers."
Common mistakes
- Reviewing only the final message. The reply is the last link in a chain. Open the steps before you decide what to change.
- Judging by session topic. A session with several turns may have one wrong turn. Review at the interaction level.
- Assuming a missing trace means nothing happened. If tracing was off or was enabled later, older conversations have no step data. Check the enablement date before you compare periods.
- Mixing versions. The session records which agent version ran. When you compare before and after a change, filter by version, or the numbers blend two different agents.
- Ignoring how sessions ended. A session that timed out is not the same as one the customer closed after getting an answer. Keep the end reason when you compute rates.
How this feeds the loop
The monitor-and-improve loop starts here. Metrics tell you that something is off. Session and interaction records tell you where. Step records tell you why. In the next chapters you will add feedback data, choose metrics, and then read traces in depth. The accuracy of every one of those steps depends on this record being enabled, complete, and filtered by version.
Exercise
A customer asks to send back shoes and the agent replies with a delivery date. At which level of the record would you first confirm that the agent picked the wrong topic, and what would you check next?
Show answer
Check the interaction level, where the chosen topic is recorded for that turn. Then open the steps of that interaction to see which action ran and what it returned. A delivery date suggests an order-status action ran when a returns topic was expected.
Exercise
You compare resolution rates before and after a change, but the "after" period includes sessions from two agent versions. What is wrong, and how do you fix it?
Show answer
The result mixes two agents, so you can't attribute the change to your edit. The session records the agent version, so filter or group by version and compare only sessions from the old version with sessions from the new one.