Most Agentforce demonstrations work. Most Agentforce deployments stall. The difference is almost never the model or the prompt. It is architecture: whether the data underneath the agent is unified, whether the actions it needs already exist and are trustworthy, and whether anyone decided what the agent is not allowed to do. This is the reference design we use, the run time flow behind it, and the decisions you need to make before anybody opens Agentforce Builder.
Why agent projects stall
Across assessments, the same four causes come up. None of them is an AI problem.
- The data is in pieces. The agent is asked about a customer who exists as four records across three systems. It answers confidently from one of them.
- The actions do not exist. An agent can only do what you give it. If there is no reliable, tested way to issue a refund, the agent cannot issue refunds, no matter how well it understands the request.
- Nobody defined the boundary. Without explicit limits, the agent attempts things it should escalate, and everyone loses confidence after the first bad transcript.
- Nobody defined success. No deflection target, no measurement, so the project cannot be shown to have worked and quietly loses its sponsor.
The blunt version. An agent that hands everything to a human is an expensive router. The value is in work completed end to end without a person. That outcome is decided by your data and your actions, which is to say by architecture, well before anyone writes an instruction.
The five layers of a working agent
Every agent that survives production has these five layers. Build them bottom up, because each one depends on the one below.
| Layer | What it is | Built with |
|---|---|---|
| 5. Trust and observability | Guardrails, monitoring, testing, escalation | Einstein Trust Layer, Testing Center, transcripts, audit |
| 4. Reasoning and orchestration | Deciding what to do and in what order | Planner, subagents, instructions, Agent Script |
| 3. Actions | The things the agent can actually do | Flows, Apex, prompt templates, APIs |
| 2. Grounding | Getting the right facts into the prompt | Retrievers, search indexes, data graphs, Knowledge |
| 1. Data foundation | One trustworthy version of the truth | CRM objects, Data 360 streams, identity resolution |
The temptation is to start at layer 4, because that is the layer that looks like AI. Starting there is how you get a demonstration that cannot be deployed.
What actually happens at run time
Understanding the request path makes the design decisions obvious. When a user asks an agent something:
- The utterance arrives with session context: who is asking, from which channel, and which record they are on.
- The planner classifies the request against the subagents available to it. Each subagent is a category of related work with its own instructions and its own set of actions.
- The planner selects actions from that subagent, using each action's description to decide what fits. This is why action descriptions are functional design, not documentation.
- Grounding happens. Retrievers query indexed content, prompt templates merge in record data, and the results are assembled into the prompt.
- The prompt passes through the trust layer, where policy checks apply before it reaches the model.
- The model responds, either with an answer or with a decision to call another action.
- Actions execute as the running user, subject to that user's permissions and sharing.
- The loop repeats until the goal is met or the agent escalates.
- Everything is logged for review.
Two consequences worth internalising. First, permissions are enforced at execution, so the agent's running user is a security design decision, not an afterthought. Second, the planner only knows what your descriptions tell it, so vague action and subagent descriptions produce an agent that picks the wrong tool and looks stupid.
Layer 1: The data foundation
This is where most of the real work is, and it is unglamorous.
Decide what Data 360 is for
Salesforce Data Cloud is now branded Data 360. You do not need it for every agent. Be honest about which case you are in:
- You do not need it if everything the agent reasons over already lives in your Salesforce org as clean CRM data. Ground on the records directly.
- You need it when the truth is spread across systems, when you need to unify a person across channels, when you want to ground on unstructured documents, or when you want to query a warehouse without copying the data.
The pipeline, in order
- Data streams bring data in from a source.
- Data Lake Objects hold it as ingested, close to its original shape.
- Mapping to Data Model Objects harmonises it into a shared model, so "customer" from three systems becomes one shape.
- Identity resolution matches and reconciles records into a unified profile. This is the step that decides whether your agent talks to one person or three fragments of one person.
- Calculated insights compute the metrics you want available, such as lifetime value or engagement recency.
- Data spaces partition all of it by brand, region, or business unit, which is also a security boundary.
Zero copy federation deserves a specific mention. If your analytics already live in Snowflake, BigQuery, Databricks, or Redshift, you can query them without physically moving the data. That changes the economics of grounding on warehouse data, and it removes a synchronisation problem you would otherwise own forever.
Identity resolution is the highest leverage and most misunderstood step, so we cover the tuning in Data Cloud identity resolution.
Layer 2: Grounding, and choosing between three routes
Grounding is how facts reach the prompt. There are three routes, and picking the wrong one is a common and expensive mistake.
| Route | Best for | Limits |
|---|---|---|
| Direct record grounding via prompt template merge fields, Flow, or Apex | Structured facts the agent needs exactly: this case, this order, this gift history | You must know in advance which fields matter. No semantic search |
| Agentforce Data Library | Fast setup over Knowledge articles, uploaded files, or web search. Salesforce builds the vector store, search index, and retriever for you with defaults | One data source per library. No multi-source integration, no real time, no zero copy, so non-CRM data has to be downloaded as files |
| Custom retrievers on Data 360 | Multiple sources, harmonised and unified data, real time and zero copy content, full control of chunking and search | Requires Data 360 implemented properly: ingestion, modelling, identity resolution |
The practical rule: start with a data library if your content is one tidy source and you want to prove value in days. Move to custom retrievers when you need more than one source, when freshness matters, or when the answers need to reflect a unified profile rather than a document.
Note also that ensemble retrievers let you combine sources, and data graphs pre-join related structured data so the agent gets a whole picture in one retrieval instead of several. With Data Cloud One connections, retrievers created in a home org can be used from companion orgs, which matters for multi-org estates.
The full setup walkthrough is in grounding Agentforce in your own documents.
Layer 3: Actions
Actions are the agent's hands. This layer is ordinary Salesforce engineering, which is good news, because you already know how to do it well.
- Flow for most record work: create, update, look up, orchestrate a few steps. Start here.
- Apex for logic Flow cannot express cleanly, complex callouts, or heavy data work.
- Prompt templates when the output is generated text: a summary, a draft reply, an explanation.
- External services and APIs when the system of record is elsewhere.
Three rules that matter more than the choice of type:
- Actions must be idempotent or guarded. A planner can retry. If a retry issues a second refund, that is your bug, not the model's.
- Actions must fail informatively. "Something went wrong" leaves the agent unable to decide what to do next. Return a reason it can act on.
- Inputs and outputs must be tightly typed and described. The planner maps conversation to parameters using your descriptions.
Detail on building them, including how to write descriptions the planner can actually use, is in Agentforce custom actions with Flow, Apex, and prompt templates.
Layer 4: Reasoning and orchestration
This layer used to be described as topics and actions. The current model is more explicit, and understanding the metadata makes it concrete:
AiAuthoringBundleholds the agent blueprint, including its Agent Script. This is what you edit, in Agentforce Builder or in VS Code.GenAiPlannerBundleis the reasoning engine. One per agent. It holds the subagent map, the orchestration graph, instructions, and the actions available.GenAiPluginrepresents a subagent, meaning a category of actions related to one job to be done.GenAiFunctionrepresents a single action.BotandBotVersionappear once an agent version is committed. A draft is the authoring bundle alone.
Design guidance for this layer:
- Scope subagents narrowly. One job each. A subagent that covers billing, returns, and technical support will misroute, because the planner has no basis to choose.
- Write instructions as policy, not as prose. "Always verify identity before discussing account balances" is usable. "Be helpful and professional" is decoration.
- State what the agent must not do, explicitly. Negative instructions do more for reliability than positive ones.
- Give each subagent an escalation path, and make escalation an acceptable outcome rather than a failure. Agents that cannot escalate improvise.
On deployment, agents are metadata and move between orgs like anything else. There is a convenient Agent pseudo type in the CLI that gathers the related components, for example sf project deploy start --metadata Agent:My_Agent. One thing to know before you plan a release pipeline: deploying agent metadata does not deploy the Apex classes and Flows behind its actions, so those must be in the same deployment. Avoid wildcards on Apex, Flow, and prompt template types, because pulling everything in the org leads to very long deployments and timeouts.
Layer 5: Trust, guardrails, and observability
The Einstein Trust Layer sits between your prompt and the model, providing toxicity detection on generated output, an audit trail of prompts and responses, and zero data retention agreements with the model providers. It is infrastructure, and it is not a substitute for your own design.
Do not assume the trust layer masks sensitive data in an agent conversation. Salesforce documents data masking as a Trust Layer feature, but its own training material states that masking for large language models is currently disabled for agents, and available for embedded generative AI features such as Einstein Service Replies. Check the current behaviour in your own org before you design around it. If sensitive data must not reach the model, keep it out of the running user's field access rather than relying on masking to remove it. There is also a cost to masking where it does apply: models are limited to a 65,536 token context window while it is on.
What you still own:
- The running user's permissions. Actions execute with real access. Create a dedicated user with the minimum object, field, and record access the agent needs. Never reuse an administrator.
- Human in the loop, deliberately placed. Decide which actions require confirmation. Anything that moves money, changes entitlement, or sends external communication is a candidate.
- Testing. Agentforce Testing Center lets you run utterance sets against an agent and check the outcome. Build your test set from real transcripts, including the awkward ones, and re-run it on every change. This is the closest thing to regression testing for an agent and it is routinely skipped.
- Observability. Review transcripts weekly at first. Watch for wrong subagent selection, actions failing silently, and the questions the agent cannot handle. That last list is your roadmap.
- Measurement. Pick the metric before launch: deflection rate, resolution time, conversion. An agent without a number is an agent nobody can defend at budget time.
Seven architecture decisions to make up front
- Do you need Data 360 at all? If the answer is unclear, you probably do not yet. Prove value grounding on CRM data first.
- Who is the running user, and what can it touch? Write the permission set before the agent.
- Which grounding route per use case? Data library, custom retriever, or direct record access. Mixing them is fine; choosing by accident is not.
- What are the subagent boundaries? List the jobs to be done, then draw one subagent per job.
- What is explicitly out of scope? Write the list down and put it in the instructions. This is the most valuable document in the project.
- Where does a human confirm? Decide per action, not per agent.
- What is the success metric and its baseline? Measure the baseline before go-live or you can never prove improvement.
Anti-patterns we keep seeing
- The everything agent. One agent, twenty subagents, launched at once. It misroutes, nobody can debug it, and confidence collapses. Ship one narrow agent, prove it, expand.
- Grounding on a mess. Pointing a retriever at an unmaintained document library. The agent faithfully repeats a policy that was superseded in 2023.
- Admin as running user. Convenient in a sandbox, indefensible in production.
- No escalation path. The agent has no legitimate exit, so it invents an answer.
- Actions built for the agent only. Build them as reusable Flows and Apex that humans and the agent both use. You get one tested path instead of two.
- Testing by conversation. Three people chatting with the agent is not a test suite. Build the utterance set.
- Data 360 as the first purchase. Buying a data platform before you have a scoped use case usually produces an unused data platform.
Almost every one of these is a decision that could have been made in a design workshop and was instead discovered in production.
Frequently asked questions
Do I need Data Cloud to use Agentforce?
No. If everything the agent reasons over already exists as clean CRM data in your org, you can ground directly on records with prompt templates, Flow, or Apex. Data Cloud, now branded Data 360, becomes necessary when truth is spread across systems, when you need one unified profile per person, when you want to ground on unstructured documents, or when you want to query a warehouse without copying data.
What is the difference between an Agentforce Data Library and a custom retriever?
A data library is the fast route: Salesforce builds the vector store, search index, and retriever for you with default settings over one source such as Knowledge articles, uploaded files, or web search. It cannot combine multiple sources, and it offers no real time or zero copy access. Custom retrievers on Data 360 support multiple sources, harmonised and unified data, and full control over chunking and search, at the cost of a real Data 360 implementation.
What permissions does an Agentforce agent run with?
Actions execute as the agent running user, subject to that user’s object, field, and record access. That makes the running user a security design decision. Create a dedicated user with the minimum access the agent needs and never reuse an administrator, because anything the running user can reach, the agent can reach.
How are Agentforce agents deployed between orgs?
Agents are metadata. The blueprint lives in AiAuthoringBundle, the reasoning engine in GenAiPlannerBundle, subagents in GenAiPlugin, and actions in GenAiFunction, with Bot and BotVersion appearing once a version is committed. The CLI offers an Agent pseudo type as shorthand. Note that deploying agent metadata does not deploy the Apex classes and Flows behind the actions, so include those explicitly.
How narrow should a subagent be?
One job to be done. A subagent covering billing, returns, and technical support gives the planner no clear basis to choose between them, so it misroutes. Narrow subagents with distinct, specific descriptions produce reliable routing, and they are far easier to debug when something goes wrong.
How do I know whether the agent is working?
Choose the metric before launch and measure its baseline first, whether that is deflection rate, resolution time, or conversion. Then build a test set of real utterances in Agentforce Testing Center and re-run it on every change, and review transcripts weekly for wrong subagent selection and silent action failures. The questions the agent cannot handle become your roadmap.