Run experiments with the option lab
An experiment is a matrix of playground runs: each variant is one set of overrides (prompt, tools, model, thinking, sampling, tool choice), each input one source run or text, and each cell one command sent under the experiment’s id. Build it on Studio’s /playground page and press Run matrix, or start one from the runs list over the runs of one failure class: the page saves the definition with POST /api/experiments, and every cell’s run carries weft.experiment.id, so the experiment reads back with its runs and their cost. A pass predicate such as status = succeeded AND cost < 0.01 judges each cell, and the grid names the cheapest variant that passes every row. runtime.Limits caps what one experiment may spend in your process.
The saved definition is plain JSON. Two variants over one source run, continued from step 1:
curl -s -X POST http://127.0.0.1:8080/studio/api/experiments -d '{ "id": "tracking-link", "name": "tracking link", "agent": "acme-support", "variants": [ {"key": "a", "overrides": {}}, {"key": "b", "overrides": {"instructions": "You are Acme'"'"'s support agent. Always include the tracking link.", "options": {"temperature": 0.2}}} ], "inputs": [{"key": "src", "source_run_id": "dd66354adfaac2b44848f0c1ed75516f"}], "engine": "live", "side_effects": "substitute", "thread": "ephemeral", "from_step": 1, "source_run_id": "dd66354adfaac2b44848f0c1ed75516f"}'{"id":"tracking-link","name":"tracking link","agent":"acme-support","variants":[{"key":"a","overrides":{}},{"key":"b","overrides":{"instructions":"You are Acme's support agent. Always include the tracking link.","options":{"temperature":0.2}}}],"inputs":[{"key":"src","source_run_id":"dd66354adfaac2b44848f0c1ed75516f"}],"engine":"live","side_effects":"substitute","thread":"ephemeral","from_step":1,"source_run_id":"dd66354adfaac2b44848f0c1ed75516f","created":"2026-10-18T10:13:09.477022685Z","updated":"2026-10-18T10:13:09.477022685Z","run_count":2,"succeeded":2,"last_run":"2026-10-18T10:13:07.374947632Z","cost_usd":0,"cost_known":true,"cost_badge":"scripted","cost_reason":"a scripted model: nothing bills it, an exact $0","cache":"exact","runs":null}The two cells had already run with "experiment_id": "tracking-link", so the save finds them: run_count 2, succeeded 2.
Experiments
Section titled “Experiments”On the /playground page, each variant is a column: + variant adds one, and a variant can be renamed, duplicated and removed. A variant’s name is required, at most 32 characters, with no leading or trailing spaces and no control characters, and unique in the form (“variant B already exists”). The name keys the cells and the experiment’s variants. The Experiment matrix below the form adds inputs with + input. Its header names the shape and the step: “Experiment matrix · 1 variant × 1 input · over the source run · from step 1”. Every cell continues from that one from_step, the source block’s step picker; past step 0 an input row’s text is not sent, and the cell runs with the page’s transcript edits instead.
Each variant runs on the engine the command can take, chosen as the replay drawer chooses it (Choose the engine): two radios per variant, and Run names the variant and the engine, Run A on scripted · 0 tokens or Run A live on <model> · ≈ $x. An engine you pick rides the URL and the form. Breakpoints are not set per variant: the form points to Runtimes, with the count in force. The playground’s Run and Run matrix wait for the preview and hold on its refusal and on the target check.
Run matrix has the page save the definition (POST /api/experiments) and issue every cell’s command under the experiment’s id, so the budget caps the whole matrix. When the last cell settles, one toast says how many succeeded and failed, with the bill when pricing is on. The grid then shows each cell (The grid).


