FAQ
My page has a strict CSP. What do I need? url mode and one
frame-src entry for the origin that serves the document. Nothing else:
no 'unsafe-eval', no worker-src.
Can I run it on Safari? Yes; the suite runs in WebKit. Safari 16+.
Several sandboxes? As many as you like; each has its own frame and queue. Runs on one sandbox are sequential.
Should I reuse workers? workerPerRun: false saves a few milliseconds
per run and keeps whatever the previous run left in the worker's global.
Use it only when runs trust each other.
How do I read the logs? result.logs, or live through onLog.
toToolOutput includes them as logs for the model.
Can I debug the worker in devtools? Yes: it appears as a dedicated worker under the sandbox frame; the model's code is the body of the compiled function.
Why is there no fallback to new Function in the page? Because a
fallback is the hole. If the sandbox cannot start, tell the model, do not
run the code.
Does pause time out? The run clock pauses while onApproval is
pending. Cut a stale wait with the run's signal.
What does the model see when a limit hits? toToolOutput words it:
Denied (sandbox_limit): the code ran 10000 ms with no function call in flight.