End an existing programmatic agent preview session and get trace location.
Description for agent preview end
You must have previously started a programmatic agent preview session with the "agent preview start" command to then use this command to end it. This command also displays the local directory where the session trace files are stored.
The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this command to end the session. You don't have to specify the --session-id flag if an agent has only one active preview session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring bundle or the published agent, respectively. To find either API name, navigate to your package directory in your DX project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata directory.
Use the --all flag to end all active preview sessions at once. You can combine --all with --api-name or --authoring-bundle to end only sessions for a specific agent, or use --all on its own to end every session across all agents in the project.
Flags
| Flag Name (Long) | Flag Name (Short) | Description |
|---|---|---|
| <code>‑‑all</code> | N/A | Type: Boolean<br><br>End all active preview sessions. Combine with --api-name or --authoring-bundle to limit to a specific agent, or use with only --target-org to end sessions for all agents found in the local session cache. Requires --target-org. |
| <code>‑‑api‑name</code> | <code>‑n</code> | Type: Value<br><br>API name of the activated published agent you want to preview. |
| <code>‑‑api‑version</code> | N/A | Type: Value<br><br>Override the api version used for api requests made by this command |
| <code>‑‑authoring‑bundle</code> | N/A | Type: Value<br><br>API name of the authoring bundle metadata component that contains the agent's Agent Script file. |
| <code>‑‑flags‑dir</code> | N/A | Type: Value<br><br>Import flag values from a directory. |
| <code>‑‑json</code> | N/A | Type: Boolean<br><br>Format output as json. |
| <code>‑‑no‑prompt</code> | <code>‑p</code> | Type: Boolean<br><br>Don't prompt for confirmation before ending sessions. Has an effect only when used with --all. |
| <code>‑‑session‑id</code> | N/A | Type: Value<br><br>Session ID outputted by "agent preview start". Not required when the agent has exactly one active session. Run "agent preview sessions" to see the list of all sessions. |
| <code>‑‑target‑org</code> | <code>‑o</code> | Type: Value<br>Required<br><br>Username or alias of the target org. Not required if the target-org configuration variable is already set. |
Examples for agent preview end
End a preview session of a published agent by specifying its session ID and API name; use the default org:
sf agent preview end --session-id <SESSION_ID> --api-name My_Published_Agent
Similar to previous example, but don't specify a session ID; you get an error if the published agent has more than one active session. Use the org with alias "my-dev-org":
sf agent preview end --api-name My_Published_Agent --target-org my-dev-org
End a preview session of an agent using its authoring bundle API name; you get an error if the agent has more than one active session.
sf agent preview end --authoring-bundle My_Local_Agent
End all active preview sessions for a specific agent without prompting:
sf agent preview end --all --authoring-bundle My_Local_Agent --target-org <target_org> --no-prompt
End all active preview sessions across every agent in the local session cache for an org:
sf agent preview end --all --target-org <target_org>
<!-- prettier-ignore-end -->