Persist `sandbox.sandbox_id` and `handle.pid` (e.g. in a DB or API response) - they are all a later process needs.
From a different process later: `sandbox = Sandbox.connect(sandbox_id)` then `handle = sandbox.commands.connect(pid)` (Python) / `await sandbox.commands.connect(pid)` (JS).
`handle.wait()` blocks until the command finishes, then read the file: `sandbox.files.read('/home/user/out.log')`.
If you do not know the pid, list running processes with `sandbox.commands.list()`.
Known gotchas
Background command stdout/stderr are ONLY delivered to the process that started it - always redirect output to a file for durable, reconnectable results (security and reliability).
Pass untrusted input via envs (`\"$VAR\"`), never by string interpolation, or `$(...)`/backticks can run arbitrary commands.
Set the command timeout to 0 so the command is not killed mid-run, and make the sandbox timeout longer than the whole job.
The sandbox must stay alive for the whole task; use a long timeout or pause/persistence to survive longer.
Give your agent this knowledge — and 17,900+ more routes
One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?