Sub topic 3
Finding everything the agent depends on
This chapter assumes you know basic Salesforce administration, Salesforce DX project structure, and the Agentforce concepts of agents, topics, and actions. It also assumes you know what Apex classes and Flows are. The goal is to build a complete list of what the agent needs before you retrieve or deploy anything.
Why an inventory comes first
An agent's own metadata (Bot, BotVersion, GenAiPlanner, GenAiPlugin, GenAiFunction) is only part of what it needs at runtime. Each action calls something else, such as an Apex class or a Flow. Those components read objects and fields, and users need permissions to run them. If one of these is missing in the target org, the deployment fails, or it succeeds and the agent breaks when someone uses it.
A dependency inventory is a written list of every component the agent needs. You build it once in the source org and use it to write the manifest later.
Walk the agent from the top down
Start at the agent and follow each link until you reach something that does not call anything else.
- Agent. Note the agent name and the agent user it runs as.
- Topics. List each topic. A topic is stored as a GenAiPlugin.
- Actions. List each action under each topic. An action is stored as a GenAiFunction.
- Action targets. For each action, record what it invokes: an Apex class, a Flow, or a prompt template.
- Objects and fields. For each target, record the standard and custom objects and fields it reads or writes.
- Access. Record the permission sets that grant access to those classes, Flows, objects, and fields.
Where to look in the source org
You can gather most of this from Setup and from retrieved files.
- Agentforce Builder. It shows each topic and its actions, and the target type of each action.
- Setup, Apex Classes and Flows. Open each target to see which objects it uses.
- Retrieved metadata. After you retrieve the GenAiFunction files, search them for the target names. The next chapters cover retrieval.
- Permission sets. Check which sets list the Apex classes and Flows as enabled.
A quick search over retrieved files saves time. This command lists the target of each action, assuming a standard DX project layout:
grep -r "invocationTarget" force-app/main/default/genAiFunctionsEach match shows the Apex class or Flow name that the action calls. Add those names to your inventory.
Record the inventory in a table
A simple table keeps the list reviewable. Here is an example for a service agent.
| Component | Type | Needed by | Notes |
|---|---|---|---|
| My_Service_Agent | Bot | Agent | Runs as the agent user |
| Order_Status | GenAiPlugin | Topic | Order questions |
| Get_Order_Status | GenAiFunction | Action | Calls the Flow below |
| Get_Order_Status_Flow | Flow | Action target | Reads Order records |
| OrderLookupService | ApexClass | Flow | Invoked from the Flow |
| Order__c | CustomObject | Flow, Apex | Must exist in the target |
| Agent_Action_Access | PermissionSet | Agent user | Grants class and Flow access |
Check the hidden dependencies
Some dependencies do not appear in the agent's own files. Check these.
- Nested calls. A Flow can call a subflow or an Apex action. Include each of them.
- Custom objects and fields. If the target org lacks them, the Flow or Apex will not compile there.
- Prompt templates and other features. An action may rely on a prompt template or a data source. Add them to the list.
- Settings that are not metadata in your project. Features such as Einstein generative AI must be enabled in the target org. The next chapter covers this.
Common errors
- Listing only agent types. Deployment fails because an Apex class or Flow is missing.
- Forgetting permission sets. The deployment works, but the agent user cannot run the action.
- Assuming wildcards cover everything. A
*member includes every component of that type in the source org, not only the ones the agent needs. Use the inventory to narrow the list later.
Exercise
An action in your agent calls a Flow, and that Flow calls a subflow and reads a custom object. Name the four things from this chain that belong in your dependency inventory, besides the action itself.
Show answer
The Flow, the subflow, the custom object (and any custom fields it reads), and the permission set that grants access to the Flow and the object.
Exercise
Why is a list containing only Bot, BotVersion, GenAiPlanner, GenAiPlugin, and GenAiFunction not enough to deploy a working agent?
Show answer
Those types describe the agent, its topics, and its actions, but the actions call Apex classes and Flows that use objects and fields. Users also need permission sets to run them. If any of these is missing in the target org, the deployment fails or the agent breaks at runtime.