run_script
Execute deterministic multi-step browser scripts without per-step LLM round-trips; supports loops, conditionals, error handling, and parallel branches, returning a script_id for result collection.
Instructions
Execute a deterministic multi-step script without per-step LLM round-trips, running on a cloned browser tab. Scripts support loops (for/while/forEach), conditionals (if/else), error handling (try/catch), parallel branches, and variable capture. Returns a script_id immediately — use wait_for_scripts to collect results. Provide either an inline script definition or a name to load a previously saved script. Use when you detect a repetitive pattern (same operation on 3+ pages/items).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name of a previously saved script to run (alternative to inline 'script'). Mutually exclusive with 'script' — provide one or the other. | |
| limits | No | Override execution limits; omitted keys keep their defaults and values are capped by settings. Keys: max_steps (200), max_timeout_secs (300), max_output_bytes (10485760), max_parallel_branches (10), per_step_timeout_secs (30). | |
| script | No | Inline script definition: {"schema_version": 1, "steps": [...]}. Each step has a snake_case `type`: tool_call {tool, input, output?}, assign {variable, value}, collect {value}, yield {value}, for_loop {variable, from, to (exclusive), steps}, for_each {variable, iterable, steps}, while_loop {condition, steps}, if_else {condition, then_steps, else_steps?}, try_catch {try_steps, catch_steps?, finally_steps?, error_var?}, parallel {branches}. Values are expressions tagged by `kind`: {"kind": "literal"|"variable"|"js_eval", "value": ...}, {"kind": "field_access", "value": {"object": <expr>, "field": "key"}} or {"kind": "array_index", "value": {"array": <expr>, "index": <expr>}}. In tool inputs and literals, a string that is exactly "$name" is replaced by the variable's value and "{{name}}" is interpolated inside a string. Example: {"schema_version": 1, "steps": [{"type": "for_each", "variable": "q", "iterable": {"kind": "literal", "value": ["a", "b"]}, "steps": [{"type": "tool_call", "tool": "navigate", "input": {"url": "https://example.com/search?q={{q}}", "page_map_depth": "none"}, "output": "page"}, {"type": "collect", "value": {"kind": "variable", "value": "page"}}]}]} | |
| save_as | No | Validate and save the script under this name before running it, for later runs by `name` (alphanumeric, underscore, hyphen). Persists to the scripts directory (default ~/.acrawl/scripts/<name>.json). |