---
title: Pause runs at breakpoints, then steer or cancel them
description: Park chosen tools on the runs your runtime starts and, with runtime.Breakpoints(), on your app's own runs; decide parked playground runs from Studio, steer a running one, or cancel it.
url: https://weftgo.dev/docs/observe/playground/breakpoints/
type: how-to
sources:
  - 'weft/runtime/breakpoints.go:12-79 (Breakpoints: a core.ParkSource bound lazily to the live links; read once per run; the union; RequireApproval-style park; Subagent child; who decides: thread turns only with Sessions and a public id, a plain Generate is the app''s; process-wide; a dropped stream keeps its set; a stopped link leaves the park; playground runs skipped; inert without a link; breakpoints_own), 80 (Breakpoints), 82-92 (weft.playground, weft.session.id, weft.public_id), 128-173 (breakpointSource)'
  - 'weft/docs/adr/0030-a-dynamic-park-source.md (decision 1: core.ParkSource read once per run, merged as ParkOn; 2: answer promptly, a panic parks nothing; 3: behaviour, not an override: no weft.override.* and the hash unchanged; 4: Agent.ParkSources)'
  - weft/runtime/example_test.go:101 (ExampleBreakpoints)
  - 'weft/runtime/executor.go:1041-1049 (breakpointTools: the stored set filtered to the agent''s tools), 1273-1316 (a deny without a reason: skipped from the devtools panel)'
  - 'weft/runtime/link.go:674-739 (dispatchDecision: unknown decision, no parked run, a call not parked, already decided; the run resumes once every parked call is decided), 1084 (breakpointSet), 1127-1155 (steer: an ephemeral run''s queue, a fork''s thread steer, else dropped with a Debug line)'
  - weft/runtime/sessions.go:40-44 (skippedReason)
  - 'weft/studio/debugger.go:1-11 (the debugger''s rungs 3–4; app-owned turns viewer-only unless runtime.Sessions), 22-87 (serveBreakpoints: panel tokens refused; every name a registered tool; 200 {tools}), 89-223 (serveSteer: 202 {steered}; app-owned 403)'
  - 'weft/studio/playground.go:1054-1197 (servePlaygroundApproval: decisions approve, deny, resolve; call_id; the pending set from run_finish; app-owned turns; 202 {command_id, state})'
  - 'weft/studio/cancel.go:65-146 (serveCancel: 404, app-owned, 409 parked, 409 finished, 503, 202 cancelling)'
  - 'weft/studio/appturn.go:1-61 (app-owned turn: the 403 and its fix)'
  - weft/studio/runtime/runtime.go:455-471 (Breakpoints, SteerMessage frames), 603-640 (RuntimeView.Breakpoints, BreakpointsSetAt)
  - 'weft/studio/web/src/components/studio/breakpoints.tsx:1-5 (the editor on /runtimes; it lived on Settings'' runtimes card; the pointer the playground form leaves where Break on was), 17-30 (BreakpointsPointer: the link and the count), 32-140 (Breakpoints: one checkbox per tool, applied on change by PUT with surface runtimes; follows the stored set; a refused change undone, its error shown; clear all; the every-tool warning); weft/studio/web/src/lib/drawer-spec.ts:74-75 (BREAKPOINTS_MOVED)'
  - 'weft/CHANGELOG.md:108 (0.19.0: GET /api/runs/{id}/commands, a lost decision marked), 136 (0.19.0: the playground form and the drawers no longer carry Break on; the editor moved to components/studio/breakpoints.tsx and /runtimes), 87 (0.20.0 Breaking: cancel and steer on an app turn refused at once, 409)'
  - 'weft/studio/cancel.go:55-58, 95-110 (an app turn with a Sessions runtime: 409, the parked case first); weft/studio/debugger.go:128-131, 176-191 (a steer on a parked or finished app turn: 409); weft/studio/runtime/runtime.go:1776-1790 (RunCommand, CommandsOn)'
  - 'weft/studio/runtime/runtime.go:2100-2162 (SetBreakpoints: stored only once delivered), weft/studio/runtime/store.go:227-242 (saveBreakpointsLocked: PutBreakpoints on the command store), weft/obsdb/commands.go:52-59 (PutBreakpoints, Breakpoints)'
  - 'weft/studio/web/src/routes/playground.tsx:1961-2014 (PendingCall: continue, skip, resolve and their titles), 2321-2346 (the steer box)'
  - 'weft/studio/README.md:1756-1782 (breakpoints and steer on runtime-started runs; cancel: 202, 404, 403, 409, 503, best effort, auth)'
  - weft/AGENTS.md:518-528 (breakpoints on runtime runs and, with runtime.Breakpoints(), the app's own; breakpoints_own; thread.PublicID; SUBAGENT_PENDING; debug_scope; steer), 539 (/api/runs/{id}/approvals), 545 (/api/runtimes/{id}/breakpoints, /api/runs/{id}/steer, /api/runs/{id}/cancel)
  - weft/CHANGELOG.md:487 (Breakpoints() core.Option), 507 (breakpoints_own; meta.debug_scope own+runtime), 935 (POST /api/runs/{id}/cancel), 3512 (decisions checked against the pending calls; resume once; a second decision rejected), 4525 (PUT /api/runtimes/{id}/breakpoints and POST /api/runs/{id}/steer, capabilities breakpoints and steer)
  - docs-site/examples/playground/main_test.go:TestBreakpointParksTheAppsRun (breakpoints_own, debug_scope own+runtime, PUT 200, the app's Generate parks, Studio's 403, Approve runs it), TestNeverToolIsSubstitutedOrParked (a call not pending is 400)
  - 'observed: PUT /api/runtimes/{id}/breakpoints, POST /api/runs/{id}/steer, /cancel and /approvals against the example program (go run ./playground) at v0.17.0'
  - 'weft/studio/runtime/runtime.go:992-1000 (registration adopts the runtime''s set when Studio holds none), 1119-1154 (the set re-sent at every stream open), 1697-1707 (debug_scope: Sessions or breakpoints_own), 2113-2117 (SetBreakpoints: not connected)'
  - weft/studio/api.go:1092-1102 (debug_scope only with breakpoints)
  - weft/studio/appturn.go:61-151 (the three app-owned 403 cases; the 202 body)
  - 'weft/studio/debugger.go:39-43, 53-55, 72-85 (PUT breakpoints: 403, 404, 503), 152-190 (steer on app turns)'
  - 'weft/studio/playground.go:1085-1093, 1163-1166 (approvals: 400 decision and call_id, 503)'
  - weft/runtime/executor.go:1133-1142 (maxParked 128; an evicted park answers no parked run)
  - docs-site/factcheck/playground.md (findings 29-35)
---

# Pause runs at breakpoints, then steer or cancel them

A [breakpoint](https://weftgo.dev/docs/reference/glossary/#breakpoint) parks every call to a named tool at the [approval boundary](https://weftgo.dev/docs/reference/glossary/#approval-boundary): the run ends successfully with the call pending, and nothing has run. Set the breakpoints for a runtime from Studio's [Runtimes page](https://weftgo.dev/docs/observe/playground/runtimes/#breakpoints), or with `PUT /api/runtimes/{id}/breakpoints`. They park every run the runtime starts. To have them park your app's own runs too, build the agent with [`runtime.Breakpoints()`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Breakpoints). A parked playground run is decided from Studio; a running one can be steered or cancelled.

Opt an agent's own runs in, in `playground/main.go`:

```go title="playground/main.go"
agt := weft.New(model,
	weft.Name("acme-support"),
	weft.Options(supportTools()...),
	runtime.Breakpoints(), // Studio's breakpoints park this agent's own runs too
)
```

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

Pass that agent to `runtime.Agents`, then set a breakpoint on `refund`. Your app's next `agt.Generate` that calls `refund` returns with `res.Pending` holding the call.

## Breakpoints

The set is per runtime: a list of tool names, each a tool some registered agent of that runtime exposes. An empty list clears it. Against the example program:

```sh
curl -s -X PUT http://127.0.0.1:8080/studio/api/runtimes/rt_6ea843dccc7741ff/breakpoints -d '{"tools":["refund"]}'
```

```json
{"tools":["refund"]}
```

A name nobody registers can never fire, so it is refused as a typo:

```json
{"error":{"code":"bad_request","message":"tool delete_account is not registered by any agent of runtime rt_6ea843dccc7741ff"}}
```

The route needs the capability `breakpoints` and the server token, or setup A's loopback. Its other answers store nothing:

| Status | When |
|---|---|
| 400 | a tool no registered agent of the runtime exposes |
| 403 | any panel token: the set parks every future run of the runtime |
| 404 | an unknown runtime (`{"error":{"code":"not_found","message":"unknown runtime rt_0000000000000000"}}`) |
| 503 | the runtime is registered but holds no command stream |

On the [Runtimes page](https://weftgo.dev/docs/observe/playground/runtimes/#breakpoints), each runtime's card has one checkbox per tool of its agents, with **clear all**. Ticking or clearing a box sends this PUT at once. The new set parks every later run the runtime starts, whatever you run next, until someone changes it. Studio stores the set in its database (the `obsdb.CommandStore`), so it survives a Studio restart. A refused change, such as the 503 for a disconnected runtime, is undone, and the card shows the error. Since 0.19.0 the editor lives there only. The playground form and the replay drawers carry no **Break on** box any more. They show a link, "breakpoints for the whole runtime live on Runtimes", followed by the count in force ("· 1 tool break on every run"). Settings' Runtimes card is a summary with a link.

`{"tools":[]}` clears the set; the answer then reads `{"tools":null}`. Studio sends the set over the runtime's command stream, and again every time that stream opens, before any queued command. When a runtime registers and Studio holds no set for it, Studio adopts the one the runtime reports, so a restarted Studio shows the rule that is parking its runs: `GET /api/runtimes` lists it as `breakpoints`, with `breakpoints_set_at` when this Studio delivered it.

On the runs the runtime starts, the set becomes the run's own `weft.ParkOn`, filtered to the agent's tools and written into its override fingerprint. A breakpoint's park is never substituted from the record, whatever the command's `side_effects` mode. The replay drawer's ack preview shows it as "breakpoint · parks".

## Breakpoints on your own runs

An agent is immutable after `weft.New`, and your call sites know nothing about a debugger, so the runtime cannot add `ParkOn` to your runs. `runtime.Breakpoints()` is a [`weft.ParkSource`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ParkSource) instead ([ADR 0030](https://github.com/weftgo/weft/blob/v0.20.2/docs/adr/0030-a-dynamic-park-source.md)): a function the loop reads once per run, at its start, and merges into the run's park set as `ParkOn` would. It is bound lazily to the links `runtime.Install` started and has not stopped, so the agent can be built before Install runs. With several links live, a run parks on the union of their sets.

| Run | Parks on a breakpoint? | Who decides it |
|---|---|---|
| a plain `Generate` or `Stream` | yes | your app: `Generate` again with `weft.Messages(res.Messages...)` and `weft.Approve`, `weft.Deny` or `weft.Resolve` |
| a `weft/thread` turn, with `runtime.Sessions` set and a session created with [`thread.PublicID`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/thread#PublicID) | yes | Studio or the panel, through your `Session` ([Approve and steer your app's own turns](https://weftgo.dev/docs/observe/devtools/app-turns/)) |
| a thread turn without both | no: the source answers nothing for a run carrying `weft.session.id` | — |
| a `Subagent` child run | the child parks | nobody: the parent's call reads `SUBAGENT_PENDING` and the parent continues |
| a playground run (`weft.playground` metadata) | its own filtered `ParkOn` decides | Studio |

The thread rule keeps a breakpoint from wedging a session: a park nobody could decide would hold the session, and every later `Send` would queue behind it. Studio decides app runs by public id through `runtime.Sessions`, so a plain `Generate` parked this way is read-only on the run page. From `TestBreakpointParksTheAppsRun`, Studio's answer to an approval of such a run:

```json
{"error":{"code":"forbidden","message":"app-owned turn · read-only: run 076ad3b18e69a583ed066d3ac6b8420b is the app's own, and no connected runtime of its service acme-support acts on the app's sessions"},"fix":"set runtime.Sessions(resolver) at runtime.Install in the app (service acme-support): its turns then take approvals and steer"}
```

The test then resumes it the app's way, `weft.Approve(res.Pending[0].ID)`, and `refund` runs once.

The set is process-wide: every agent built with the option parks on it, whether or not you gave it to `runtime.Agents`. The registration's `breakpoints_own` is `true` when an agent given to `Agents` carries the option, and `GET /api/meta` reads `"debug_scope":"own+runtime"` while a connected runtime registered `breakpoints_own` or `runtime.Sessions` (otherwise `"runtime-started runs"`; the field is there only with the `breakpoints` capability).

The option is inert without a link: with no Install, an Install not enabled, a stopped link or an empty set, the source answers nothing and the run is byte-identical to one built without it. A source's parks are behaviour, not an override: they write no `weft.override.*` and leave the override hash alone. A link whose stream dropped, but which was not stopped, keeps its last set until it reconnects and Studio re-sends it. [`ExampleBreakpoints`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#example-Breakpoints) runs the agent with no link: `Refunded. 0`, nothing pending.

## Decide a parked run

A parked playground run is decided with `POST /api/runs/{id}/approvals`, one call at a time. The decisions are the approval boundary's own ([Require human approval for a tool](https://weftgo.dev/docs/guides/approvals/)), and the playground's result card names them (before 0.18.0 its verbs read continue, skip and resolve):

| `decision` | The card's verb | Effect |
|---|---|---|
| `approve` | approve | the handler runs for real |
| `deny` | deny | the model sees a denied result; `reason` is the text, else "skipped from the devtools panel" |
| `resolve` | resolve… | `content` is the tool's result, computed outside the process; the handler never runs |

The body is `{"call_id": …, "decision": …, "reason": …, "content": …}`. Studio forwards it to the runtime that started the run and answers 202 `{"command_id", "state":"queued"}`; poll the command like any other. The run resumes once, when every parked call has a decision, under all of them, as a new run whose row reads `resumed_from` (the parked run's reads `resumed_by`). A decision is checked against the run's pending calls, read from its stored `run_finish`. From `TestNeverToolIsSubstitutedOrParked`:

```json
{"error":{"code":"bad_request","message":"call nope is not pending on run pg_01M5762FPMD2GSF8AQE40AHXK1 (pending: c1)"}}
```

A run that did not park answers:

```json
{"error":{"code":"bad_request","message":"run pg_01M5780D5BYHQNGQDWRXR84HAZ is not parked: it finished with no pending call"}}
```

The route's other answers: 400 for an unknown `decision` (`unknown decision maybe`) or a body with no `call_id` (`an approval needs a call_id`), 404 for an unknown run, and 503 when the runtime that started the run is not connected. The runtime keeps the newest 128 parked runs for a decision; an older one is rejected on the command row, `no parked run "…" on this runtime (it may already have been resumed)`, so send the run again. The runtime checks again and rejects the command row when the call is not parked there, or is already decided: a second decision on a call never replaces the first, so concurrent decisions cannot run an approved handler twice. A parked run whose resume never started is restored, so it can be decided again. A parked call in a fork is decided through the fork's session and resumes as the fork's next turn. Your app's own turns go through `runtime.Sessions`; otherwise the route is 403 "app-owned turn" ([below](#steer-and-cancel)). A read-scoped panel token cannot decide.

Since 0.19.0 Studio remembers the decisions, steers and cancels sent to a run: `GET /api/runs/{id}/commands` (capability `run_commands`, with the playground) lists them, oldest first, each with its lifecycle row (`state`, the runtime's answer) and its `verb`, `call_id` and `decision`. The run page reads it, so a parked call whose decision was lost still says so after a reload or a Studio restart: `your approve at … was lost: <why> — decide again`. The devtools panel reads the route once per parked turn and marks a lost decision by the same rule, each call's latest decision. A Studio restarted over its command store logs one INFO line naming the runtimes it restored and the commands still open and lost. [`RuntimeServer.CommandsOn`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio/runtime#RuntimeServer.CommandsOn) is the Go side ([The Studio HTTP API](https://weftgo.dev/docs/reference/studio-api/#get-api-runs-id-commands)).

## Steer and cancel

**Steer** delivers one user message into a run in flight: `POST /api/runs/{id}/steer` with `{"message": …}`, capability `steer`. An ephemeral playground run carries a steering source, so the message joins the run at its next drain point ([Steer a running turn](https://weftgo.dev/docs/guides/steering/)); a fork's running turn takes it as a thread steer under that turn's run options, so the park rule still binds a follow-up turn. The route answers 202 once the message is on the runtime's stream:

```json
{"steered":true}
```

On your app's own thread turn it goes through a connected `runtime.Sessions` runtime of the run's service. It answers 202 `{"command_id","state":"queued","run_id","runtime_id"}`, the command to poll. A turn that is parked, or whose row reads `succeeded` or `failed`, is 409 at once (`no running turn to steer: run <id> is parked: …`, `… already finished (<status>)`). With no such runtime, it is 403 "app-owned turn". That is all it promises. A steer for a run that is no longer in flight is dropped by the runtime with a Debug line, and the route still says `"steered":true`. The playground's result card has a steer box ("a message delivered mid-flight") while its run runs.

**Cancel** asks the runtime holding a runtime-started run to stop it: `POST /api/runs/{id}/cancel`, capability `cancel`. The runtime cancels that run's own context, never kills anything; the run ends failed with `context canceled` and its partial transcript, its command finished failed, and it has no `run_finish` (the live stream carries the failed run row). The answers:

| Status | When |
|---|---|
| 202 `{run_id, command_id, runtime_id, state: "cancelling"}` | the cancel frame is on its way |
| 404 | an unknown run |
| 403 "app-owned turn" | the app's own run, and no connected runtime of its service registered `runtime.Sessions` (the app's runtime gone, one connected without `Sessions`, the link dialled another Studio, or none connected); or the run is not a turn of a session with a public id ([the five refusals](https://weftgo.dev/docs/observe/devtools/app-turns/#what-is-refused-without-it-and-why)) |
| 409 | a parked run ("decide its pending calls (approve/deny) instead"), or one already finished; on the app's own turn with a `Sessions` runtime connected, always (`cancel is not supported on an app turn: run <id> is the app's own turn`) |
| 503 | its runtime is disconnected |

For a finished run:

```json
{"error":{"code":"conflict","message":"run pg_01M5780D5BYHQNGQDWRXR84HAZ already finished (succeeded): there is nothing to cancel"}}
```

Cancel is best effort: one lost to a stream reconnect is not retried, so cancel again. An app's own session turn is never cancelled from Studio, since thread has no per-turn cancel: with a `runtime.Sessions` runtime of its service connected, cancel answers 409 at once (before 0.20.0 it answered 202 and the command row was then rejected). The 403 cases above apply alike to the approvals and steer routes.

Steer, cancel and the approvals share one rule for who may act: the dev token or setup A's loopback, a playground-scoped panel token inside its public id; a read-scoped panel token is 403.

## Complete example

`TestBreakpointParksTheAppsRun` in [`main_test.go`](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/playground/main_test.go) builds `newDebuggableAgent` (the region above) on a script that calls `refund`, registers it through `runtime.Local`, and checks `breakpoints_own` and `debug_scope`. It PUTs `{"tools":["refund"]}`, waits until the agent's park source ([`Agent.ParkSources`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Agent.ParkSources)) answers `[refund]`, runs `agt.Generate` and finds `refund` pending with the handler not run. Studio's approval is 403, and the app's `weft.Approve` runs `refund` once:

```sh
go test -run TestBreakpointParksTheAppsRun -v ./playground
```

```text
=== RUN   TestBreakpointParksTheAppsRun
    main_test.go:471: PUT breakpoints: 200 {"tools":["refund"]}
    main_test.go:493: approve the app's own run in Studio: 403 {"error":{"code":"forbidden","message":"app-owned turn · read-only: run 04bdddd0f389b6a8afc7cd2d05d4f642 is the app's own, and no connected runtime of its service acme-support acts on the app's sessions"},"fix":"set runtime.Sessions(resolver) at runtime.Install in the app (service acme-support): its turns then take approvals and steer"}
--- PASS: TestBreakpointParksTheAppsRun (0.04s)
PASS
ok  	weftgo.dev/docs/examples/playground	0.041s
```

## Best practices & gotchas

- **Build the agent with `runtime.Breakpoints()` to break on your own runs.** Without it a breakpoint parks only the runs the runtime starts. (Source: `runtime.Breakpoints` godoc; CHANGELOG 217)
- **A thread turn parks only with `runtime.Sessions` and a public id.** Otherwise the source answers nothing for it, so the session is never held by a park nobody can decide. (Source: `runtime/breakpoints.go:42-52`)
- **Resume a parked plain `Generate` in your code.** Studio decides session turns only, so it answers 403 "app-owned turn". (Source: the example's `TestBreakpointParksTheAppsRun`)
- **Stopping the link does not unpark a parked run.** The park set is read once, at the run's start; a turn parked before the stop has no decider until your app decides it or a link with `Sessions` comes back. (Source: `runtime/breakpoints.go:61-68`)
- **Read `"steered":true` as sent, not delivered.** A steer for a run not in flight is dropped. (Source: `runtime/link.go:1127-1155`)
- **Decide a parked run; do not cancel it.** Cancel answers 409 for a run parked at the approval boundary. (Source: `studio/cancel.go:112-117`)

## See also

- [Require human approval for a tool](https://weftgo.dev/docs/guides/approvals/)
- [Approve and steer your app's own turns](https://weftgo.dev/docs/observe/devtools/app-turns/)
- [Steer a running turn](https://weftgo.dev/docs/guides/steering/)
- [How does the playground work?](https://weftgo.dev/docs/observe/playground/overview/)
- [Watch runs live](https://weftgo.dev/docs/observe/studio/live/)

Symbols used: [`runtime.Breakpoints`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Breakpoints) · [`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.Sessions`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/runtime#Sessions) · [`weft.New`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#New) · [`weft.ParkSource`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ParkSource) · [`weft.ParkOn`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ParkOn) · [`weft.Approve`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Approve) · [`weft.Deny`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Deny) · [`weft.Resolve`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Resolve) · [`weft.Messages`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Messages) · [`weft.Subagent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Subagent) · [`thread.PublicID`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/thread#PublicID) · [`Agent.ParkSources`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Agent.ParkSources) · [`Agent.Generate`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Agent.Generate)
