PXI · UI code mode · Script walkthrough
One tool call, ten UI actions
The script owns the control flow. A for loop over three models becomes ten UI actions inside a single execute_browser_action call, with no round trip to the model in between.
One tool call, ten UI actions
Walkthrough of a nine-line script: it lists the playground models, then loops over the three results, setting each model, running the playground, and reading the output. The dispatch log beside the code fills with ten UI actions, and the script returns all three results to PXI in one tool output.
THE SCRIPT · ONE execute_browser_action CALL
UI ACTIONS DISPATCHED TO THE PAGE
EACH AWAIT
#01 playground.model.list → 3 models
#02 playground.model.set model 1 of 3
#03 playground.run waits for the run
#04 playground.run.readOutput → output
#05 playground.model.set model 2 of 3
#06 playground.run waits for the run
#07 playground.run.readOutput → output
#08 playground.model.set model 3 of 3
#09 playground.run waits for the run
#10 playground.run.readOutput → output
RESULT
Returned to PXI as one tool output
results · 3 entries · plus logs and per-call telemetry
1
TOOL CALL
10 of 50
UI ACTIONS
1
MODEL TURN
1
const { output } = await ui.playground.model.list ( { } ) ;
2
const results = [ ] ;
3
for ( const { target } of output . builtinModels ) {
4
await ui.playground.model.set ( { target } ) ;
5
await ui.playground.run ( { } ) ;
6
const run = await ui.playground.run.readOutput ( { } ) ;
7
results . push ( { model : target . modelName , run : run . output } ) ;
8
}
9
return results ;
WITHOUT CODE MODE · 10 MODEL TURNS, EACH PASTING THE LAST RESULT BACK IN
WITH CODE MODE · 1 MODEL TURN
one execute_browser_action call · 10 UI actions
The loop runs in the browser; PXI never sees the middle.
Ten intermediate results stay out of the model's context window.
The script can also branch, filter, and reshape before returning.
LEGEND
Line being executed (animation only)
#07
One dispatched UI action, in order
Crosses from worker to main thread
Previous
Play
Pause
Next
Replay
←/→ step · Space play/pause · R replay · Home/End jump
Step 5 of 5
Animation controls require JavaScript. The complete final diagram is shown above.
Every await ui.* is one action request from the worker to the page. The script can branch, loop, batch, and reshape results before returning, so PXI spends one turn instead of ten. The main thread still checks every action and enforces the budgets: 50 actions and 30 s of execution per script.