Skip to content

v0.1.5

Choose a tag to compare

@cr-sbarbouche cr-sbarbouche released this 10 Nov 21:19
21f37f6
  • Egress allowlist: create_sandbox(egress=["pypi.org", "*.pythonhosted.org", "10.0.0.0/24:8080"]) instead of all-or-nothing network. The sandbox gets a private --internal network whose only other member is a small allowlist proxy; HTTP_PROXY/HTTPS_PROXY point at it, so pip, apt, curl and Python's urllib just work, and code that ignores them has no route. A name only gets through if it resolves to public addresses, so it can't reach 10.x, the docker host or the cloud metadata endpoint unless an entry says so. The proxy runs under docker's default runtime (runc), not gVisor, because docker's embedded DNS doesn't work under gVisor: it is the one component outside gVisor (about 150 lines, nobody, read-only, all capabilities dropped). Headless only, fixed at creation. agvisor prune and prune_egress() remove what expired sandboxes leave behind. agvisor-mcp takes AGVISOR_EGRESS for the same thing
  • Background jobs: sb.spawn(cmd, timeout=...) returns a Job at once, with poll(), wait(), read(offset) and kill(). It outlives the exec() and your process, and Job(sb, job_id) picks it up again. A running job does not keep an idle_ttl sandbox alive. agvisor-mcp: start_job, job_output and kill_job
  • Directories in and out: sb.put_dir(local, remote) and sb.get_dir(remote, local, max_bytes=50 MB). Links are copied as links and never followed on the way in; on the way out the tar is extracted with tarfile's data filter (nothing lands outside, no device files, no setuid bits), and links that point outside are left out and returned by name. agvisor put and agvisor get do the same from a shell
  • Python sessions: sb.python(code, timeout=60, restart=False) runs code in one long-lived interpreter inside the sandbox, so variables, imports and functions survive between calls, like notebook cells, and the value of a last expression is printed. At timeout the code gets a TimeoutError and the session survives. A Python exception is a traceback in stdout, not a return code. Needs python3 in the image; the session goes with the container
  • agvisor-mcp: new python, read_file, list_files and edit_file(path, old, new) tools. edit_file replaces one exact piece of text that must appear once, so the agent doesn't resend a whole file
  • agvisor-mcp: set AGVISOR_PUT_DIR=HOST_DIR:/DEST and a directory of yours is copied into the sandbox when it is made. It is skipped when /DEST already exists, so a resumed named sandbox keeps its edits. The whole directory goes through one tar in memory: keep it small
  • Tested on real gVisor over ssh:// (docker 29.1.3, runsc 20261102.0 and 20261026.0, Ubuntu 24.04) with tests/test_gvisor_egress.py, test_gvisor_jobs.py and test_gvisor_mcp.py: egress, jobs, directories, the agvisor put/get commands, and the MCP tools including python, edit_file and AGVISOR_PUT_DIR. The MCP tools were called as functions, not through a real MCP client