Sub topic 11
Versions and Activation
This chapter covers how a prompt template changes over time, and how to release a change without breaking an agent that depends on the template. It assumes you can already build a template in Prompt Builder, add it to a topic as an action, and test it in Agent Builder, as earlier chapters showed. It also assumes you know the basics of Salesforce Setup and permission sets.
Why versions exist
A prompt template is not a single editable text. It is a container for one or more versions. Each version holds the actual prompt body, the model choice, and the resource configuration. The template itself holds the name, API name, type, and description.
This split matters because an agent action points at the template, not at one version. When the agent runs the action, Salesforce uses the version that is currently active. You can therefore draft a new version, test it, and switch to it without touching the agent.
Keep this in mind throughout the chapter. Editing a prompt is a release decision, because an active version is what live users get.
The version lifecycle
A version is always in one of two states: draft or active. Only one version of a template can be active at a time.
The practical rules are these:
- A draft version can be edited freely. It is not used by the agent.
- An active version is locked. To change it, you clone it into a new draft, edit the draft, and activate the draft.
- Activating a version makes the previously active version inactive. It does not delete it.
- An inactive version stays available, so you can reactivate it as a rollback.
The exact button labels and menu positions differ between Salesforce releases. Check the Prompt Builder interface in your org for the current wording.
Releasing a change safely
A safe release follows the same order each time.
- Clone the active version. Cloning copies the prompt body, model, and resources, so you start from a known good state.
- Edit the draft. Make one kind of change at a time, such as a rule, a resource, or a model.
- Preview in Prompt Builder with real records. Choose records that cover the normal case and the edge cases, such as a case with an empty description.
- Check the resolved prompt, not just the output. The preview shows the prompt after the merge fields are filled in. Confirm each field has the value you expect.
- Activate the draft.
- Test the agent in Agent Builder with the utterances that should trigger the action.
- Keep the previous version. If the agent test fails, reactivate the old version.
Changing several things in one version makes failures hard to diagnose. If the output gets worse, you will not know whether the model, the wording, or a new resource caused it.
What counts as a breaking change
Some edits are safe for the agent. Others break it. The difference is whether the template's inputs change.
| Change | Effect on the agent action | Risk |
|---|---|---|
| Reword instructions or rules in the body | None. Same inputs, same outputs. | Low |
| Change the model | Output style and quality may shift. | Medium |
| Add an optional resource, such as a related list | Inputs stay the same. Output may change. | Medium |
| Add a new required input | The action now needs a value the agent may not supply. | High |
| Remove or rename an input | The action's input mapping no longer matches. | High |
| Change the template type | Different supported resources and use. Treat as a new template. | High |
For high-risk changes, it is often cleaner to create a new template with a new API name, build a new action for it, and move the topic over. The old template keeps working until you retire it.
Adding an input to the example template
The Case summary template from earlier chapters takes a Case record. Suppose you want to add a language input so that summaries can be written in the customer's language. The new body might look like this:
You are a service assistant. Write a short, factual summary of the case below for a customer call hand-off.
Case number: {!$Input:Case.CaseNumber}
Subject: {!$Input:Case.Subject}
Status: {!$Input:Case.Status}
Description: {!$Input:Case.Description}
Rules:
- Use at most five sentences.
- Use only the information above. If something is missing, say it is unknown.
- Do not promise refunds or dates.The body above is unchanged on purpose. Adding a language input means adding a second input to the template and a matching line in the rules. That changes the action's inputs, which is a high-risk change. Treat it as a new version plus a new input mapping in the agent, and test both together.
Activation and the agent
Activation is the step that connects your work to live behavior. Three points are easy to get wrong.
First, an agent action can only use a template that has an active version. If no version is active, the action fails at run time, even though the template appears in the list of available templates.
Second, activation affects every caller. The agent is one caller. Flow and Apex can call the same template by API name, as a later chapter shows. Activating a new version changes the output for all of them at the same moment.
Third, activation does not change the agent's instructions. The topic text still says what the topic should do. If the new version returns a different shape of output, such as a list in place of a paragraph, the topic instruction "return its output to the user without rewriting the facts" still applies, but the user experience changes.
Permissions
Creating and activating templates is controlled by permissions. Typically you need a Prompt Builder permission set, such as the one that lets you manage prompt templates, and access to the objects the template reads. Names of permission sets change between releases, so check the current list in Setup.
Plan the permissions with the release process in mind. Many teams let developers create drafts but restrict activation to a smaller group. This gives you a review step before a prompt reaches users.
Also remember that the template reads data on behalf of a user. If the running user cannot see a field, the merge field may resolve to empty. A version can preview correctly for an admin and still return thin output for a service agent user. Test activation with a user who has the same access as the real audience.
Moving between orgs
Prompt templates are metadata, so you can move them between a sandbox and production using your normal deployment tooling, such as change sets or Salesforce CLI. A common flow is:
- Build and test the draft in a sandbox.
- Deploy the template and any dependent Flows or Apex classes to production.
- Verify the deployed version in production.
- Activate it there, after a preview with production-like records.
Dependencies deploy only if you include them. If the template uses a Flow or Apex resource, that resource must exist in the target org first. Otherwise the deployment fails, or the template cannot resolve the resource when it runs.
Check whether your deployment keeps the activation state or arrives as inactive. Behavior depends on the metadata type and your tooling. Do not assume. Verify after each deployment.
Common errors
- The agent ignores your edit. You saved changes to a draft but never activated it. The agent still uses the old active version.
- The action fails at run time. No version of the template is active, for example after a deployment that arrived inactive.
- The action input is missing. A new required input was added, but the action's input mapping in the agent was not updated.
- Output differs between preview and agent. The preview used a record you can see in full. The agent's running user has narrower field access.
- You cannot edit the active version. This is expected. Clone it into a new draft.
- Rollback is impossible. Someone deleted the previous version. Keep at least one known good inactive version until the new one has proven itself.
A release checklist
Use this before each activation:
- The change is one kind of change.
- Inputs are unchanged, or the action mapping is updated in the same release.
- Preview passes with at least one normal record and one record with missing fields.
- The resolved prompt shows correct merge field values.
- The running user's permissions were tested.
- The previous version is kept and can be reactivated.
- After activation, the agent was tested with the real trigger utterances.
Exercise
You edit the rules in the active version of the Summarize_Case template to say "Use at most three sentences", save, and test in Agent Builder. The agent still returns five-sentence summaries. What are the two most likely causes, and what should you do?
Show answer
Either the active version is locked and your edit was made on a new draft that was never activated, or you edited a draft and forgot to activate it. In both cases the agent keeps using the old active version. Open the template, confirm which version is active, preview the draft, then activate it and retest the agent. Keep the previous version so you can reactivate it if the three-sentence output fails.
Exercise
A teammate wants to add a required input called Language to the Summarize_Case template and activate the new version immediately. Why is this risky, and what is a safer approach?
Show answer
Adding a required input changes the action's contract. The agent's action mapping does not supply a value for it, so calls can fail or return incomplete output. A safer approach is to clone the version, add the input, update the action's input mapping and topic instructions, test both in preview and Agent Builder, and then activate. For a larger change, create a new template with a new API name and move the topic to a new action.