Skip to Content
GuidesRun commands and tasks

Run commands and long tasks

Two ways to run a program on a machine: exec_run waits for it and returns its exit code, and task_start starts it in a terminal that keeps running after your call or your conversation ends.

Before you start

Both need the exec class in your grant and in the machine’s ceiling. Without it the call returns denied: tell the owner, do not retry.

Run a command and wait

  1. Call exec_run with argv (run directly, no shell) or command (run as /bin/sh -c):

    { "machine": "build-box", "argv": ["cargo", "test", "--quiet"], "cwd": "~/src/app", "timeout_secs": 300 }
  2. Read the result: exit_code, stdout and stderr apart, and timed_out. A non-zero exit is a normal result, not an error: decide from the code and the output.

Limits:

  • timeout_secs defaults to 120, at most 600. On timeout the whole process group is stopped.
  • Each stream keeps its last 64 KiB; longer output is saved to the files named in stdout_file and stderr_file, which you can read with fs_read.
  • The command starts with a small base environment (PATH, HOME, USER, SHELL, the locale, the desktop session) plus what you pass in env. Nothing else from the machine program’s own environment reaches it, so a key set there is not passed on.

Start a long task

For a dev server, a build that takes longer than ten minutes, or anything interactive:

  1. Call task_start with argv or command, and cwd. It returns the task id at once.
  2. Read the task’s screen with task_output {"task": <id>}: the last 200 lines by default, lines: 0 for all the machine keeps. Call it again to follow progress; it works whether the task still runs or has ended.
  3. End it with task_stop: the machine sends SIGTERM to its process group, and SIGKILL after 5 seconds.

Lost the id? Over MCP, tasks_list returns everything running now, by author (MCP server).

What a task survives, and what it does not:

EventThe task
your call or conversation ends, the page closes, the network dropskeeps running; reconnect and read it
the machine is pausedis stopped, with every other task
the machine program restartsis stopped; it is listed as lost

The machine keeps 1000 lines of output of its last 50 tasks until it restarts.

Check

exec_run returns exit_code: 0 for the command you expected to succeed. For a task, task_output shows the program’s own output, and tasks_list lists it under your name.

If it fails

  • busy: the machine already runs 8 calls at once. Wait and retry.
  • paused: the owner paused the machine; stop and tell them.
  • timed_out: the call did not finish in time. For long work use a task instead.

Tasks · Risk classes · Work with files