# agent trace delete

Delete trace files from an agent preview session.

## Description for agent trace delete

When you run an agent preview conversation (either interactive or programmatic), trace files are automatically recorded and saved in your local DX project. Use this command to delete some or all of the trace files.

By default, this command shows a preview of what will be deleted and prompts for confirmation. Use --no-prompt to skip confirmation.

Without filters, this comamnd deletes all trace files for all agents and sessions. Use flags to narrow the scope: filter by agent API name (--agent), by session (--session-id), or by age (--older-than).

## Flags

| Flag Name (Long) | Flag Name (Short) | Description                                                                                                                                                                                                                    |
| ---------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--agent`        | `-a`              | **Type:** Value<br><br>API name of the agent used to filter the list of trace files you want to delete. Matches against the API name used when starting the session, either an authoring bundle or a published agent API name. |
| `--flags-dir`    | N/A               | **Type:** Value<br><br>Import flag values from a directory.                                                                                                                                                                    |
| `--json`         | N/A               | **Type:** Boolean<br><br>Format output as json.                                                                                                                                                                                |
| `--no-prompt`    | N/A               | **Type:** Boolean<br><br>Skip the confirmation prompt and delete immediately.                                                                                                                                                  |
| `--older-than`   | N/A               | **Type:** Value<br><br>Duration used to filter the list of trace files; only files older than the duration are deleted. Accepts a number followed by a unit: m/minutes, h/hours, d/days, w/weeks. Examples: 7d, 24h, 2w.       |
| `--session-id`   | N/A               | **Type:** Value<br><br>Session ID used to filter the list of trace files you want to delete. Use the "agent preview sessions" CLI command to list all known agent preview sessions along with their session IDs.               |

## Examples for agent trace delete

Delete all traces for all agents and sessions; prompt for confirmation:

```shell
sf agent trace delete
```

Delete all traces for a specific agent:

```shell
sf agent trace delete --agent My_Agent
```

Delete traces from a specific session:

```shell
sf agent trace delete --session-id <SESSION_ID>
```

Delete traces older than 7 days:

```shell
sf agent trace delete --older-than 7d
```

Delete traces older than 24 hours for a specific agent; don't prompt for confirmation:

```shell
sf agent trace delete --agent My_Agent --older-than 24h --no-prompt
```

Delete all traces for all agents and sessions; don't prompt for confirmation:

```shell
sf agent trace delete --no-prompt
```
