Skip to content

Replay, edit and experiment from the panel

View as Markdown

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:

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

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; replays do not need it. The link opens under WEFT_ENV=dev. Connect your app to Studio’s playground covers the other options.

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.

VerbWhereWhat the drawer is set to
↦ replay from this step (step N)a step card, a tool callkeep steps 0 to N−1, run step N fresh
edit this result and replay (call c)a tool callfrom_step N+1, with the call’s recorded result pre-filled to edit
edit the prompt and replay (step N)a step cardrun step N fresh under an edited system prompt, pre-filled from the step’s request record
↻ re-run the whole turna step card, and ↻ Re-run under the turnthe whole turn again, from step 0, with the drawer’s prompt, tools and model; transcript edits dropped
⎇ continue here with a new messagea step card of a session’s top-level turna 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).

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).
  • 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).
  • 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.

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)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)
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.

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 gives each kind’s rules and what Studio refuses, such as edits with the scripted engine.

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.

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:

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.

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).

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.

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 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:

Terminal window
go test -run TestReplayEditedResult -v ./devtools
=== 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
  • 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)
  • 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)

Symbols used: runtime.Install · runtime.Agents · runtime.Local · runtime.Studio · runtime.Sessions · runtime.AllowSideEffects · weft.Replay · weft.ReplaySafe