Sub topic 13
Deploying and Versioning Flow-Based Actions
This chapter assumes you can build an autolaunched flow, register it as an action in Agent Builder, and test it in the agent preview. It covers how to move a finished action from a sandbox to production and how to change it safely afterward.
What you are actually deploying
A flow-based action is not one thing. It is a chain of metadata components, and each one has to exist in the target org before the action works.
| Component | Metadata type | Notes |
|---|---|---|
| The flow | `Flow` | Each saved version is stored as a separate flow version. |
| Custom objects and fields the flow reads or writes | `CustomObject`, `CustomField` | Must exist before the flow deploys. |
| Permission sets that grant access | `PermissionSet` | Needed for the run context you chose. |
| Apex classes, subflows, prompt templates | `ApexClass`, `Flow`, `PromptTemplate` | Only if the flow calls them. |
| The agent, topic, and action registration | `GenAiPlannerBundle`, `GenAiPlugin`, `GenAiFunction` | Names vary by API version, so check the Metadata API reference for your release. |
The last row matters most. The flow can arrive in production and still not be usable by the agent if the topic and action definitions did not come along. Check how your org and API version represent these types, and retrieve a known-good agent from a sandbox to see exactly what your release produces.
Flow versions and what "active" means
Every time you save a flow in Flow Builder, you create a new version. Only one version of a flow is active at a time. The action calls the flow by its API name, so it runs whichever version is active.
This has two consequences:
- Activating a new version changes the action's behavior immediately, including for conversations already in progress that have not yet called the action.
- Rolling back means activating an earlier version. Older versions stay in the org until you delete them, so rollback is quick as long as you have not cleaned them up.
Flow Builder keeps a limited number of versions per flow, so delete obsolete inactive versions deliberately rather than all at once. Keep the version you would roll back to.
Changes that break the action
Not all edits are equal. The agent's language model and the action registration both depend on the flow's interface, meaning its input and output variables. Treat that interface like a public API.
| Change | Risk | Safer approach |
|---|---|---|
| Edit logic inside the flow, keep variables the same | Low | Test and activate the new version. |
| Improve a variable description | Low to medium | The agent may start using the action differently. Retest conversations. |
| Add an optional input | Medium | The registration may need updating so the agent knows to collect it. |
| Rename or remove a variable | High | The registered action refers to the old name and can fail. |
| Change a variable's data type | High | Same as above, and existing prompts may no longer fit. |
If you must rename a variable, create a new flow with a new API name, register it as a new action, and retire the old one after testing. This gives you a clean rollback.
Deployment paths
You have three common options. Pick based on team size and how often the action changes.
- Change sets. You add components by hand in the source org and upload them to the target. This is simple for a one-off move. It is easy to miss a dependency, and change sets do not support every agent metadata type in every release.
- Salesforce CLI with source tracking. You retrieve metadata into a project and deploy it with commands. This fits teams that already use version control.
- A CI/CD pipeline. Automated jobs run the CLI deploy and tests on every merge. This is the right choice when several people change actions regularly.
Whichever path you use, deploy the building blocks first: fields, then permission sets, then the flow, then the agent definitions. The CLI resolves much of the ordering for you when everything is in one deploy, but a failed deploy often traces back to a missing prerequisite.
A CLI example
This package.xml retrieves the flow and the related permission set from the sandbox. Replace the names with your own.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Get_Case_Status</members>
<name>Flow</name>
</types>
<types>
<members>Agent_Case_Access</members>
<name>PermissionSet</name>
</types>
<version>62.0</version>
</Package>Retrieve it from the sandbox, then validate it against production without saving anything:
sf project retrieve start --manifest package.xml --target-org my-sandbox
sf project deploy start --manifest package.xml --target-org my-production --dry-run --test-level NoTestRunThe --dry-run flag validates the deployment and reports errors without changing the org. When validation passes, run the same command without --dry-run. Production deployments that include Apex normally need tests, so use a test level that fits your org's rules and any Apex the flow calls.
How flow status travels with a deployment
The flow's active or inactive status is part of the deployed metadata, and it depends on the org. Production can reject a deployment that would activate a flow when the org's deployment settings or test coverage requirements are not met. In some orgs, a deployed flow arrives as inactive and you must activate it yourself.
Check the status after every deployment. A common mistake is to see a green deploy result and assume the new logic is live. Open the flow in Setup and confirm which version is active.
Versioning the agent side
The agent's configuration also has versions. Agent Builder lets you save changes to topics, actions, and instructions, and an agent has to be activated before it serves real users. Plan these steps together with the flow:
- Deploy the flow and its dependencies, leaving the new version inactive if you can.
- Deploy the agent definition that refers to it.
- Test in the agent preview of the target org.
- Activate the flow version, then activate the agent version if it is not already active.
Keeping the old flow version inactive but present gives you a one-step rollback for the flow. The agent version can be rolled back by activating the previous agent version.
A release checklist
Use this list before you promote an action.
- The flow's input and output variable names and types match what is registered.
- Every variable description reads correctly for the agent, since the model uses it.
- The run context and permission sets exist in the target org and are assigned to the right users or to the agent's running user.
- Fault paths still return a usable error message, not a raw system error.
- The CLI validation (
--dry-run) passed. - You tested at least one success case and one failure case in the target org's preview.
- You know which flow version you would reactivate to roll back.
Common errors
- The deploy fails on a missing field. The flow references a field that is not in the target. Deploy the field first or include it in the same package.
- The action is missing after deploy. The agent registration was not part of the package. Retrieve and include the agent metadata types.
- The agent no longer calls the action. A description or variable changed. Compare the new descriptions with the old ones.
- The action runs but returns "no access" results. The permission set was deployed but not assigned in the target org. Permission set assignments are data, not metadata, so they do not travel with the deployment.
- Sandbox data does not exist in production. The flow works in testing because test records exist there. Use real production-shaped data when you test after release.
Summary
Treat a flow-based action as a set of linked components with a public interface. Keep variable names and types stable, deploy dependencies first, confirm the active version after each release, and keep a previous version available for rollback.
Exercise
You renamed the input variable caseNumber to caseNo in your flow, deployed it to production, and activated it. The agent preview now fails to pass the case number. What went wrong, and what should you have done?
Show answer
The action registration still refers to the old variable name caseNumber, so the input no longer maps to anything in the flow. Variable names are part of the flow's public interface. Instead of renaming, you should have created a new flow with a new API name, registered it as a new action, tested it, and retired the old one. To recover now, either reactivate the previous flow version or update the action registration to use caseNo.
Exercise
A deployment to production shows success, but the agent still behaves as it did before. Name two things to check.
Show answer
First, open the flow in Setup and confirm the new version is active, because deployed flows can arrive inactive. Second, confirm the agent topic and action registration were included in the deployment and that the agent version is active. Running the agent preview in production helps confirm both.