| Trace not found | CLI version issue | Update to sf CLI 2.131.0+ |
| `Nonexistent flag: --simulate-actions` on `preview start` | CLI older than 2.131.0 (plugin-agent <1.32.16)|UpdatetheCLI;below2.131.0only`--use-live-actions`exists|
| `Nonexistent flag: --no-prompt` on `preview end` | CLI older than 2.135.5 | Drop the flag — it only affects `end --all`, and single-session `end` never prompts |
| Action mock fails | Complex inputs | Use `--use-live-actions` flag |
| Context variables missing | Preview limitation | Use Runtime API for context tests |
| `jq` parse error on preview output | Control characters in CLI output | Use Python `re.sub` + `json.loads` (see below). `tr` via bash pipes is unreliable -- control chars survive `echo "$VAR"` expansion. |
### Defensive JSON Parsing
`sf agent preview` output may contain control characters (e.g. `\x08`, `\x1b`) that break `jq` and `json.loads`. Always sanitize before parsing.
**Use Python `re.sub`** -- this is the only reliable approach. The `tr` command via `echo "$VAR" | tr -d ...` is unreliable because bash variable expansion and `echo` can re-introduce or mangle control characters:
```bash
# Recommended: Python re.sub (handles all control characters reliably)
`When using --authoring-bundle, you must specify either --use-live-actions or --simulate-actions.` Add `--simulate-actions` (or `--use-live-actions` if you want real Apex/Flow execution) to `start`. Do **not** add it to `send` or `end` — they reject it with `Nonexistent flag`.
### `RequiresProjectError` on any `preview` subcommand
`This command is required to run from within a Salesforce project directory.` Run the command from the directory containing `sfdx-project.json`.
-`sf` CLI **2.131.0+** (plugin-agent 1.32.16+) — the floor for `preview start --authoring-bundle --simulate-actions`, which every example here uses. `start`/`send`/`end` as separate subcommands need 1.28.0; `--simulate-actions` needs 1.32.16 = CLI 2.131.0.