---
title: Replay, edit and experiment from the panel
description: Replay a turn from any step, edit a tool result, the prompt, a reply, a steer or a call's arguments in place, preview what will be sent, and run it as an experiment from the devtools panel's story tab; the verbs need weft/runtime and a token that may act.
url: https://weftgo.dev/docs/observe/devtools/replay/
type: how-to
sources:
  - 'W11-auditB2-fix, v0.20.2: weft/studio/web/src/panel/element.ts:5556-5586 (open in playground ⤢, discard), 5786-5797, 6126-6145 (steer this run)'
  - 'weft/studio/README.md:763-832 (Replay from here, plan F1: the verbs, from_step bounds, the drawer pre-filled from lib/replay.ts, the ack preview and prefix line, what holds Run, a child''s verbs, the result pane, ↖ t3 step 2, canReplay)'
  - weft/studio/README.md:2533-2537 (the panel hands the playground its fields in the fragment, read once and stripped)
  - 'weft/AGENTS.md:370-375 (block 7: plan F1 replay verbs, F2 in-place edits, the will be sent preview, weft.edits as chips)'
  - weft/CHANGELOG.md:1481 (the panel's replay verbs, plan F1.3), 1753 (⎇ Continue from step N and compare in Studio send the step ordinal), 1757 (↻ Re-run opens the drawer)
  - 'weft/studio/web/src/panel/element.ts:4027-4027 (edBox: data-weft-editable, edit …, the drawer opens first, edited / inserted, revert), 4280-4284 (the side effects note), 6292 (↻ Re-run''s title), 6650-6664 (the verbs'' labels), 7281-7330 (insert a message before step N / after the last step), 7671-7718 (studioPlaygroundLink: the fragment hand-off)'
  - 'weft/studio/web/src/panel/editor.ts:1-125 (will be sent · step N''s request), 214-214 (the weft.edits mark: kept prefix edited)'
  - 'weft/studio/web/src/lib/replay.ts:127-212 (the drafts: replay from this step, edit this result and replay, edit the prompt and replay, re-run, continue here), 370-393 (tokenScopeOf, canReplay), 474-478 (REPLAY_OFF)'
  - 'weft/studio/web/src/lib/edits.ts:158-167 (impliedFromStep), 53-55 (FORK_EDITS), 375-427 (the weft.edits mark: MARK_CHIPS, +N more, none on a child run)'
  - weft/studio/web/src/lib/preview.ts
  - weft/studio/web/src/panel/replay.test.ts, edit.test.ts, experiment.test.ts, playground.test.ts
  - 'docs-site/examples/devtools/appturns_test.go:TestReplayEditedResult (a tool_result edit of an app turn: forked_from <run>#1, weft.edits 0:c2:result)'
  - 'docs-site/factcheck/playground.md (finding 18: the step cards'' verb labels)'
  - 'observed: Chromium (Playwright 1.62.0) against a scratch app embedding weft studio v0.17.0 with runtime.Local and runtime.Sessions (WEFT_DISCOVERY=off): a finished two-step turn''s verbs are replay from this step (step 0), edit the prompt and replay (step 0), re-run the whole turn, continue here with a new message, edit this result and replay (call call_track_3), replay from this step (call call_track_3, step 0); edit this result opened the drawer titled Experiment · acme-support · continue from step 1 with Edit this result and replay, the before you run preview (step 0 kept; refund substituted, requires approval; track runs, replay safe) and will be sent · step 1''s request; after editing the result and Run experiment, the result pane showed Result · t2·x2, keep as prompt ⤴, save as test, compare in Studio, discard, the diff vs t2; the new turn row read experiment of t2 with ↖ t2 step 1; the replayed run read kept prefix edited · from <source>#1 with result edited step 0 · call call_track_3, its meta weft.edits 0:call_track_3:result; under a read panel token no verb was drawn'
  - 'weft/studio/web/src/panel/element.ts:4466-4514 (an unplaced edit: gap, not in the steps read · Run held), 4547-4611 (every hold on Run), 4027 (engine live: transcript edits need it)'
  - weft/studio/web/src/lib/replay.ts:107-125 (an empty result seeds no edit)
  - weft/AGENTS.md:515 (playground runs carry weft.playground, never weft.session.id)
  - 'weft v0.20.2: weft/studio/web/src/lib/drawer-spec.ts:5-41 (DRAWER_ORDER and DRAWER_TITLES: source, target, engine, 1 what changes, 2 will be sent, 3 tools during the replay, advanced: side effects · where it writes · options, run), 47-51 (Write to: nowhere (ephemeral) | a new session (fork)), 74-75 (BREAKPOINTS_MOVED); lib/replay.ts:443-457 (VERB_TITLES, REPLAY_OPEN ✎ Replay…, REPLAY_TITLE Replay; panel/element.ts:3773: the drawer titled Replay · <agent>); lib/engine.ts:272-278 (runLabel: Run on scripted · 0 tokens, Run live on <model> · …); lib/glossary.ts:278 (✎ Experiment and Run experiment ▶ as aliases); lib/replay.ts:433-441 (REPLAY_WORDS: the chip replay of <turn> · step N, the result head Replay n of <turn>); lib/run-row.ts:36, 103 (the ↻ glyph); panel/playground.ts:293-306 (experimentLabel); panel/editor.ts:47 (kept prefix edited); weft/studio/README.md:787-820 (U17: the order on both surfaces; the engine choice; breakpoints point to /runtimes); weft/CHANGELOG.md:136, 138-141 (0.19.0: Break on gone, engine per command, the drawer order, the replay words, the target check), 60 (0.20.0: ✎ Experiment is ✎ Replay…, Write to)'
---

# Replay, edit and experiment from the panel

Hover or focus a step card in the panel's story and it offers replay verbs: replay from this step, edit this result and replay, edit the prompt and replay, re-run the whole turn, and continue here with a new message. Each opens the replay drawer pre-filled for that verb, with a preview of which tools will run and of the exact request that will be sent. **Run** posts it. The replay runs in your app as a playground run (a `pg_…` id, never part of your session), listed in the turn list. You can also click a tool result, a reply, a prompt, a steer or a call's arguments to edit it in place. The verbs need your app connected to Studio with `weft/runtime`, and a token that may act.

Connect the app's runtime to the embedded Studio, in `docs-site/examples/devtools/appturns.go`:

```go title="devtools/appturns.go"
// resolve is the runtime.Sessions resolver: the app's live Session
// behind a public id, with nothing to release (the app keeps writing
// it). (nil, nil, nil) says the conversation is not this app's.
func (c *conversations) resolve(ctx context.Context, publicID string) (*thread.Session, func(), error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	if s, ok := c.live[publicID]; ok {
		return s, nil, nil
	}
	return nil, nil, nil
}

// install opens the runtime link with the opt-in: the app's own turns
// then take the panel's continue / skip / resolve and steer. The link
// opens under WEFT_ENV=dev; extra adds the caller's options.
func (c *conversations) install(link runtime.Option, extra ...runtime.Option) (shutdown func()) {
	return runtime.Install(append([]runtime.Option{
		link, // runtime.Local(srv) for an embedded Studio, else runtime.Studio(url, token)
		runtime.Agents(c.agt),
		runtime.Sessions(c.resolve),
	}, extra...)...)
}
```

[devtools/appturns.go on GitHub](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/devtools/appturns.go)

`runtime.Agents` is what makes replays possible: the drawer runs the agents a connected runtime registered. `runtime.Sessions` is for [your app's own turns](https://weftgo.dev/docs/observe/devtools/app-turns/); replays do not need it. The link opens under `WEFT_ENV=dev`. [Connect your app to Studio's playground](https://weftgo.dev/docs/observe/playground/connect/) covers the other options.

## Replay verbs

The verbs show on hover and on keyboard focus, on step cards, tool calls, steers, a subagent call's child row and the child's own steps. Each carries an `aria-label`; `Enter` or `Space` on a verb runs it, and `Escape` moves on to the panel.

| Verb | Where | What the drawer is set to |
|---|---|---|
| `↦` replay from this step (step N) | a step card, a tool call | keep steps 0 to N−1, run step N fresh |
| edit this result and replay (call c) | a tool call | `from_step` N+1, with the call's recorded result pre-filled to edit |
| edit the prompt and replay (step N) | a step card | run step N fresh under an edited system prompt, pre-filled from the step's request record |
| `↻` re-run the whole turn | a step card, and **↻ Re-run** under the turn | the whole turn again, from step 0, with the drawer's prompt, tools and model; transcript edits dropped |
| `⎇` continue here with a new message | a step card of a session's top-level turn | a fork: a new session, with the turn's history, that runs your message |

**✎ Replay…** under the turn (named **✎ Experiment** before 0.20.0) opens the same drawer from the agent's registered config. `from_step` and an edit's step are the step ordinal, the same number Studio shows. The verbs are drawn only up to the highest `from_step` the server accepts for the transcript: a last step's results can be edited only when all its calls are answered there, and a turn without a transcript gets no edit or steer verb.

A child's verbs replay the child as its own run of the child row's agent. An agent no connected runtime registers is said in the drawer, and nothing is posted. A turn derived from stock OTel spans has no transcript, so its verbs are drawn disabled with the badge's words.

The verbs and the drawer are drawn only when Studio reports the `playground` capability and the token may act: no token in setup A, the dev token, or a playground-scoped panel token. A read-scoped panel token sees none of them ([Secure the devtools panel](https://weftgo.dev/docs/observe/devtools/security/#what-each-token-can-do)).

## The replay drawer

The drawer opens under the turn, focus on the verb's own field, and returns focus to the verb when it closes. Its title is the verb's (`Replay from this step`, `Edit this result and replay`, `Edit the prompt and replay`, `Re-run`, `Continue here with a new message`), or `Replay · <agent>` when **✎ Replay…** opened it. It posts the same command Studio's replay drawer posts for the same draft, byte for byte. Since 0.19.0 both drawers read in one order, top to bottom:

- **source** and **target**: the run and step it replays, and the agent it runs. A source that names no agent, or one no connected runtime registers, holds Run until you pick one ([the target check](https://weftgo.dev/docs/observe/playground/replay/)).
- **engine**: two radios, `scripted` and `live`, chosen per command, one option a line with its reason under it (the chosen one in the foreground colour), so a 640 px dock does not wrap them into two columns. It opens on `scripted` when the recorded answers can serve the replay (a source run, no edit, no prompt, model, input, fork, tools, thinking or tool-choice change, a `from_step` the source answered), else on `live`, which says what it calls and roughly what it costs.
- **1 what changes**: the verb's edit with the value to change and a **drop** button, the system prompt (`↺` resets it), tools, model and thinking, each greyed at the agent's default until you change it; the transcript edits with the steps they keep.
- **2 will be sent · step N's request** (below).
- **3 tools during the replay**: the ack preview. The prefix line comes first: `step 0 kept`, and `· the compacted prefix (what the model saw at step 3)` when a compaction view applies. Then each tool of the step's catalog and what it will do, in the playground's words: `runs`, `substituted` (from the recorded result when the call repeats, else parked) or `parked`. It is redrawn as you change tools or side effects.
- **advanced: side effects · where it writes · options**, folded: side effects (`substitute`, `park`, `allow`), **Write to** `nowhere (ephemeral)` or `a new session (fork)`, and the option lab's knobs ([Run experiments with the option lab](https://weftgo.dev/docs/observe/playground/experiments/#the-option-lab)).
- **Run**, which names the engine: `Run on scripted · 0 tokens`, or `Run live on <model> · ≈ $x`.

Runtime-wide breakpoints are not a replay knob: where **Break on (parks every run)** was before 0.19.0, the drawer links to the [Runtimes page](https://weftgo.dev/docs/observe/playground/runtimes/#breakpoints).

![The panel's replay drawer opened with ✎ Replay…: the target's Runs in line naming the acme-app runtime, the engine (scripted, 0 tokens, or live), what changes (system prompt, tools, model, thinking, input), the request that will be sent, and the tools during the replay (lookup_order runs, refund and send_email substituted)](https://weftgo.dev/docs/_astro/panel-experiment-drawer.light.BCAA_yYf.webp)

*The replay drawer opened from the turn, its overrides greyed at the agent's defaults, and the preview of the tools during the replay: lookup_order runs, refund is substituted.*

Run is held, among other cases, while side effects `allow` would be refused because a tool left on is not opted in with `runtime.AllowSideEffects`. It is held while a pre-filled edit names a call the steps read do not show (badged `gap`, `· not in the steps read · Run held`). It is held while an option-lab knob or an in-place edit is refused, or while the preview is pending or refused. It is held while a fork carries edits, and while the step's catalog is still being read. An empty recorded result seeds no edit. **continue here** waits for a message that is not blank. **↻ Re-run** never posts at once: it opens the drawer, and Run posts.

## Edits

Every value the story shows that a replay can change is editable in place: the turn's prompt, a reply, a steer, a tool result, a call's arguments, and a message inserted between steps (`· insert a message before step 1`, `· insert a message after the last step`). An editable node is a button titled `edit …`. Clicking it, or `Enter`, opens the drawer if it is not open, then the editor in place.

Each edit becomes part of the drawer's one command and shows in the story as `edit · the result of track (call_track_3)` with an `edited` (or `inserted`) badge and a **revert** button. The kept prefix must contain every edited step, so the drawer's `from_step` moves up with the edits: an edit of step N needs `from_step` N+1 or later, an insert before step N needs N. A fork carries no edits: it starts at step 0. A call's arguments are JSON, checked against that step's tool schema before you can run; Studio checks them again when the command arrives.

The edit kinds are the playground's `transcript_edits`: `tool_result`, `reply`, `user`, `tool_args` and `insert`. [Replay a run from any step, with edits](https://weftgo.dev/docs/observe/playground/replay/#edits) gives each kind's rules and what Studio refuses, such as edits with the scripted engine.

### What will be sent

Above Run, **will be sent · step N's request** lists the replay's first request, message by message, each marked `same` as the recorded request or changed. It comes from `POST /api/playground/preview` (Studio's `preview` capability), which assembles the request without running anything and needs no runtime. Use it to check that an edit landed where you meant before you spend a model call.

### Edited runs carry `weft.edits`

A replay whose kept prefix was edited records which pairs in its run metadata, `weft.edits`. For one edited tool result at step 0 it is `0:call_track_3:result`; an argument edit is `<step>:<call>:args`. The panel reads it back on the replayed turn as a mark and chips:

```text
kept prefix edited · from s_01M5…-t2#1
result edited  step 0 · call call_track_3  order 4411 was delivered yesterday
```

The chips read `result edited`, `args edited`, `inserted`, or `edited` (a reply or user message). A long list is capped, ending `+N more`. Studio's run page shows the same marks. A subagent child of a replayed run inherits its parent's metadata but not the mark, because its own transcript was not edited.

## The result

After Run, the result streams under the drawer, titled with the replay's number and its source turn, its engine and its state (`Replay 2 of t2 · scripted · finished`; `Result · t2·x2` before 0.19.0):

- the replayed run's status, tokens and cost, and `N replays of this turn` summed;
- its id, linked to the source step (selected in the panel, `⤢` to Studio's run page) and `open the replayed run ⤢`;
- the reply, a diff against the source turn's reply, and a step-by-step comparison (`steps vs source`);
- **keep as prompt ⤴**, which copies the drawer's prompt and, with Studio's `proposals` capability and the dev token or no token, proposes it as the agent's prompt. A panel token copies only and is told "a proposal needs the dev token";
- **save as test**, **open in playground ⤢** (named **compare in Studio** before 0.20.0) and **discard**, which clears the result pane;
- while the replay runs, under the `steer` capability and a token that may act, a **steer this run** box: a field ("a message delivered mid-flight") and a **steer** button that delivers one user message into the running replay.

A parked replay shows its approval controls in the result pane. The replay, a playground run, also joins the turn list as its own row, with a `↻ replay of t2 · step 2` chip and a `↖ t2 step 2` button back to its source ([Turn chips](https://weftgo.dev/docs/observe/devtools/reading-runs/#turn-chips)).

## Hand-off to the playground

**open in playground ⤢** opens Studio's `/playground` in a new tab with the drawer's whole command carried over: the source run and step being read, and only what changed (the prompt, the tools left on, model, thinking, input, engine, side effects, thread, the agent and runtime, the option lab's knobs and the edits). Everything rides in the URL fragment, `/playground#run=…&instructions=…`. A fragment never reaches a server, a log or a `Referer`, so a long prompt, which is your app's content, does not either. The playground reads the fragment once, fills its form, and strips it from the address bar; its **Copy link** never includes a prompt.

## Complete example

`appturns.go` holds the runtime wiring above and the conversations it resolves. In a browser, against an app built like it with Studio embedded at `/studio/`:

1. Ask the chat something that calls a tool, and let the turn finish.
2. In the panel's story, hover the tool call and choose **edit this result and replay**.
3. Change the result. **3 tools during the replay** lists each tool's fate, and **2 will be sent** marks the edited tool message as changed.
4. Choose **Run** (it names the engine: an edit runs `live`). The result pane shows the new reply and its diff, and the turn list gains a row chipped `↻ replay of t1 · step 1` whose story starts `kept prefix edited`.

`TestReplayEditedResult` in [`appturns_test.go`](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/devtools/appturns_test.go) posts the command those steps build, offline against an in-process Studio: a `tool_result` edit of the app's turn, `from_step` 1. The replay runs in the app's runtime, and its run carries the mark the panel reads back:

```sh
go test -run TestReplayEditedResult -v ./devtools
```

```text
=== RUN   TestReplayEditedResult
    appturns_test.go:433: POST /api/playground/runs: 202 {"command_id":"cmd_edit_1","state":"queued"}
    appturns_test.go:433: command: {State:finished RunID:pg_01M579NPX4RWKMMPCXPHN1PV8G Status:succeeded Error:<nil>}
    appturns_test.go:449: replay: forked_from s_01M579NPWSY0B65JE0E6ZYBFN0-t1#1, weft.edits 0:c2:result
--- PASS: TestReplayEditedResult (0.04s)
PASS
```

## Best practices & gotchas

- **Install `weft/runtime` in the app you are debugging.** The verbs run the agents a connected runtime registered; with none, the drawer says the agent is not registered and posts nothing. (Source: `studio/README.md:821-823`)
- **Mint a playground-scoped token for a page that should replay.** `canReplay` hides every verb under a read-scoped panel token, rather than showing dead buttons. (Source: `lib/replay.ts:459-468`)
- **Mark read-only tools `weft.Replay(weft.ReplaySafe)`.** Unannotated tools are substituted from the recording or parked in a replay; the ack preview shows which before you run. (Source: `studio/README.md:786-790`; [Mark tools replay safe](https://weftgo.dev/docs/observe/playground/overview/#mark-tools-replay-safe))
- **Check `will be sent` before Run.** It is assembled without a model call, and shows whether an edit changed the message you meant. (Source: `AGENTS.md:375`; `lib/preview.ts`)
- **Use the live engine with edits.** The scripted engine replays recorded turns, which answered a different prompt; the drawer says so and Studio refuses the command. (Source: `panel/element.ts:4250`; `AGENTS.md:536`)

## See also

- [Replay a run from any step, with edits](https://weftgo.dev/docs/observe/playground/replay/)
- [How does the playground work?](https://weftgo.dev/docs/observe/playground/overview/)
- [Run experiments with the option lab](https://weftgo.dev/docs/observe/playground/experiments/)
- [Read a run in the panel](https://weftgo.dev/docs/observe/devtools/reading-runs/)
- [Secure the devtools panel](https://weftgo.dev/docs/observe/devtools/security/)

Symbols used: [`runtime.Install`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Install) · [`runtime.Agents`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Agents) · [`runtime.Local`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Local) · [`runtime.Studio`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Studio) · [`runtime.Sessions`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Sessions) · [`runtime.AllowSideEffects`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#AllowSideEffects) · [`weft.Replay`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Replay) · [`weft.ReplaySafe`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ReplaySafe)