The name field is free text, and the experiment’s id follows the command id’s rule, [A-Za-z0-9._:-]{1,128}. A name that fits is its own id; any other is slugged with a per-page nonce, and an empty one becomes exp_<time>. Because of the nonce, the same odd name in another tab or after a reload makes a separate experiment; only a name that fits the rule re-runs the same one. A reopened experiment keeps its id until you rename it.
The page keeps your form as a draft in this browser (IndexedDB) once you change it, under ?exp=<draft id>; the drafts list opens or deletes the others, and drafts never leave the browser. copy share link puts the whole form in the URL fragment (#state=, no token, at most 8,000 characters encoded): the link restores the form on any browser against the same Studio and runs nothing. A share link past 8,000 characters, or one that inflates past 256 KiB, is refused, and so is a link or draft from an older form version.
A bare /playground over several registered agents asks first: “Pick an agent (N registered on M runtimes) or paste a run id in Source run”, with the five latest failed runs as one-click sources. A rejected or lost command offers “send again”, a new command. A scripted run’s card reads “scripted · 0 tokens”.
The option lab
Section titled “The option lab”The option lab is the form’s Options block, one form on both surfaces: the playground page and the run page’s replay drawer in Studio, and the devtools panel’s experiment drawer. It has a knob for every override a command carries:
- max steps, parallelism and temperature (
options); - top_p, max tokens, seed and stop (one per line) (
params); - tool choice (
default (auto), any, none, named and its tool), only tools and park on; - beside them System prompt, Tools, Model and Thinking.
Each knob shows the agent’s default from GET /api/runtimes, greyed: the registration carries per agent defaults {max_steps, parallelism, thinking, temperature?, top_p?, max_tokens?, seed?, stop?, tool_choice}. A value that differs is drawn in colour with a ↺ back to the default. An empty knob, or one set to the default, sends nothing, so it keeps the agent’s value. An agent whose registered cap is 0 has no bound, so its knob shows no default; a 0 sent as an override is refused (max_steps must be a whole number from 1).
The Model select lists the runtime’s runtime.Models names, plus free text when the agent’s runtime registered a runtime.ModelResolver: your app resolves the name, and its refusal is the command’s reason, shown as given (Agents and models).
The form refuses a widening before it sends. It mirrors the server’s rules by name: caps lower only, the ranges, a tool the agent lacks, only tools inside the tools left on, a named choice the command turns off or parks, the agent’s own named default turned off. Each refusal is said on its knob in the server’s words and holds Run. A tool turned off is greyed out of only tools and the named tool picker; park on lists every tool. The server stays the authority: if it refuses anyway, its 400 is shown verbatim. Both surfaces build the overrides through one function, so they post byte-identical JSON for the same choices.
The drawers pre-fill the registered system prompt and send no instructions override while it is unchanged, so a scripted command is not refused for an override you did not make.
A runtime older than the option lab registers no defaults. The form then shows the knobs with no default, and greys the seven it cannot carry (top_p, max tokens, seed, stop, tool choice, only tools, park on), saying why.
Overrides
Section titled “Overrides”A command’s overrides object, the same in a variant’s overrides:
| Field | Values | Rule |
|---|---|---|
instructions | text | replaces the system prompt; refused with the scripted engine |
tools_enabled | tool names | the tools left on; each must be the agent’s. An empty list, [], counts as not overridden (gotcha) |
model | a name | the agent’s own, a runtime.Models name, or one the resolver accepts; refused with the scripted engine |
thinking | off, low, medium, high | neutral |
options.max_steps, options.parallelism | a whole number from 1 | lower only |
options.temperature | 0 to 2 | neutral |
params.top_p | 0 to 1 | neutral |
params.max_tokens | positive | neutral |
params.stop | at most four non-empty strings | neutral |
params.seed | any integer | neutral |
tool_choice | {"mode": "auto" | "any" | "none" | "named", "name": …} | a named choice must name a tool the command keeps on and does not park |
park_on | tool names | adds parking: a parked call stops there even under substitute |
only_tools | tool names | narrows further, inside tools_enabled when both are sent |
The sampling override is laid over the agent’s own weft.Params: an absent field keeps the agent’s value, and a command cannot clear the agent’s stop or max_tokens. Each override is applied as a plain run option (weft.Instructions, weft.OnlyTools, weft.UseModel, weft.Thinking, weft.MaxSteps, weft.Parallelism, weft.Params, weft.ToolChoice, weft.ParkOn), so it shows on the run’s weft.override.* attributes and changes its weft.override.hash.
Every refusal names its rule. From TestOverrideRefusalsNameTheirRule, against the example agent (MaxSteps(10), tools lookup_order, refund, send_email):
overrides | Status | Answer |
|---|---|---|
{"options":{"max_steps":50}} | 403 | max_steps may only lower the agent's cap |
{"tools_enabled":["lookup_order"],"only_tools":["refund"]} | 403 | only_tools may only narrow tools_enabled: tool refund is not enabled |
{"tools_enabled":["cancel_order"]} | 400 | tool cancel_order is not in agent acme-support's manifest |
{"options":{"temperature":3}} | 400 | temperature must be between 0 and 2 |
{"params":{"top_p":1.5}} | 400 | top_p must be between 0 and 1 |
{"tool_choice":{"mode":"named","name":"refund"},"park_on":["refund"]} | 400 | tool_choice names refund, which park_on parks: every forced call would park |
Each answer is the body’s error.message, as in {"error":{"code":"forbidden","message":"max_steps may only lower the agent's cap"}}. With no tool_choice sent, an agent default naming a tool the command turns off is refused too: send tool_choice. The runtime checks all of it again before the ack, against its own registration, and rejects unknown engines, modes, thinking levels, options, out-of-range values, bad run or command ids and a from_step out of range. Against a runtime that predates the option lab, Studio refuses params, tool_choice, park_on and only_tools with 400 runtime predates the option lab: upgrade weft/runtime to use params, tool_choice, park_on, only_tools, since it would run the command without them.
Saved experiments
Section titled “Saved experiments”POST /api/experiments creates or replaces one definition: a field it leaves out is cleared. The body is id, name, agent, variants (each key, overrides, and its own engine, side_effects or thread when they differ), inputs (each key, a source_run_id or a text, and its own from_step when it differs from the experiment’s), pass_predicate, and the rest of the command the cells ran with: engine, side_effects, thread, from_step, source_run_id and transcript_edits. So a saved experiment reopens as the form that ran it. A negative from_step is refused, naming the field (inputs[0].from_step must be a step ordinal (0 or more)), and so is a pass_predicate over 4,096 bytes. It needs an id that fits [A-Za-z0-9._:-]{1,128} and at least one variant and one input:
{"error":{"code":"bad_request","message":"an experiment defines at least one variant and one input"}}GET /api/experiments lists the 50 most recently updated by default, ?limit= up to 200, with total, the number saved:
curl -s 'http://127.0.0.1:8080/studio/api/experiments?limit=10'{"experiments":[{"id":"tracking-link","name":"tracking link","agent":"acme-support","variants":[{"key":"a","overrides":{}},{"key":"b","overrides":{"instructions":"You are Acme's support agent. Always include the tracking link.","options":{"temperature":0.2}}}],"inputs":[{"key":"src","source_run_id":"dd66354adfaac2b44848f0c1ed75516f"}],"engine":"live","side_effects":"substitute","thread":"ephemeral","from_step":1,"source_run_id":"dd66354adfaac2b44848f0c1ed75516f","created":"2026-10-18T10:13:09.477022685Z","updated":"2026-10-18T10:13:09.477022685Z","run_count":2,"succeeded":2,"last_run":"2026-10-18T10:13:07.374947632Z","cost_usd":0,"cost_known":true,"cost_badge":"scripted","cost_reason":"a scripted model: nothing bills it, an exact $0","cache":"exact"}],"total":1}Each row is read at request time from the runs labelled with its id, never stored: run_count (its top-level runs), succeeded, last_run (the newest one’s start; both omitted past the summary’s walk cap) and the cost of its runs, own plus delegated (See what a run cost). GET /api/experiments/{id} adds runs, the experiment’s runs as run rows. created and updated keep nanoseconds.
The join is by id alone. POST /api/playground/runs accepts any experiment_id, saved or not, so a re-run sent with a saved experiment’s id joins it, and a definition saved after its runs finds them all. /api/runs and /api/search take experiment_id= as a filter. The full request and response shapes are on Studio’s HTTP API.
curl -s 'http://127.0.0.1:8080/studio/api/runs?experiment_id=tracking-link' | jq -c '[.runs[] | {id, experiment_id, forked_from}]'[{"id":"pg_01M5780D5E5KT7515M5GAC71BS","experiment_id":"tracking-link","forked_from":"dd66354adfaac2b44848f0c1ed75516f#1"},{"id":"pg_01M5780D5BYHQNGQDWRXR84HAZ","experiment_id":"tracking-link","forked_from":"dd66354adfaac2b44848f0c1ed75516f#1"}]The routes are the server token’s or setup A’s loopback: every panel token is refused, the reads like the write, because a definition holds prompts and inputs of any public id. A panel token’s run command may not carry an experiment_id either.
The experiments pages
Section titled “The experiments pages”Experiments in Studio’s sidebar opens /experiments on two tabs, matrices and replays. It opens on replays when no matrix is saved.
replays lists every playground run, the newest 2,000 (and says so when there are more), grouped under the run it replays (its weft.forked_from), the group with the newest replay first. Each row is one replay: its step, what it changed (edit, prompt and model chips), its engine, its outcome, its start, and a link to compare it with its source. A replay from the drawer lands here.
matrices lists “the playground’s saved matrices”. Each row is one experiment with its agent, created, variants × inputs, engine, source run and step, runs, passed (“2 / 2 passed”: its top-level runs that succeeded), last run and cost. The list shows the newest 50, says “newest N of total” when more are saved, and loads 50 more at a time up to 200. Past 200 it reads “the list stops at the newest 200” and offers no more: the API has no cursor past its ?limit=. You can filter it by agent or source run; the filter narrows the loaded rows only.
/experiments/{id} draws the grid (below). From there:


- re-run one cell, or re-run all, under the same experiment id, each cell choosing its engine as the drawer does. When the last cell settles one toast reports the batch. With pricing on, a run not yet listed under the experiment makes the page read the experiment again, at most three times, and then the toast goes out reading “cost not read yet”;
- clone into the form, which reopens the playground on a draft holding that form;
- pick two cells and compare the two cells on the compare page. Since 0.20.0 the picked cells are the URL’s
?pick=<variant>×<input>,<variant>×<input>, so a shared link opens with them picked; a third pick drops the oldest; - “its runs in the runs list” opens
/runsfiltered by the experiment id.
GET /api/experiments/{id} for an id that runs carry but under which no definition was saved answers a synthetic document instead of a 404: unsaved: true, no variants or inputs, the agent its runs name, and its runs. The page says “no saved definition: these runs carry the experiment id, but no matrix was saved under it”. An id with no runs is still a 404.
Under a panel token, Experiments is not offered in the sidebar, the ⌘K palette or the playground’s history; opened by URL, the page shows the hidden badge (“dev token only”) and fetches nothing.
The grid
Section titled “The grid”The grid has one row per input, one column per variant, and a source column naming the run each row’s cells replay and the step. Each cell is its latest run, in one line: outcome · the answer’s first line (at most 80 characters, “no answer text” when the run produced none) · tokens · cost · engine (scripted, or live · <model>) · its wall time, with the run id’s tail (…VGKSMX) and a link to compare it with its source.
Each cell also reads a chip against its source: “same as source”, “same where both recorded”, or “changed at step N”, from one GET /api/diff per cell, aligned on the source’s steps (Replays align on their source). Only the grid’s first 24 cells read it; a later cell links to the compare and says it was not read.
A matrix Studio has issued opens as /experiments/<id>?issued=N: the grid reads the experiment again until N top-level runs joined (a subagent’s child run that carries the experiment id is no cell), for at most two minutes. Meanwhile its empty cells read “issued, not started” and the summary waits. Past two minutes it says “k issued cells never started (no run joined in 2 minutes): counted as missing”.
Pass predicate
Section titled “Pass predicate”A matrix carries a pass predicate, and the grid judges each cell’s latest run with it: ✓ pass, ✗ fail or ? not judged, with the reason. The language is clauses joined by AND:
| Clause | Reads |
|---|---|
status = <word>, status != <word> | the run’s status: succeeded, failed, interrupted, running |
answer ~ /re/flags, answer !~ /re/flags | the run’s last answer against a JavaScript regular expression, flags i, m, s, u |
answer = "text", answer != "text" | the whole answer, exactly |
steps, tokens or cost with <, <=, =, >=, > and a number | the step count, input + output tokens, the whole bill in USD (own + delegated) |
An empty predicate is status = succeeded. For example:
status = succeeded AND answer ~ /tracking/i AND cost < 0.01A fact the predicate reads that is not known is never a pass and never an empty answer: an answer not read yet, content off, stripped or unreadable, or an unpriced cost makes the cell not judged. A known fail wins over an unknown one. The grid reads the answer for every cell of the first 20 rows and says so past them.
An answer ~ pattern is tested off the page, on the answer’s first 8 KiB. A pattern that can take exponential time (an unboundedly repeated group that itself holds an unbounded quantifier, or a backreference) is refused when you type it; any other runs in a worker, bounded at 250 ms per answer, and past that the cell is not judged.
Under the grid each column gets its tally, “5/7 · $0.0021”, or “3/4 judged” while some cells are not judged. The summary names the cheapest column whose every row passed and the cheapest column overall, never a column with rows missing; while any cell is not judged it says “k cells not judged: no cheapest yet” with the reason. A bill that is not known reads “unpriced” for a model with no price, else “cost unknown”. You can try a predicate on the grid and save it on the definition.
The predicate is Studio’s alone: POST /api/experiments stores pass_predicate verbatim, at most 4,096 bytes, and the server validates nothing in it and judges no cell.
A matrix from a failure class
Section titled “A matrix from a failure class”The runs list groups failures into error classes (Error classes). With one class picked, Experiment on these N → opens the playground’s multi-source matrix over those runs, one matrix per agent: /playground?sources=<ids>&agent=<name>, at most 20 source runs, said when the class holds more.
- Rows are the source runs, each continuing from its own failing step: the step its error names (“run failed at step N”), else its last recorded step, with its own kept prefix.
- Columns are models: the agent’s models, each on live, or the agent’s own on scripted (“scripted replays the recording: only the agent’s own model can run on it”).
- A pass predicate, as above.
- The estimate before Run: “28 cells · ≈ 34k tokens · ≈ $0.012”, with each column’s figure, from the source steps’ recorded usage priced at each column’s model under Studio’s price table. An unpriced model reads “cost unknown:
<model>has no price”, never $0. A failed source is a floor, ”≥”, and a failing step that billed nothing is estimated at the step before’s input tokens, said in a note.
Run matrix saves one experiment (each input its source_run_id and its own from_step, the predicate verbatim), issues every cell through the grid’s own cell rule, and links the grid with the count it sent. The playground holds Run while no connected runtime registers the agent (Runs in).
Budgets
Section titled “Budgets”runtime.Budget caps one experiment, counted per experiment_id from the usage of the commands this runtime ran. Pass it with runtime.Limits at Install (Connect your app):
| Field | Caps |
|---|---|
MaxTokensPerExperiment | input + output tokens across the experiment’s runs |
MaxRunsPerExperiment | the number of commands run, reserved at admission |
A zero field is no cap; without Limits a runtime accepts unlimited playground runs within the agent’s own budgets (MaxSteps, UsageLimit). A breach rejects a command of that experiment before its ack, never a run in flight and never your app’s own runs. The run cap is exact: each command reserves its run at admission and gives the reservation back when it never ran, so the cap’s last command is the last one run. The token cap is counted from usage after a run ends, so the run that crosses it finishes and the next command is rejected. Budgets count failed runs and every leg of a substitute chain (the chain’s resumed runs). With MaxRunsPerExperiment: 2, the third command’s row from TestBudgetRefusesTheNextCommand:
{"command_id":"cmd_budget_3","state":"rejected","run_id":"","error":"budget_exceeded","created":"2026-10-18T11:39:18.426637411+02:00","updated":"2026-10-18T11:39:18.426764993+02:00"}The tally lives in the runtime’s memory, one per runtime.Install: an app restart, each weft dev reload on save included, starts every experiment’s count again at zero, and two processes serving the same agents count separately. A command with no experiment_id counts against no experiment’s cap. The matrix sends every cell under its experiment’s id, so the cap covers the whole matrix.
Complete example
Section titled “Complete example”Start the example program from How does the playground work? open the playground on its source run, and press Run matrix:
go run ./playgroundplayground: http://127.0.0.1:8080/studio/playgroundsource run: dd66354adfaac2b44848f0c1ed75516fThe tests TestOverrideRefusalsNameTheirRule and TestBudgetRefusesTheNextCommand in main_test.go send the refused commands above, the resolver’s refusal and acceptance, and three commands under MaxRunsPerExperiment: 2.
Best practices & gotchas
Section titled “Best practices & gotchas”- Name an experiment within
[A-Za-z0-9._:-]to re-run the same one. Any other name is slugged with a per-page nonce, so it starts a new experiment each time. (Source:studio/README.md:1854-1860) - A hand-written
POST /api/experimentsis not held to the variant-name rules. They are checked in the browser only; the server checks the id, the modes, the overrides’ shape andfrom_step. (Source:studio/web/src/routes/playground.tsx:493-504;studio/experiments.go:120-170) - Leave a knob empty to keep the agent’s value. An empty knob sends nothing; a command cannot clear the agent’s
stopormax_tokens. (Source:studio/README.md:1703-1705) - A command cannot turn every tool off. With
tools_enabledandonly_toolsboth empty or absent, the run gets every tool; an emptyonly_toolsbeside a non-emptytools_enablednarrows totools_enabled. With every tool unticked, the form and the panel drawer issue nothing and showat least one tool must stay on — the command cannot express an empty tool set (it would run with every tool). To test an agent with no tools, keep one harmless tool on. (Source:studio/web/src/lib/experiment-body.ts:153-163;routes/playground.tsx:1306-1309;panel/playground.ts:289-291;studio/playground.go:916-926;runtime/executor.go:1376-1382) - Keep
submit_outputon for anOutput[T]agent.tools_enabledandonly_toolsboth run asweft.OnlyTools, which drops a tool the list leaves out,submit_outputincluded. The run then ends without a value: the model’s submission readsNO_SUCH_TOOL: no tool named "submit_output". List it in the override; it is in the agent’s manifest, so Studio accepts the name. (Source:runtime/executor.go:1374-1382;core/agent.go:1013-1028;core/manifest.go:180-191;studio/playground.go:703-713) - Without
runtime.Limitsa matrix is uncapped. The default accepts unlimited playground runs, so the only caps are the agent’s ownMaxStepsandUsageLimit. (Source:runtime/options.go:131-136) - Do not treat a budget as a lifetime cap. It counts what this process ran since
runtime.Install. Underweft dev, every save restarts the app and resets the count, so a matrix re-run after an edit gets the whole budget again. (Source:runtime/link.go:106, 137;runtime/options.go:336;runtime/executor.go:573-581) - Expect the token cap to bite one command late. The run that crosses
MaxTokensPerExperimentfinishes;MaxRunsPerExperimentis exact. (Source:runtime.Budgetgodoc;runtime/executor.go:588-600) - Use the dev token for experiments. Every panel token is refused on the experiments routes. (Source:
studio/experiments.go) - Write the predicate for what you need to be true, not only
succeeded. A run that succeeded with the wrong answer passes the default. Add ananswer ~or acost <clause. (Source:lib/predicate.tsDEFAULT_PREDICATE) - Record with content on to judge answers. With content off the answer is not known, so every
answerclause leaves the cell not judged. (Source:lib/predicate.ts,lib/experiments.tsanswerText)
See also
Section titled “See also”- Replay a run from any step, with edits
- How does the playground work?
- Compare runs step by step
- See what a run cost
- How does a run stop?
Symbols used: runtime.Limits · runtime.Budget · Budget.MaxTokensPerExperiment · Budget.MaxRunsPerExperiment · runtime.Models · runtime.ModelResolver · weft.Params · weft.ToolChoice · weft.ParkOn · weft.OnlyTools · weft.UseModel