run_script_and_wait
Run a script, wait for it to finish, and get the full output in one call. Supports Python tasks/SLIs and Bash scripts with secret variable injection.
Instructions
Execute a script and wait for results (combines run + poll + output).
This is a convenience tool that runs a script, polls until completion, and returns the full output — all in one call. Use this instead of calling run_script + get_run_status + get_run_output separately.
The script must follow the RunWhen contract:
Python task: define main() returning List[Dict] with keys 'issue title', 'issue description', 'issue severity' (1-4), 'issue next steps'.
Python SLI: define main() returning a float 0-1.
Bash task: define main() writing issue JSON array to FD 3 (>&3).
Bash SLI: define main() writing a metric float to FD 3.
Provide exactly one of: script | script_base64 | script_gzip_base64 | script_path (stdio) | script_base64_path (stdio). Use script_gzip_base64 for scripts >5KB to maximise transport headroom.
Bash scripts must NOT include main "$@" at the bottom. The runner
sources the script and invokes main() itself with FD 3 wired to a
run_output.json file. A trailing main "$@" triggers a preflight
invocation with FD 3 read-only and produces misleading "Bad file
descriptor" errors.
secret_vars entries are injected as env vars whose VALUE is a FILE
PATH on the runner — not the secret value itself. kubectl/KUBECONFIG
and gcloud/GOOGLE_APPLICATION_CREDENTIALS work unchanged. For tokens/
passwords the script must cat "$VAR" (bash) or
open(os.environ["VAR"]).read() (python) to get the actual value.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | No | The full script source code (raw text). | |
| env_vars | No | Environment variables for the script. | |
| location | No | Runner location (use get_workspace_locations). | |
| run_type | No | 'task' or 'sli'. | task |
| interpreter | No | 'bash' or 'python'. | bash |
| script_path | No | Local file path to read the script from. **stdio mode only.** Mutually exclusive with the other script_* params. | |
| secret_vars | No | Secret mappings (env var name to workspace secret key). | |
| script_base64 | No | UTF-8 script as standard base64. Prefer over inline 'script' when JSON-escaping multiline content is error-prone. | |
| workspace_name | Yes | The workspace to run in (e.g. 't-oncall'). | |
| script_base64_path | No | Local file path to a file containing the base64-encoded script. **stdio mode only.** | |
| script_gzip_base64 | No | UTF-8 script as base64(gzip(...)). Best inline option for scripts >5KB — 3-5x denser than 'script_base64'. | |
| runtime_var_overrides | No | Per-run override values for script variables (name → value). Merged into envVars at test time. Overrides win on name collision. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |