Most teams testing Agentforce in a sandbox assume the environment is safe because it is not production. It is not. If that sandbox is a full copy refreshed from live data, every case description, chat transcript, and contact record a test agent touches can get pulled into a prompt and sent to the Einstein Trust Layer or a connected LLM. Masking has to happen before Agentforce testing starts, not after someone notices a customer's SSN in a grounding response.
This is not a theoretical compliance footnote. It is an architecture problem. Agentforce does not read static config, it retrieves live records at runtime to ground its answers, which means your sandbox data is not just sitting in a database anymore. It is actively feeding a generative model.
Why Agentforce Sandbox Testing Puts Real Data in the Model's Path
Retrieval-augmented grounding is the whole point of Agentforce. When a test agent asks it to resolve a case, the model pulls related case history, knowledge articles, and contact fields to build context before generating a response. That is exactly the behavior you want to validate before go-live.
The problem is where that data comes from. Most QA teams validate Agentforce against a full-copy or partial-copy sandbox because synthetic data rarely produces realistic conversational patterns. Real customer complaints, real phone numbers in case notes, real email threads pasted into descriptions — all of it gets ingested the moment someone runs a test prompt.
Unlike a report export or a dashboard view, that data does not stay inside Salesforce's perimeter. Depending on your Trust Layer and model configuration, it can pass through external inference endpoints, get logged for debugging, or surface in a transcript that a contractor reviews during UAT. None of that happens in a standard Apex test or a flow debug log. Agentforce changes the exposure surface, and most sandbox governance policies were written before that surface existed.
Compliance Masking vs. AI-Safe Masking
Teams that already mask sandboxes for GDPR or HIPAA reasons sometimes assume they are covered. They are not, and the gap matters.
Standard masking scrambles names, emails, and national ID numbers so a developer running SOQL queries never sees a real customer. That is sufficient for most functional testing. Agentforce testing asks more of the data.
First, referential integrity has to survive the mask. If a contact's email is scrambled independently from their case records, the model may fail to connect them during grounding, which gives you a false negative on an accuracy test rather than a real signal. Second, the masked text inside free-text fields — case descriptions, chat logs, email bodies — has to stay semantically coherent. Replacing "cancel my subscription due to billing error on invoice 4471" with randomized tokens breaks the exact intent-recognition test you are trying to run. You need the sentence structure and intent intact with the identifying details stripped out.
This is the distinction we built MaskEzee around: anonymize the identifiers, preserve the relationships and the realistic shape of the data. A masking job that treats every field the same way will either leave PII exposed or strip out the context Agentforce needs to be tested properly. You cannot default to maximum scrambling and call it done.
What Actually Breaks When You Test With Unmasked Data
Picture a 400-seat service org running Agentforce pilot testing in a full-copy sandbox refreshed straight from production, no masking step in between. Here's what tends to happen in that scenario.
Support leads reviewing test transcripts see real customer names and policy numbers on shared screens during a demo to the executive sponsor. A contractor on a fixed-term engagement gets sandbox access for UAT and now has read access to real financial details through case history, access that was never scoped for them. If the model configuration routes any processing outside your data residency boundary, you have a cross-border transfer of regulated data that nobody filed a privacy impact assessment for, because nobody classified sandbox testing as a data processing activity in the first place.
None of these are edge cases. They are the default outcome of skipping a masking step because the testing deadline was tight and the sandbox refresh already ate two days. I've seen teams treat masking as a nice-to-have for lower environments and a must-have for anything customer-facing. Agentforce blurs that line completely, because a sandbox test run is now a live interaction with a generative model, whether anyone labeled it that way or not.
Where Masking Fits in the Agentforce Testing Pipeline
The fix is sequencing, not more policy documents. Masking needs to be a gate, not a cleanup task.
A workable pipeline looks like this: refresh the sandbox, mask immediately and automatically before any user gets access, seed additional production-like volume if your test cases need more records than the copy provides, then open the environment for Agentforce configuration and grounding tests. Each step has a reason for existing in that order.
- Refresh: pull the full or partial copy from production on your normal cadence.
- Mask before access: run an automated masking job the moment the refresh completes, before any admin, tester, or contractor logs in. Manual or delayed masking is how exposure windows happen.
- Seed for volume: if your partial copy sandbox does not have enough case variety to stress-test grounding accuracy, generate additional production-like records rather than widening the data pull. This is the SproutEzee layer — more realistic volume without pulling more real customer data into scope.
- Test Agentforce: run prompt validation, deflection accuracy checks, and knowledge grounding tests against the masked, seeded environment.
The order matters because masking after testing has already started is functionally the same as not masking at all. Once a prompt has run against real data, that exposure already happened, and no amount of after-the-fact cleanup un-sends it.
Building an AI-Safe Masking Policy
A masking policy written for Agentforce testing needs to cover more field types than a typical compliance-driven mask. The table below is a starting point, not a complete list — your actual scope depends on which objects feed your Agentforce grounding configuration.
| Data type | Standard masking | AI-safe masking requirement |
|---|---|---|
| Names, emails, phone numbers | Usually covered | Covered, with relationships preserved across objects |
| Case descriptions and comments | Often skipped | Must mask embedded PII while keeping intent and structure readable |
| Chat and email transcripts | Rarely covered | High priority — these feed grounding directly |
| Attachments and file uploads | Not covered | Needs scanning or exclusion, since file content bypasses field-level masking |
| Custom fields with free text | Inconsistent | Audit every free-text field before the first Agentforce test cycle |
Attachments deserve a specific mention because they are the field type teams forget most often. A masked case record can still have a PDF invoice or a screenshot attached with a customer's full name and account number visible. If your Agentforce configuration references attachment content during grounding, that file needs to be excluded or scrubbed separately from the standard field-masking job.
Get this sequence running as an automated part of your sandbox refresh process and it stops being a separate task someone has to remember. That is the actual goal: masking that happens by default, not masking that happens when someone raises a concern after the fact.
Frequently Asked Questions
Does Agentforce send sandbox data outside Salesforce?
Depending on your Trust Layer and model configuration, grounding requests can be processed by external inference endpoints rather than staying entirely within Salesforce's own infrastructure. Even when processing stays inside Salesforce's boundary, the data still moves from static storage into an active prompt context, which is a different exposure pattern than a report or dashboard. Review your specific Trust Layer settings and data processing agreement to confirm exactly where inference happens for your org.
Is standard sandbox data masking enough for Agentforce testing?
No. Standard masking typically scrambles identifiers like names and emails but often breaks referential integrity between related records and strips the sentence structure out of free-text fields. Agentforce grounding needs both the relationships and the semantic coherence intact, with only the identifying details removed. Masking built for compliance audits and masking built for AI testing solve different problems.
When should masking happen in a sandbox refresh for Agentforce testing?
Masking should run automatically immediately after the sandbox refresh completes and before any user, including admins and contractors, gets access to the environment. Running masking after testers have already logged in creates an exposure window, since any data they viewed or queried before the mask ran was already real. The safest pipeline treats masking as a gate, not a cleanup step.
Can synthetic data replace real data for Agentforce testing?
Synthetic data alone often lacks the conversational realism needed to validate grounding accuracy, since randomly generated case text does not reflect how real customers phrase issues. A better approach combines masked production-like data for realism with additional synthetically seeded volume where test coverage needs more records than the sandbox copy provides. Relying on pure synthetic data for every test case tends to produce unreliable accuracy results.
What fields get missed most often when masking for Agentforce testing?
Chat transcripts, email bodies, and attachments are the most commonly missed fields because standard masking tools focus on structured fields like name and phone number. Attachments are a particular risk since file content bypasses field-level masking entirely and can still contain a customer's full details. Any field that feeds Agentforce's grounding configuration needs a specific audit before the first test cycle, not an assumption that standard masking already covers it.