Sub topic 6
Trust Layer and Model Selection
This chapter assumes you can build a basic prompt template in Prompt Builder, know what merge fields are, and can find Einstein settings in Setup. It covers what happens to a prompt between your template and the large language model (LLM), and how to pick the model that runs it.
What the Einstein Trust Layer does
The Einstein Trust Layer is a set of controls that sits between Salesforce and the LLM. Your template does not call the model directly. Every request passes through the layer, and so does every response.
For a prompt template, the layer works in this order:
- Grounding. Merge fields are replaced with real record data. The Trust Layer applies the running user's field-level security and sharing, so users only ground on data they can see.
- Data masking. If masking is enabled, sensitive values such as names, emails, and phone numbers are replaced with placeholders before the prompt leaves Salesforce.
- Prompt defense. System-level instructions are added to reduce the chance that text in a record overrides your rules.
- LLM call. The masked prompt goes to the model. With the standard setup, the provider does not keep your data after the response is returned (zero data retention).
- Demasking and toxicity check. Placeholders are swapped back for real values, and the response is scored for harmful content.
- Audit trail. The request and response metadata are stored, if auditing is enabled in your org.
Why this matters for an agent action
When an agent runs your template as an action, the same path applies. The agent passes inputs to the template, the template is grounded and masked, and the model answers. The agent then receives the demasked output.
Two practical consequences follow:
- Masking can change what the model sees. If your rule says "address the customer by first name", the model may only see a placeholder. The output is demasked afterward, but the model's reasoning about the value is limited.
- Grounding follows the user's permissions. A template that works for you as an admin can return "unknown" for another user who lacks field access. Test with a realistic user.
Choosing a model
In Prompt Builder, the template editor has a model selector. Which models appear depends on your org's configuration and on what Salesforce offers. Options typically include Salesforce-managed models from providers such as OpenAI, Anthropic, and Google, and you can also connect your own model through Einstein Studio (a "bring your own model" setup).
Choose with these criteria:
| Criterion | What to check |
|---|---|
| Task fit | Short factual summaries need less capability than long reasoning or multi-step drafting. |
| Latency | An agent waits for the template result during a live conversation. Smaller, faster models feel better in chat. |
| Context size | Large related lists and long descriptions need enough room in the model's context window. |
| Cost | Larger models use more credits per call. Estimate volume before choosing. |
| Data residency | Confirm the model is allowed for your regulatory requirements. |
Start with the default model. Run the same test records through one or two alternatives in the preview, compare quality and response time, then switch only if the gain is clear.
Common errors
- Model missing from the list. The model may not be enabled in your org, or may not be available in your region. Check Einstein setup and your edition.
- Different results after a model change. Prompts are tuned against a model's habits. Retest your rules, especially length limits and "say unknown" instructions.
- Truncated or failed output on large inputs. Too much grounded data can exceed the context window. Trim fields and limit related lists.
- Masked values look wrong in the preview. Open the resolved prompt in the preview to see what the model actually received.
Exercise
A template that summarizes a case works for an admin but returns "unknown" for most fields when a service agent triggers it through the agent. Which Trust Layer step most likely explains this, and what do you check first?
Show answer
Grounding. It applies the running user's field-level security and sharing, so the service agent may lack access to the fields. Check the user's permission sets and field access, then retest the template as that user.
Exercise
You switch a template from the default model to a larger one. Name two things you should retest and two reasons the larger model might not be the right choice.
Show answer
Retest the output length limit and the "use only the information above" rule. A larger model may be slower in a live chat and may cost more credits per call.