Pushing an autonomous AI agent from a sandbox into a production Salesforce org is fundamentally different from pushing standard Apex triggers or custom objects. When DevOps teams treat Agentforce as just another metadata package, deployments collapse under cryptic dependency errors, broken function bindings, and inactive agent runtimes. At 365Finds, our stance is unequivocal: monolithic deployments for Agentforce are broken by design. To ship reliable autonomous agents, engineering teams must decompose the agent architecture into a phased dependency graph and align their Salesforce CLI (sf) pipelines to Metadata API version 64.0 or higher.
Deploying Agentforce successfully requires mastering its underlying metadata entities, enforcing a strict four-stage release sequence, and resolving the environment-level dependencies that the Metadata API cannot provision on its own.
The Metadata Architecture: Bundles, Topics, and Actions
In early Einstein Copilot releases (API versions 60.0 to 63.0), the planning logic was anchored in the flat GenAiPlanner metadata type. Starting in API version 64.0, Salesforce restructured this model into modular bundles. Managing Agentforce in version control requires tracking several distinct metadata types:
| Metadata Type | Directory & Extension | Role in Agentforce Architecture |
|---|---|---|
GenAiPlannerBundle | genAiPlannerBundles/<name>.genAiPlannerBundle | Replaced legacy GenAiPlanner; houses agent reasoning strategy, instructions, and topic bindings |
GenAiPlugin | genAiPlugins/<name>.genAiPlugin | Defines Agent Topics; groups instructions, trigger intents, and action assignments |
GenAiFunction | genAiFunctions/<name>.genAiFunction | Defines Agent Actions; specifies inputs, outputs, and invocation hooks for Apex, Flows, or Prompts |
GenAiPromptTemplate | genAiPromptTemplates/<name>.genAiPromptTemplate | Einstein 1 Studio prompt templates used for reasoning or data grounding |
Bot & BotVersion | bots/<name>/<name>.bot, botVersions/... | The runtime execution container and conversational engine hosting the planner |
When developers configure agents in Agentforce Builder, the user interface frequently drafts topics and actions inline. If these components remain coupled to an uncommitted draft state or use local definitions, retrieving them via Salesforce CLI can leave behind orphaned configurations. 365Finds recommends standardizing every agent action into globally tracked library components before writing CI scripts.
Target Org Pre-Flight Requirements
The Salesforce Metadata API deploys schema and instructions, but it does not automatically provision platform capabilities or resolve execution permissions. Attempting to deploy GenAiPlannerBundle to an unprepared sandbox will halt the pipeline immediately.
Before running CLI deployment jobs, DevOps engineers must ensure the following baseline conditions in the target environment:
- Feature Toggles: In Setup, "Turn on Einstein", "Einstein Bots", and "Agentforce for Salesforce" must be actively toggled on. In scratch org workflows, these must be enabled in
project-scratch-def.jsonunderfeatures. - Data Cloud Provisioning: If your Agentforce actions or prompt templates query Data Cloud DMOs or vector search indexes, Data Cloud must be provisioned and accessible in the target org; sandboxes refreshed from production must retain these index mappings.
- The Agent Running Identity: Agentforce executes actions under a dedicated technical user (the Einstein Agent User). This service identity must have assigned Permission Sets granting Object-Level Security (OLS), Field-Level Security (FLS), and class/flow execution permissions for every underlying Apex class or Autolaunched Flow referenced by
GenAiFunction.
The Four-Stage Dependency Deployment Strategy
Salesforce CLI dependency resolution often fails if you push actions, topics, and planners in a single indiscriminate payload. A GenAiPlugin cannot validate if its referenced GenAiFunction does not yet exist in the target org, and a GenAiFunction fails if its backing Flow or Apex class is still compiling.
365Finds recommends enforcing a sequential four-stage pipeline in CI/CD runners (such as GitHub Actions, GitLab CI, or Azure DevOps):
flowchart LR
A[Stage 1: Logic & Schema] --> B[Stage 2: Actions & Prompts]
B --> C[Stage 3: Topics]
C --> D[Stage 4: Planners & Bots]
Stage 1: Foundation Logic and Schema
Deploy the core platform logic that the agent executes:
- Apex Classes (specifically
@InvocableMethodentry points) - Autolaunched Flows
- Custom Objects, Fields, and Permission Sets
Stage 2: Prompt Templates and Functions
Deploy the reasoning templates and action contracts:
GenAiPromptTemplateGenAiFunction
Stage 3: Topics
Deploy the domain groupings that organize instructions and invoke functions:
GenAiPlugin
Stage 4: Planner Bundles and Runtime Bots
Deploy the orchestration layer that brings the agent to life:
GenAiPlannerBundleBotandBotVersion
Defining the Manifest (package.xml)
When retrieving or deploying Agentforce components via sf project deploy start or manifest-driven scripts, ensure your manifest explicitly references API version 64.0 or above to handle GenAiPlannerBundle correctly:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>Flow</name>
</types>
<types>
<members>*</members>
<name>GenAiPromptTemplate</name>
</types>
<types>
<members>*</members>
<name>GenAiFunction</name>
</types>
<types>
<members>*</members>
<name>GenAiPlugin</name>
</types>
<types>
<members>*</members>
<name>GenAiPlannerBundle</name>
</types>
<types>
<members>*</members>
<name>Bot</name>
</types>
<types>
<members>*</members>
<name>BotVersion</name>
</types>
<version>64.0</version>
</Package>
In sfdx-project.json, pin sourceApiVersion to 64.0:
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"name": "agentforce-devops",
"namespace": "",
"sfdxLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "64.0"
}
Executing CLI Commands in CI/CD Pipelines
1. Source Retrieval
To pull Agentforce changes from a developer sandbox while avoiding local workspace clutter:
sf project retrieve start --manifest manifest/package.xml --target-org sandbox-dev
2. Pull Request Validation (Dry Run)
Every pull request targeting your integration branch should run a validation check against an ephemeral scratch org or integration sandbox without committing changes:
sf project deploy validate \
--manifest manifest/package.xml \
--target-org uat-org \
--test-level RunLocalTests \
--wait 30
3. Targeted Phased Deployment
When executing actual releases, if your team chooses not to run a single manifest, execute deployments using path-based staging to guarantee execution order:
# 1. Deploy underlying execution logic
sf project deploy start --source-dir force-app/main/default/classes force-app/main/default/flows --target-org prod-org --wait 20
# 2. Deploy AI Functions and Prompt Templates
sf project deploy start --source-dir force-app/main/default/genAiFunctions force-app/main/default/genAiPromptTemplates --target-org prod-org --wait 15
# 3. Deploy Agent Topics
sf project deploy start --source-dir force-app/main/default/genAiPlugins --target-org prod-org --wait 15
# 4. Deploy Planner Bundle and Bot Runtime
sf project deploy start --source-dir force-app/main/default/genAiPlannerBundles force-app/main/default/bots --target-org prod-org --wait 20
Post-Deployment Activation and Operational Pitfalls
Deploying Agentforce metadata via Salesforce CLI lands components in the target environment, but it does not automatically switch the runtime agent to active status. The Metadata API imports BotVersion configurations in an inactive or draft state to prevent untested prompts from serving live traffic immediately.
To activate the agent post-deployment, pipelines must either execute an automated Apex hook via sf apex run updating the BotVersion status field (status = 'Active'), or require a verified post-deployment manual sign-off in Agentforce Builder.
In multi-developer environments, concurrent modifications to natural language instructions in .genAiPlugin files produce frequent merge conflicts. Because topic files combine prompt phrasing and action linkages in structured XML, standard line-by-line Git merges can corrupt XML tags. Teams must treat topic definitions as modular assets and prevent multiple developers from editing the same topic branch concurrently.
The Metadata API rejects any GenAiPlannerBundle deployment if referenced invocable actions take more than 30 seconds to respond or fail basic schema validation against target org objects.
References
- Salesforce Metadata API Developer Guide: GenAiPlannerBundle
- Salesforce Metadata API Developer Guide: GenAiPlanner
- Salesforce Metadata API Developer Guide: GenAiPlugin
- Salesforce Metadata API Developer Guide: GenAiFunction
- Salesforce Metadata API Developer Guide: GenAiPromptTemplate
- Salesforce Metadata API Developer Guide: Bot
- Salesforce Agentforce Official Documentation