Sub topic 6
Writing a manifest for the agent and its dependencies
A manifest is the package.xml file that tells Salesforce CLI which metadata to retrieve or deploy. This chapter covers how to write one that contains an Agentforce agent and everything the agent needs to run in the target org.
Prerequisites
This chapter assumes you:
- Can run basic Salesforce CLI commands and work in a Salesforce DX project.
- Know the agent metadata types from the earlier chapter:
Bot,BotVersion,GenAiPlanner,GenAiPlugin, andGenAiFunction. - Have a dependency inventory for your agent: the Apex classes, Flows, and permission sets that its actions call.
- Have already retrieved the agent metadata from the source org.
Why a manifest matters for agents
You can deploy by source path, for example --source-dir force-app. For agents, a manifest is usually the better choice, for three reasons:
- An agent spans many metadata types, and some of them are not stored under one folder.
- A manifest is a reviewable file. A teammate can read it and see exactly what ships.
- The same file works for retrieval, validation, and deployment, so all three steps cover the same set of components.
If a component is missing from the manifest, the deployment either fails or succeeds with an agent that cannot do its work. A missing Apex class used by an action is the typical case. The failure appears at deploy time or, worse, when a user talks to the agent.
Anatomy of a package.xml
A manifest has three kinds of elements:
<types>blocks. Each block names one metadata type and lists its members.<members>entries. Each is either a component's API name or*for all components of that type.<version>. This is the API version used to interpret the metadata.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>My_Service_Agent</members>
<name>Bot</name>
</types>
<version>63.0</version>
</Package>The <name> element holds the metadata type. The <members> element holds one component. You repeat <members> to list several components of the same type.
A manifest for a whole agent
The following manifest lists the agent metadata together with the components its actions rely on.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>Bot</name>
</types>
<types>
<members>*</members>
<name>BotVersion</name>
</types>
<types>
<members>*</members>
<name>GenAiPlanner</name>
</types>
<types>
<members>*</members>
<name>GenAiPlugin</name>
</types>
<types>
<members>*</members>
<name>GenAiFunction</name>
</types>
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>Flow</name>
</types>
<types>
<members>*</members>
<name>PermissionSet</name>
</types>
<version>63.0</version>
</Package>Each type has a role in the agent:
| Metadata type | What it represents | Why it must be in the manifest |
|---|---|---|
| `Bot` | The agent itself | It is the root of the agent definition |
| `BotVersion` | A version of the agent | It holds the version's configuration and links to the planner |
| `GenAiPlanner` | The planner that groups topics | It connects the agent to its topics |
| `GenAiPlugin` | A topic | It holds the topic's instructions and its action list |
| `GenAiFunction` | An action definition | It points at the Apex class, Flow, or other target that runs |
| `ApexClass` | Custom code used by actions | The action fails if the class is absent |
| `Flow` | Automation used by actions | The action fails if the flow is absent |
| `PermissionSet` | Access grants | The agent user needs them to run actions |
The wildcard * is convenient while you learn. It is a poor choice for a real project, as the next sections explain.
Wildcards versus named members
A wildcard retrieves or deploys every component of a type. That has costs:
- Unrelated code travels with the agent.
ApexClasswith*ships every class in the source org or project. Some of those may have failing tests or unfinished work. - The deployment is slower. More components mean more compile time and, for production, more tests.
- Review is harder. Nobody can tell from the manifest which classes the agent actually needs.
- Wildcards do not cover every type equally. Some metadata types handle
*in a special way. If a retrieval returns fewer components than you expect, name them explicitly.
A narrower manifest names each member. The dependency inventory from the earlier chapter supplies the names.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>My_Service_Agent</members>
<name>Bot</name>
</types>
<types>
<members>My_Service_Agent.v1</members>
<name>BotVersion</name>
</types>
<types>
<members>My_Service_Agent_Planner</members>
<name>GenAiPlanner</name>
</types>
<types>
<members>Order_Status_Topic</members>
<members>Returns_Topic</members>
<name>GenAiPlugin</name>
</types>
<types>
<members>Get_Order_Status</members>
<members>Create_Return</members>
<name>GenAiFunction</name>
</types>
<types>
<members>OrderStatusService</members>
<members>OrderStatusServiceTest</members>
<name>ApexClass</name>
</types>
<types>
<members>Create_Return_Flow</members>
<name>Flow</name>
</types>
<types>
<members>Agent_Action_Access</members>
<name>PermissionSet</name>
</types>
<version>63.0</version>
</Package>All names in this example are placeholders. Replace them with the API names from your own org. A BotVersion member is written as the bot name, a dot, and the version name, such as My_Service_Agent.v1. Check the exact names in the files you retrieved, because the file name on disk is the member name.
Include test classes
When you deploy to production, Salesforce runs Apex tests. Any Apex class you deploy needs coverage. Include the test classes for the agent's Apex classes in the manifest, as the example does with OrderStatusServiceTest. Without them, the deployment can fail on coverage even when the agent itself is fine.
Generating the manifest from retrieved files
You do not have to write the file by hand. Salesforce CLI can generate one from the source in your project.
sf project generate manifest \
--source-dir force-app/main/default/bots \
--source-dir force-app/main/default/genAiPlanners \
--source-dir force-app/main/default/genAiPlugins \
--source-dir force-app/main/default/genAiFunctions \
--name manifest/package.xmlThe command reads the folders you list and writes a manifest with a named member for each component it finds. Review the output before you use it. It lists what is in the folders, not what the agent depends on, so you still add Apex classes, Flows, and permission sets from your inventory.
You can also generate a manifest from an org with --from-org, which captures components that exist in the org but are not yet in your project:
sf project generate manifest \
--from-org source-org \
--included-metadata Bot \
--included-metadata GenAiPlanner \
--name manifest/package.xmlFlag names can differ between CLI versions. Run sf project generate manifest --help to confirm what your version supports.
Validating the manifest
Before a real deployment, check the manifest against the target org. A validation-only deployment runs the same checks as a real one but saves nothing.
sf project deploy start \
--manifest manifest/package.xml \
--target-org target-org \
--dry-runWhen validation passes, run the same command without --dry-run. Using the same manifest for both steps means the validated set is the deployed set.
How the manifest relates to the other pieces
The manifest sits between your inventory and the deployment. The diagram shows the flow.
The loop between validation and the manifest is normal. Expect to adjust the file at least once.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| A `Bot` deploys but has no topics | `GenAiPlugin` or `GenAiPlanner` is missing from the manifest | Add both types and redeploy |
| An action fails with a missing target | The Apex class or Flow behind a `GenAiFunction` is not in the manifest | Add it from the dependency inventory |
| Deployment fails on Apex test coverage | Test classes are not included, or coverage is below the threshold | Add the test classes, then rerun validation |
| Retrieval returns fewer files than expected | A wildcard did not cover a type, or a member name is wrong | Name the members explicitly and check spelling and case |
| The agent deploys but cannot run actions | The permission set is missing or not assigned to the agent user | Add the permission set, then assign it in the target org |
| A manifest entry reports "no match found" | The member does not exist in the source | Check the API name against the files in your project |
A practical workflow
- Retrieve the agent metadata from the source org.
- List the agent's actions and find the Apex class, Flow, or other target behind each one.
- Generate a starting manifest with
sf project generate manifest. - Add the dependency components and the test classes by name.
- Replace broad wildcards with named members where you can.
- Run a validation-only deployment against the target org.
- Fix every error, and repeat until validation passes.
- Commit the manifest, then deploy.
Edge cases
- Components that already exist in the target org. A deployment overwrites a component of the same name. If the target has a different version of an Apex class, your deploy replaces it. Check this before you deploy to an org that other teams use.
- Several agent versions. Each
BotVersionis its own member. If you list only one version, only that version moves. - Dependencies outside the agent. Custom objects, fields, and custom metadata types that an Apex class or Flow uses must exist in the target org. Add them to the manifest or confirm they are already deployed.
- API version. The
<version>value must support the agent metadata types you use. If a type is rejected, raise the version and test again. - Deleting components. A manifest only adds or updates. To remove components from the target, you need a separate destructive changes manifest. Do not rely on
package.xmlfor removals.
Exercise
Your validation-only deployment fails with a coverage error. The manifest lists the agent's Apex class under ApexClass but no test class. What should you change, and why is a wildcard on ApexClass a poor fix?
Show answer
Add the test class for the agent's Apex class to the ApexClass members, then validate again. The tests supply the coverage the target org checks. A wildcard on ApexClass would also deploy every other class in the project, which adds unrelated code, slows the deployment, and can introduce new failing tests or coverage gaps.
Exercise
After deployment, the agent exists in the target org but has no topics. Which two metadata types do you check in the manifest first?
Show answer
Check GenAiPlanner and GenAiPlugin. The planner connects the agent to its topics, and each plugin is a topic. If either is missing from the manifest, the agent deploys without its topics.