A structured reference for designing production-grade Agentforce agents — from the deterministic sandwich pattern to RAG data strategy.
Hybrid reasoning, blueprint hierarchy, the deterministic sandwich pattern, RAG strategy, and best practices. Some sections differ between models — use the switcher to show the version relevant to you.
Agentforce blends probabilistic LLM flexibility with deterministic rule-based control
LLM = Behavior. Code = Control. Every design decision in Agentforce comes back to this. If the outcome must be predictable and traceable — use code. If the input is open-ended and human — use the LLM. This distinction drives every design decision in Agentforce.
Configure everything visually in the Agentforce Builder UI — no code files required
| pipe lines — same concept, now in codebefore_reasoning: / after_reasoning:before_reasoning: or a Flow. Master the pattern, then the syntax follows.
In the Classic Model, you configure everything through the Agentforce Builder visual interface — no code files, no syntax to learn.
In the Classic Model, instructions are plain text written in the Builder UI. The LLM reads them as behavioral guidelines.
The LLM reads instructions as context — it interprets them probabilistically. For deterministic enforcement, the logic must live in a Flow or Apex action.
Hierarchical structure of concepts nested within Agentforce Builder
The overarching entity. Defines the agent's identity, persona, channels, and which Subagents it contains.
Specialized departments with distinct expertise. The Reasoning Engine reads each subagent's Classification Description to route the user's message to the right one.
1–3 natural-language guidelines written in the Builder UI. The LLM reads them as behavioral guidance — tone, action selection, what to do/avoid. Probabilistic, not enforced as code.
Each Action is configured individually in the Builder. The LLM reads the action's name and description to decide when to invoke it.
Invoke a Salesforce Flow. Use for mandatory sequences, data writes, identity checks — logic that must be deterministic.
Invoke an Apex class method. Use for complex calculations, integrations, or business rules that need full programmatic control.
Use an Einstein Prompt Template to generate structured AI output — summaries, drafts, classifications — grounded in Salesforce data.
Connect to external systems via MuleSoft integrations or REST APIs configured as Named Credentials.
Data Libraries (ADL) + Retrievers for Retrieval Augmented Generation — grounds the LLM in your org's knowledge.
Indexes structured data (Cases, Knowledge Articles) and unstructured data (PDFs, HTML) for vector search.
Bridge between the search index and the prompt — injects relevant chunks into the LLM's context at inference time.
Code handles the beginning and end — AI handles the middle
A Flow runs deterministically before the LLM responds. Use for: identity verification, data lookups, mandatory pre-conditions, loading context from Salesforce records.
The LLM conversation loop. Driven by 1–3 natural-language Instructions in the Builder UI. Handles: tone, intent detection, action selection, collecting user input.
A closing Flow handles: writes to Salesforce, audit logs, handoffs to humans, session cleanup. Must be referenced in Instructions — the LLM is told to invoke it.
| Layer | Mechanism | How enforced |
|---|---|---|
| 🔒 START | Flow Action | Instruction: "Always invoke Validate_Customer_Identity as the first action before responding to any request." |
| 🧠 MIDDLE | Instructions (text) | 1–3 natural-language guidelines in the Builder UI. LLM interprets probabilistically. |
| 🔒 END | Flow Action | Instruction: "After completing the request, always invoke Log_Case_Event before ending the conversation." |
The key difference from Agent Script: the END layer is not code — it relies on the LLM following your instruction. For truly mandatory logic, always use a Flow.
When asked to design an agent, always call out the sandwich explicitly: "I'd put identity verification and mandatory data lookups in a deterministic Flow before the LLM sees any context, and all writes and audit logs in a closing Flow invoked at the END layer." That language signals you understand the hybrid model regardless of which implementation you're using.
In the Classic Model the sandwich is a design pattern, not a technical guarantee. The END layer depends on Instructions correctly telling the LLM which Action to invoke and in what order. If instructions are ambiguous, the LLM may skip a step. Mandatory sequences belong in Flows — not in plain-text instructions.
How state is passed between subagents and steps in the Classic Model
In the Classic Model there are no session variables. State is passed between subagents and actions through these mechanisms:
Without session variables, cross-subagent state requires deliberate design:
In the Classic model there are no explicit session variables — you pass data between subagents by storing values in Salesforce records or using Flow variables within a single invocation. Agent Script variables are a cleaner abstraction of the same need: don't re-fetch what you already know.
How the Reasoning Engine routes requests in the Classic Model — automatic, not coded
In the Classic Model, routing between subagents is automatic and invisible — you don't write transition logic. The Reasoning Engine handles it.
There is no deterministic "go to subagent X" in the Classic Model. Routing is always probabilistic — the engine reads, infers, and routes.
In the Classic model, "transitions" don't exist as a concept — routing between subagents happens automatically via the Reasoning Engine's classification step. Agent Script makes transitions explicit and controllable. The important thing is knowing when to route and why, regardless of how it's implemented.
Step-by-step reasoning engine logic when a user sends a message
How Agentforce grounds responses in real data
Context engineering, instructions, actions, and RAG data curation
End-to-end diagram from user message to grounded response
Customer-facing agents for support, deflection, and case management
Delivers personalized customer interactions by answering FAQs directly from your knowledge base. Autonomously handles the creation and management of support cases and intelligently escalates complex issues to a human service representative when needed.
Agents that assist across the full sales cycle — from prospecting to closing
Prospects and generates pipeline 24/7. Intelligently engages leads with personalized content, answers common questions, and schedules meetings.
Equips sales representatives with confidence and practice to close deals through AI-powered coaching. Provides personalized, actionable, stage-specific feedback on sales pitches and role-play sessions.
Assists sales teams in managing and progressing deals from creation to closing. Helps the deal closing team track progress and initiate deal-related communications.
Answers sales and pricing questions and qualifies leads directly from a website. Can transfer the conversation to other agents when required.
Employee-facing and domain-specific agents for internal workflows
Interacts with employees via natural language to provide data, insights, and task automation. Ensures secure access to CRM data across channels such as Salesforce, Mobile, and Slack.
A specialized agent built for financial services teams, designed to help manage and expedite the loan approval process.
Base agents and cross-cloud agents for broader platform workflows
The standard base agent used for general workflows and tasks within the platform. Starting point for custom agent builds without a predefined template.
Additional agent types designed to handle specific marketing campaigns, commerce workflows, and other domain-specific tasks across the Salesforce ecosystem.
A customer contacts the bank's chat to report an unrecognized charge, block their card, and request a replacement. Agent Profile, Subagents, RAG, and the Conversation are the same in both models. Only the Sandwich implementation differs.
Name, channel, persona — the top-level identity of the agent
Classification description, scope, instructions, and actions for each subagent
Classic Model — sandwich as a design pattern, enforced via Flows and Instructions
En el Classic Model el sandwich es un patrón de diseño, no una garantía técnica. El END layer depende de que las Instructions indiquen correctamente al LLM qué action invocar y en qué orden. Si las instrucciones son ambiguas, el LLM podría saltarse un paso. El Agent Script elimina esta fragilidad poniendo el END en código.
Knowledge Base structure, article fields, and Retriever wiring per subagent
| Field | Content |
|---|---|
| Title | Short, keyword-rich: "Fraud Dispute — Credit Card Resolution Timeline" |
| Summary | One sentence: what this article answers |
| Question | The exact customer question this article answers |
| Answer | The policy answer in plain language |
| Exceptions | Edge cases, international rules, fee exceptions |
| Last Reviewed | Date — Retriever can deprioritize stale content |
| Subagent | Retriever Scope | Action That Triggers It |
|---|---|---|
| Report_Unrecognized_Charge | Fraud Dispute articles only | Get_Dispute_Resolution_Info |
| Block_Card | Card blocking impact — recurring payments, linked services | Surfaced proactively in LLM MIDDLE layer |
| Request_Replacement_Card | Replacement delivery terms, address change policy | Get_Card_Delivery_Terms |
The full customer interaction — annotated with which component runs at each message