Sub topic 3
Deploying the Agentforce Agent to the Target Org
Assume you know Salesforce orgs, permission sets, Agentforce topics and actions, Salesforce CLI, and basic Apex and Flow deployment. The deployment package should already contain the agent metadata and its dependencies.
Deploying and activating the agent
Run a validation deployment before changing the target org:
sf project deploy start \
--manifest manifest/package.xml \
--target-org target-org \
--dry-runIf validation succeeds, deploy the same manifest:
sf project deploy start \
--manifest manifest/package.xml \
--target-org target-orgThe target org must have the required Agentforce features enabled. It also needs referenced Apex classes, Flows, custom objects, fields, and permission sets. Deployment can succeed while runtime access is still missing.
Assign the permission set required by the agent's actions, then activate the agent:
sf org assign permset \
--name Agent_Action_Access \
--target-org target-org
sf agent activate \
--api-name My_Service_Agent \
--target-org target-orgThe names in these commands are examples. Use the API names from your project.
Testing and common errors
Test both normal requests and action failures. Confirm that the agent selects the expected topic, invokes the correct action, respects user permissions, and returns a useful response when data is missing.
| Symptom | Likely cause | Check |
|---|---|---|
| Metadata validation fails | Missing dependency or unsupported metadata | Deployment error details and manifest |
| Agent cannot invoke an action | Permission set or Apex access is missing | User permissions and class access |
| Activation fails | Agent metadata is incomplete or incompatible | Agent version and target features |
| Behavior differs | Environment-specific configuration differs | Named credentials, data, and settings |
Automating deployment
A CI/CD pipeline can authenticate to each org, validate the manifest, deploy only after validation passes, assign environment-specific permissions, and activate the agent. Store authentication data as protected pipeline secrets. Keep production activation as a controlled step when approval is required.
Exercise
Why should a pipeline validate the manifest before deploying it?
Show answer
Validation detects metadata and dependency errors without changing the target org, so the pipeline can stop safely before deployment.