Test, Trace, and Improve the Grounding
Bu içerik henüz dilinizde mevcut değil.
The question this module answers: How do we know the grounding actually worked, and when it didn’t, where did it fail?
We’ve designed the grounding. Module 1 named the evidence the agent needs. Module 2 chose how it gets each piece: look up the facts you know, retrieve the knowledge you have to find. Module 3 asked whether that evidence is trustworthy:
Relevant · Authoritative · Current · Complete · Permitted · Traceable
All of that is still a design on a whiteboard. Now a different question: how do we know it actually worked?
This is also where the Salesforce platform has moved quickly. As of November 2026, Agentforce can test an agent before it goes live, measure the quality of what retrieval found, trace what happened in a session, trace the Flow and Apex underneath it, and record what went to the model and what came back. As a data architect, you don’t have to become the administrator of every one of those features. But you do have to be able to answer one question when something goes wrong:
Was the problem in the data, the retrieval, the context, the reasoning, or the execution?
Start by testing the evidence, not just the answer
Section titled “Start by testing the evidence, not just the answer”Let’s test the finance agent on the damage claim from module 2. We ask it: should Redrock’s claim on this delivery be credited, and how much? It answers: yes, $180.
Was that a successful test?
We don’t know yet. $180 is the right answer. But what evidence did it use? Did it look up the $900 on the Work Order Line Item? Did it retrieve Redrock’s policy, version 2026-03, section 4? Did it see the photos, and check for an earlier claim on the same delivery?
Or did it retrieve last year’s version of the policy, which also happened to say 20%? Then it reached the right answer for the wrong reason, and next month, when the two versions disagree, it’ll reach the wrong one.
A correct answer doesn’t prove the grounding is correct.
The opposite is true too. A wrong answer doesn’t prove the grounding failed. It might have had perfect evidence and reasoned badly over it. So testing an agent has to look past whether the final answer was right. We test the path that produced the answer.
Agentforce Testing Center
Section titled “Agentforce Testing Center”Agentforce Testing Center is how you evaluate an agent before you rely on it. You keep sets of test cases you can reuse, and you run the agent against them in batch. Each test checks whether the agent chose the subagent and the action you expected and gave an acceptable response. There are measures built in, including a model that judges the answers (“LLM-as-judge”), and you can write your own (Agentic Operational Excellence (opens in a new tab), Salesforce Architects, Well-Architected, checked 2026-11-28; Agentforce Testing Center (opens in a new tab), Salesforce Help, checked 2026-11-28).
For a data architect, the important shift is this: grounding can be tested instead of assumed.
So what goes in the test set? Here’s how I’d start one for the finance agent:
| Test case | What it proves |
|---|---|
| A normal claim, inside the window, with photos | The happy path, with the evidence we expected |
| A claim on day 31 | It reads the window, not just the rule |
| A haul-away item | It got the exclusion, not just the first sentence |
| A second claim on the same delivery | It checks for earlier claims |
| A Redrock claim with Keystone’s policy also in the index | It filters to the right partner |
| A delivery with no photos yet | It says what’s missing instead of deciding |
| The manifest and the portal claim disagree on the price | It uses the source that governs |
| Two policy versions with the same effective date | It escalates instead of choosing one |
Look at that list again. Are those AI tests?
They’re data architecture tests. Each one checks that the design supplies the right evidence under a condition we know happens in the real business.
Test the failure cases you designed for
Section titled “Test the failure cases you designed for”Traditional testing tends to spend most of its time on the happy path. Grounding needs the negative tests on purpose, because every decision in module 3 is a promise about what happens when something goes wrong.
- We said the agent shouldn’t decide when material evidence is missing. So test it with the door photo missing.
- We said the version in effect governs. So put both policy versions in the index and see which one it uses.
- We said Redrock’s agreement governs the price, not the portal claim. So make them disagree: $900 against $1,050.
- We said two versions effective on the same day must go to a person. So create that conflict and check that it escalates.
- We said the claim number is the idempotency key. So send the same claim twice and count the credits.
Checkpoint 3 does the same for the assistant that Recipients talk to: ask it for a time before dispatch confirms one, ask for “the delivery before mine,” change one character of the token. Each one is a line in the test set, run before every release.
A grounding principle that isn’t tested is still mostly an assumption.
Test the architecture decisions, not just how well the agent talks.
Retrieval quality gives us another layer of evidence
Section titled “Retrieval quality gives us another layer of evidence”For the evidence the agent retrieves, Salesforce can measure the quality of what retrieval found. For agents grounded in a knowledge base, Testing Center’s retrieval-quality analysis looks at three things (Agentic Operational Excellence (opens in a new tab), checked 2026-11-28):
- Context relevance: did retrieval supply evidence that’s relevant to the question?
- Answer faithfulness: is the answer supported by the evidence it was given? (Salesforce also calls this groundedness.)
- Answer relevance: does the answer actually address the question?
That lets us ask a much better question than “did RAG work?” Each measure points at a different part of the architecture, and that matters, because the fix is different for each one.
There’s one more measure worth knowing, and Salesforce names it in its Well-Architected guidance: grounding accuracy, the percentage of agent responses that are factually correct when checked against the source data. You sample answers at random and check their claims against the sources. Salesforce’s own threshold: below 95%, there’s a hallucination problem that needs better prompts or better retrieval. And it’s a measure you build yourself; the observability tools give you traces and metrics, but you instrument grounding accuracy on your own (Reliability for the Agentic Enterprise (opens in a new tab), checked 2026-11-28). The 95% is Salesforce’s number, as of November 2026, not mine. What I’d take from it is the habit: someone checks a sample of real answers against the real sources, on a schedule.
Context Relevance — Did we retrieve useful evidence?
Section titled “Context Relevance — Did we retrieve useful evidence?”Someone in finance asks the agent: “Does Redrock’s policy cover a haul-away washer?”
The retriever returns three sections of Redrock’s policy: how to file a claim, where to send it, and the payment terms. All three come from the right document, the right version, the right partner. None of them answers the question. The section on haul-away items never came back.
That’s a context relevance problem. The agent may answer anyway, and badly, but the failure happened before it reasoned at all. So where would I look? The corpus, the metadata and the filters, how the policy was chunked (is the exclusion in its own chunk, with its heading?), how the question becomes a query, and whether keyword search would have found “haul-away” when semantic search didn’t.
And notice what that diagnosis changes. Instead of saying “the AI gave a bad answer,” we can say:
The agent never received the evidence it needed.
That’s something a team can fix.
Answer Faithfulness — Did the model stay with the evidence?
Section titled “Answer Faithfulness — Did the model stay with the evidence?”Now say retrieval returns exactly the right sentence: “Damage reported within 30 days of delivery is credited.” The delivery was completed on November 3. Redrock reported the damage on December 14, say. That’s 41 days.
The agent answers: “This claim is within Redrock’s window and qualifies for a credit.”
The evidence was relevant. The answer wasn’t faithful to it.
That points away from the source data and the retrieval design, and toward how the agent used the evidence it got: its instructions, its reasoning, or a calculation it shouldn’t have been asked to do. And that distinction protects us from changing the wrong part of the architecture. If retrieval keeps supplying the right sentence, redesigning the index won’t fix this.
Answer Relevance — Did we answer the question?
Section titled “Answer Relevance — Did we answer the question?”One more. Finance asks, “Is this claim inside Redrock’s window?” Retrieval finds the right sections. The answer is a careful, accurate summary of Redrock’s whole claim policy: the window, the exclusions, the filing steps, the payment terms. It never says yes or no.
The evidence was good. The answer was even faithful. But it wasn’t relevant to the task. That points toward how the task is framed and how the response is designed, not toward the data.
Put the three together and you get a diagnosis you can start from:
Poor context relevance: look at retrieval and the data architecture.
Good context, poor faithfulness: look at how the agent used the evidence.
Good context, good faithfulness, poor answer relevance: look at the task framing and the response.
Three measures, three different places to look.
Real failures can be messier than three lines. But it’s a much better place to start than calling every bad answer a hallucination.
Session Tracing — What did the agent actually do?
Section titled “Session Tracing — What did the agent actually do?”Testing tells us whether behavior met our expectations. Tracing tells us what actually happened.
Agentforce Session Tracing records an agent’s activity as structured data in Data 360. Its data model includes AIAgentSession, AIAgentSessionParticipant, AIAgentInteraction, AIAgentInteractionStep and AIAgentInteractionMessage (Agentic Operational Excellence (opens in a new tab), checked 2026-11-28; Data Model for Agentforce Session Tracing (opens in a new tab), Salesforce Help, checked 2026-11-28). With those records you can look at a session in much more detail than its final answer: the messages, the steps the agent took, the actions it called, the errors, the order, how long each took.
One thing to plan for. Salesforce Help says Session Tracing is off by default, except in an org with only one data space, where it’s on by default. Where it’s off, someone has to turn it on, and turning it on stores the traces in a data space in Data 360 (Set Up Agentforce Session Tracing (opens in a new tab), Salesforce Help, checked 2026-11-28; Trust for the Agentic Enterprise (opens in a new tab), checked 2026-11-28). So check your org before you need a trace: a trace you didn’t switch on before the bad answer is a trace you don’t have. And the traces are data, in Data 360, with volume, retention and privacy decisions of their own. That’s ours.
This changes the traceability conversation from module 3. Traceability isn’t an abstract requirement we hope someone builds one day. The platform records structured evidence of what the agent did.
But there’s a limit, and it’s a data architecture limit:
A trace can only tell us as much as the data makes identifiable.
If the trace says the agent used “a policy,” that doesn’t help much. If it says Redrock’s claim policy, version 2026-03, section 4, retrieved at 9:02, now we can check it. If it says an action returned a price, that’s less useful than the Work Order Line Item’s record ID, the value, and the time. That’s why module 3’s decision record carried record IDs, versions and sections. We may not own Session Tracing. We decide whether the evidence flowing through it carries enough identity and provenance for the trace to mean something.
Agent Platform Tracing — What happened underneath the agent?
Section titled “Agent Platform Tracing — What happened underneath the agent?”An agent doesn’t work alone. It can call Flow, Apex, Prompt Builder, invocable actions, the AI and LLM gateways, Data 360 queries and integrations. Agent Platform Tracing follows the work into that layer, and its traces can be tied back to the session (Agent Platform Tracing (opens in a new tab), Salesforce Developers Blog, May 2026, checked 2026-11-28).
That matters, because sometimes the agent was right and something underneath it failed.
Say the agent decides: credit $180. A person approves it. The Flow that creates the credit writes $1,800: a field mapping slipped a decimal place. Looking only at the outcome, you’d say the agent made a terrible decision. It didn’t. The reasoning and the decision were both right. The failure happened in execution.
This is exactly why module 3 drew the chain:
Source → Data → Retrieval / Lookup → Context → Reasoning → Decision → Action
Tracing lets us walk the chain instead of guessing.
Audit & Feedback — What was supplied to generative AI?
Section titled “Audit & Feedback — What was supplied to generative AI?”The last piece is Audit & Feedback. It records what went through the AI and LLM gateways, the requests and the responses, along with feedback, content quality and the retrieval-quality measures above (Agentforce Observability Infrastructure (opens in a new tab), Salesforce Help, checked 2026-11-28).
For a data architect, the object names matter less than what it lets us connect: what evidence did we provide? and what did the model produce from it? That’s the line between grounding and reasoning. If the right evidence reached the model and the answer contradicts it, look downstream, at the agent. If the right evidence never arrived, work backward, toward retrieval and the data.
Follow the evidence becomes an operational troubleshooting model
Section titled “Follow the evidence becomes an operational troubleshooting model”Now module 3’s chain becomes a working method. Say the finance agent issued the wrong credit. Start at the top, and at each stage ask one question, look in one place, and know what kind of fix it leads to.
| Stage | Ask | Where to look | Fix |
|---|---|---|---|
| Source | Did we choose the right system or document? Keystone’s policy for a Redrock claim? | The trace’s retrieval and action steps | The source architecture |
| Data | Was the value right in that source? A wrong price on the line item? | The record, and its history | Data quality and governance |
| Retrieval or lookup | Did we get what we meant to? Last year’s version? | Context relevance, retrieval steps | Access or retrieval design |
| Context | Did the agent get it with its qualifications? The rule without the exclusion? | What went to the model, in Audit & Feedback | Grounding and context design |
| Reasoning | Did it apply the evidence correctly? $360 for 20% of $900? | Faithfulness, the reasoning steps | Instructions, or deterministic logic |
| Decision | Did it reach the right conclusion, with the right control? Approved alone above its threshold? | The decision step and the approval | Rules, Agent Script, human control |
| Action | Did the system do what was decided? $1,800 written for $180? | Platform Tracing: Flow, Apex, integration | The action or the downstream system |
A word on the Decision row. In Agentforce today, a subagent is what used to be called a topic, and some API fields and older documents still use the old name.
That table gives us a much more disciplined conversation than “why did the AI get it wrong?”
Ask why until you reach the process
Section titled “Ask why until you reach the process”Finding the stage isn’t always the end. Salesforce’s own Well-Architected guidance shows a five-whys analysis for an agent failure, and it ends somewhere a data architect will recognize (Agentic Operational Excellence (opens in a new tab), checked 2026-11-28). Here’s the same idea at Steve Trucking. Say the finance agent credited a haul-away item.
- Why? The agent applied Redrock’s policy without the haul-away exclusion.
- Why? It retrieved last year’s version, which didn’t have the exclusion.
- Why? The policy library still marked last year’s version as current. Version 2026-03 was signed in March and never loaded.
- Why? Nobody’s job is to send a signed partner agreement to the library. The partner team signs it, and the library team finds out when something breaks.
- Root cause: there’s no process linking a change in a partner agreement to the knowledge the agents use.
Five whys from a wrong credit to a missing process.
Look where it ended. Not at the model, not at the prompt, not even at the index. At ownership: who owns the partner policies, and what happens when one changes. That’s data governance, the same stewardship question from Part 1. Rewriting the prompt would never have fixed it.
Sometimes the right fix is deterministic logic
Section titled “Sometimes the right fix is deterministic logic”This chapter is about grounding, but testing will sometimes show that the problem isn’t grounding at all.
Go back to the $360 from module 1. The evidence was perfect: an item worth $900, a qualifying claim, a rule of 20%. The agent keeps getting the arithmetic wrong. We could keep rewriting the instructions.
Or we could ask a better architecture question: why are we asking a language model to do a business calculation?
The credit is a rule. It should be calculated the same way every time, by an action: a Flow or Apex that takes the item value and the policy’s percentage and returns $180. The agent decides whether to call it and explains the result. Agentforce lets natural-language instructions sit beside deterministic logic, in Agent Script and in platform actions (Agent Script Language Characteristics (opens in a new tab), Salesforce Developers, checked 2026-11-28). And Salesforce’s own guidance agrees: agents should call proven workflows, not rebuild the business logic in their instructions (The Agentic Enterprise (opens in a new tab), Salesforce Architects, Well-Architected, checked 2026-11-28).
Use grounding to provide evidence. Use deterministic logic where the business needs the same answer every time.
The data architect usually doesn’t build that logic. But when testing shows good data reaching the agent again and again, and the failure happens after that, stop trying to fix the data.
Observability doesn’t replace point-in-time architecture
Section titled “Observability doesn’t replace point-in-time architecture”Session Tracing and the rest are powerful. They don’t answer every audit question.
Say Redrock disputes the $180 credit two years from now. We need to show the item value used, the policy version and section in effect, the photos, the decision, who approved it, and the credit that was created. Some of that may still be in the traces, depending on how long you keep them. Some of it has to be kept on purpose, as part of the business data. Salesforce’s guidance makes the same point: log the data retrieved for grounding with each significant action, because the records may have changed since (Trust for the Agentic Enterprise (opens in a new tab), checked 2026-11-28).
That brings back the distinction from module 3:
Provenance tells us where evidence came from.
A decision record keeps what evidence and rules were actually used, at that moment.
Observability supports the design. It doesn’t replace it.
Test before production, observe after deployment
Section titled “Test before production, observe after deployment”Testing and tracing solve related problems, at different times.
Before production, use controlled cases to ask: does the grounding behave the way we designed it? Test the governing sources, stale data, conflicting data, missing evidence, retrieval quality, permissions, ambiguity, and every failure case you designed for.
After deployment, use observability to ask: what’s actually happening in real conversations? Look for retrieval that keeps coming back thin, sources you didn’t expect, actions that fail, slow responses, patterns in feedback, cases where the agent didn’t have enough evidence, and the gap between what you expected and what happened.
And keep testing after go-live, because things change underneath you. Salesforce names the causes of quality drift: the model changes, the knowledge base goes stale, the questions people ask change. It recommends mapping which agents depend on which knowledge bases, so an update shows who’s affected, and versioning prompts, agent configurations and knowledge bases (Agentic Operational Excellence (opens in a new tab), checked 2026-11-28). At Steve Trucking, that map says Redrock’s policy library feeds the finance agent and the assistant, so a new version means a test run for both.
The model can change too. As of November 2026, Salesforce’s Well-Architected guidance says there’s no documented way to freeze the Salesforce Default model mix to an earlier version. So it recommends running your test sets after each platform release and any announced model change, or choosing a specific named model if you need that stability (Trust for the Agentic Enterprise (opens in a new tab), checked 2026-11-28). Your test set isn’t a one-time gate. It’s the thing you run every release.
Architecture isn’t finished when the agent passes its first test. What production shows should feed back into the design.
Design → Test → Observe → Improve
The Data Architect doesn’t own the whole agent
Section titled “The Data Architect doesn’t own the whole agent”It’s worth ending the chapter where we began. Many things shape an agent’s behavior: instructions, Agent Script, deterministic logic, actions, guardrails, human approvals, the model, testing, and observability. A data architect should understand how each of them touches the data. But we shouldn’t turn every AI concern into a data architecture concern.
Our responsibility is clearer than that:
The data architect makes sure the agent has the right evidence. The broader agent architecture decides how the agent uses it.
So we should be able to answer:
- What evidence does this agent need?
- What’s the source that governs each fact?
- Should the agent look the fact up, or retrieve the knowledge?
- How fresh must the evidence be?
- Is it complete?
- Is the agent permitted to use it?
- Can we trace where it came from?
- Can we test that the grounding works?
- When something fails, can we find where in the chain it failed?
If we can answer those, we’ve done much more than connect a model to enterprise data. We’ve designed the grounding.
The grounding architecture
Section titled “The grounding architecture”Across the four modules, the chapter has built one progression:
1. What evidence does the agent need? Ground it in enterprise data.
2. How should the agent get it? Look up the facts you know; retrieve the knowledge you have to find.
3. Can the agent trust it? Relevant, authoritative, current, complete, permitted, traceable.
4. How do we know it worked? Test it, trace it, and follow the evidence from source to action.
And when something goes wrong:
Source → Data → Retrieval / Lookup → Context → Reasoning → Decision → Action
Follow the evidence. That’s how a data architect helps make an agent trustworthy.
What an Architect Decides Here
Section titled “What an Architect Decides Here”- Which test cases prove each grounding decision, including every failure case the design promises to handle.
- Which retrieval-quality measures are watched, and who samples real answers against the sources, on what schedule.
- That Session Tracing is on before go-live, and how long its traces are kept, under what privacy rules.
- Which identifiers and versions the evidence carries, so a trace can be checked.
- Which calculations and rules move out of the instructions into deterministic actions.
- Who owns each knowledge source, and what process updates it when the business changes.
- Which agents depend on which sources, and the test run every release and every model change triggers.
Beyond the exam: what AI changes. Testing used to end at go-live, more or less: the code didn’t change unless someone changed it. An agent’s behavior can change when the model changes, when a document is updated, or when people start asking different questions, and nobody touched the code. So the test set becomes something you run for the life of the agent. An AI tool can help you write that test set quickly, too. Give it the design decisions and ask it for the case that breaks each one. Then check that every case it writes actually tests a decision you made.
Explore
Section titled “Explore”- Salesforce Architects, Well-Architected: The Agentic Enterprise (opens in a new tab), Reliability for the Agentic Enterprise (opens in a new tab), Trust for the Agentic Enterprise (opens in a new tab) and Agentic Operational Excellence (opens in a new tab), checked 2026-11-28.
- Salesforce Help, Agentforce Testing Center (opens in a new tab), checked 2026-11-28.
- Salesforce Help, Agentforce Observability Infrastructure (opens in a new tab), checked 2026-11-28.
- Salesforce Help, Agentforce Session Tracing (opens in a new tab), checked 2026-11-28.
- Salesforce Help, Data Model for Agentforce Session Tracing (opens in a new tab), checked 2026-11-28.
- Salesforce Help, Set Up Agentforce Session Tracing (opens in a new tab), checked 2026-11-28.
- Salesforce Developers Blog, Agent Platform Tracing (opens in a new tab) (May 2026), checked 2026-11-28.
- Salesforce Developers, Agentforce Developer Guide, Agent Script Language Characteristics (opens in a new tab), checked 2026-11-28.
- Earlier in this chapter: Grounding an Agent in Enterprise Data, Choosing How the Agent Gets the Data, Designing Grounding You Can Trust. Chapter 11’s Safe to Retry. Checkpoint 3’s tests for the assistant.
