Repository navigation
Releases
Releases · cr-sbarbouche/agvisor
v0.2.0
- Network rules change while a sandbox runs:
sb.allow(*entries),sb.deny(*entries),sb.egress_rules()andsb.egress_denied(). A!entryinegress=shuts a host out and wins over every allow; its port defaults to every port.allow()un-denies an entry,deny()replaces it with!entry. The proxy reloads on a signal: new connections follow the new rules at once, and tunnels already open to a host that is no longer allowed are closed.egress_denied()lists what the proxy refused ashost:port, leaving out what is allowed by now (it reads the proxy's log). From a shell:agvisor allow NAME host...,agvisor deny NAME host...,agvisor egress NAME [--denied]. The MCP server gets a read-onlyegress_blockedtool (withAGVISOR_EGRESSorAGVISOR_INJECT); the agent has no way to change the rules.create_sandbox(egress=...)now waits until the proxy listens before it starts the sandbox sb.pause()andsb.resume()(agvisor pause/resume,AsyncSandboxtoo) freeze every process; memory stays held, it is a freeze and not a checkpoint.exec()on a paused sandbox raisesSandboxPaused.idle_ttldoes not run out during a pause (the watchdog notices the freeze);lifetimekeeps counting, so a sandbox paused past it is gone when resumed.stop()removes a paused sandbox, andagvisor lsshowspausedrenewable=Truewithlifetime=:sb.renew(seconds)(agvisor renew NAME SECONDS) moves the deadline later or earlier. It is opt-in, because the deadline is a file inside the sandbox: code running there can extend its own life. A plainlifetimeis unchangedcreate_sandbox(mounts={"/host/path": "/inside"})shows a host directory or file read-only, without copying it (--mount, so a missing source is an error). Refused:/, anything under/proc,/sysor/dev, sources under/runor/var/run, and*.sock.agvisor run --mount HOSTPATH:REMOTE, andAGVISOR_MOUNTSfor the MCP servercreate_sandbox(env=),exec(env=, cwd=)andspawn(env=, cwd=). Values reach docker through stdin or a file only you can read, never a command line.agvisor exec --env NAME[=VALUE] --cwd,agvisor run --env, andAGVISOR_ENVfor the MCP serversb.python(code, context="name"): a separate interpreter per name, with its own variables. The MCPpythontool takescontexttoo- MCP
AGVISOR_LOG=/path/audit.jsonl: one JSON line for every tool call (arguments, sandbox, seconds, exit code, and the result or the exception), oneserver_startwith the configuration (no secret values: the names of theAGVISOR_ENVvariables and the hosts ofAGVISOR_INJECT) and onesandbox_createdper sandbox. Readable by its owner only, append-only, never rotated. It records the agent's tool calls, not what the code does inside examples/10_agent_cli.py: Claude Code's CLI inside a sandbox behindegress=andinject=.examples/11_eval_harness.py: one sandbox per trial from aPool, withsnapshot()andrestore()to retry from a clean workspace- The docs site has a What's new page with diagrams
- Tested on real gVisor (runsc 20261026.0, GitHub's Ubuntu runner):
tests/test_gvisor_env.py,test_gvisor_pause.py(the freeze,idle_ttlandlifetimeacross a pause),test_gvisor_renew.py,test_gvisor_pycontexts.py,test_gvisor_mounts.py(writes refused, host edits visible inside),test_gvisor_egress_live.py(pip refused, then allowed on the running sandbox; an open tunnel closed 0.5 s afterdeny()),test_mcp_stdio.py(the audit log written by a real server), and both new examples. Not tested: any of this overhost="ssh://...", and example 10 with a real API key (with its placeholder key the API refuses the request, as it should)
v0.1.9
- The action is named "agvisor sandbox" so it can be listed on the GitHub Marketplace (the name
agvisorbelongs to another account there).uses: cr-sbarbouche/agvisor@v0.1.9is unchanged, and the README's Action examples use this tag - No change to the library, the CLI or the action's inputs since 0.1.8, which introduced the GitHub Action,
agvisor run,ports=,Sandbox.stats()and the egress idle timeout (see the v0.1.8 notes for what was tested and what was not)
v0.1.8
- GitHub Action:
uses: cr-sbarbouche/agvisor@v0.1.8runs a script in a gVisor sandbox on the runner, withimage,run,workspace(the job's files, copied to/workspace),output(a directory copied back to./agvisor-out, even if the script failed),egress,inject,cpus,memory,timeoutandhost. It installs the pinnedrunscwhen the runner has none, and fails the step with the script's exit code.inject:isHOST:HEADER=ENVVAR: the value is the calling step's$ENVVAR, so a secret is never on a command line and the script can use it without holding it.host: ssh://user@vmruns the sandbox on another machine's docker; a self-hosted runner withrunscset up works too (README, "On your own machine instead of GitHub's") agvisor run IMAGE [options] -- COMMAND: what the Action calls. Makes a sandbox, runs the command, removes the sandbox, exits with the command's code.--cpus,--memory,--pids,--timeout,--egress,--inject,--put,--get,--host. The sandbox expires on its own--timeoutplus 5 minutes after it started, so a killed job doesn't leave it runningcreate_sandbox(ports=[8000])publishes those container ports on the docker host's127.0.0.1;sb.port(8000)returns the host port.AGVISOR_PORTSand an MCPporttool (only when set) do the same for the MCP server. Refused withgui,network="none",egress=andinject=;AsyncSandbox.portis includedSandbox.stats()returns CPU, memory, the memory limit and the process count fromdocker stats, with an MCPstatstool andAsyncSandbox.stats. Under gVisor, memory counts/tmpbut not root-filesystem writes, and the process count is host threads (an idle sandbox reads about 35); a call takes about 1 s- The egress proxy closes a tunnel that has been quiet in both directions for 15 minutes. A download the client says nothing during is not quiet
examples/09_browser_egress.py: Chromium ignoresHTTPS_PROXY, so the example passes the proxy tochromium.launch(proxy=...); a host that isn't allowed fails withnet::ERR_TUNNEL_CONNECTION_FAILED- Tested on real gVisor (runsc 20261026.0, GitHub's Ubuntu runner):
tests/test_gvisor_ports.py,tests/test_gvisor_stats.py, the examples including 09, and the Action itself (uses: ./: files in and out, an allowed and a refused host, an injected key reaching api.anthropic.com and absent from the sandbox's environment). The idle timeout has only a unit test with a 0.3 s timeout. Not tested: a self-hosted runner,host: ssh://...against a real VM,ports=overhost="ssh://...",inject=used bygitorcurl(Python'surllibonly)
v0.1.7
inject=:create_sandbox(inject={"api.example.com": {"Authorization": "Bearer ..."}})gives the sandbox a credential it can use but not read. The egress proxy ends the sandbox's HTTPS to that host, sets those headers on every request (replacing one of the same name the sandbox sent) and sends it on over TLS of its own, with the host's real certificate verified. The sandbox trusts a certificate authority made for it on your machine, whose private key is dropped after it signs the one certificate the proxy needs; it is told throughSSL_CERT_FILE,REQUESTS_CA_BUNDLE,CURL_CA_BUNDLE,GIT_SSL_CAINFOandNODE_EXTRA_CA_CERTS. The credential is not in the sandbox's environment, files or command lines. It is in the proxy container's environment, so whoever can rundocker inspecton the host can read it. Plain host names only,https://on port 443 only (http://to such a host is refused), one request per connection, no HTTP/2 or websockets to those hosts. A request is only given a credential if it has a path, oneHostheader naming the host and no folded headers. Needspip install 'agvisor[inject]'(thecryptographypackage) and the image needs a CA bundle. Same restrictions asegress=.AGVISOR_INJECTsets it for the MCP server. The README Security section has an entry for itagvisor.aio:AsyncSandbox,AsyncJob,create_sandbox(),list_sandboxes()andprune_egress()forasynciocode, with the arguments, results and errors of the synchronous ones; every blocking call runs in a worker thread, so calls run side by side.async with AsyncSandbox(...)starts and stops the sandbox. Cancelling an await stops waiting, not the command.exec(on_output=)can be a plain function or anasync defPool(size, image, **create_sandbox_args): keepssizestarted sandboxes ready, soacquire()doesn't wait fordocker run, and starts a replacement in the background. A spare that expired or fails a health check is skipped.lifetime=oridle_ttl=is required,name=,owner=andgui=are refused.close()orwithstops the sparessnapshot()pauses a running sandbox while its data dir is copied, so the snapshot is the data dir at one moment, not a mix of before and after a write. Its processes stop for those few seconds and anexec()meanwhile fails; a running sandbox that can't be paused raises instead of being copied- MCP server, with
AGVISOR_NAME:snapshot(tag)andrestore(tag)take a tag (no tag still meanscheckpoint), and there are two new tools,list_snapshots()anddelete_snapshot(tag).AGVISOR_SNAPSHOTS(default 3) limits how many snapshots exist at once, since each one is a full copy of/workspace examples/08_browser.py: a headless Chromium (Playwright's image) opens a page and takes a screenshot under gVisor, with a README section onLimits(shm=), the network and the matching Playwright version. The example is run by thegvisorCI job with the others- README: the two relative links are absolute (they were dead on PyPI), and the intro lists what the library has now
- Tested on real gVisor (runsc 20261026.0, GitHub's Ubuntu runner):
tests/test_gvisor_aio.py,test_gvisor_pool.py,test_gvisor_snapshot.py(a copy of a running writer spans one pass of it with the pause, several without),test_mcp_stdio.py(named mode),test_inject_gvisor.pyandtest_inject_mcp_stdio.py(against api.anthropic.com, which answers differently with and without the injected key), and the browser example.inject=was run with Python'surllibonly;curl,git, Node and Go were not run against it. Not tested:Pooloraiooverhost="ssh://...", a browser together withegress=
v0.1.6
network="isolated":create_sandbox(network="isolated")puts the sandbox on one shared docker bridge,agvisor-isolated, created with inter-container traffic off. Sandboxes on it keep the internet but can't connect to each other's ports (the connection times out); files were never shared between sandboxes, this is only the network. The default is still"bridge"(docker0), so a host firewall written for docker0 keeps applying to existing setups;isolatedsandboxes sit on a new bridge, so give it rules of its own. Docker's embedded DNS doesn't work under gVisor on user-defined networks (no name resolves, not even with--dns), so an isolated sandbox is given the resolver servers a sandbox on"bridge"gets. A network of that name that exists with inter-container traffic on is refused, not used."isolated"is now a reserved network nameLimits(workspace="10g"): a hard cap on the/workspacevolume of a named sandbox (the home forgui=True), whichdisknever covered, so a runaway process could fill the host's disk through it. It is an xfs project quota that docker sets on the volume (docker volume create --opt size=): past the cap writes fail withNo space left on device, the sandbox keeps running, and the cap is still there after astop(). It needs a host whose/var/lib/docker/volumesis on xfs mounted withpquota(setup in the README, Host setup); on any other hostcreate_sandboxraises with docker's message instead of leaving the volume uncapped. The cap belongs to the volume and is fixed when it is created, likeowner=: a different cap later, or a cap asked for on a volume made without one, raisesValueError(delete()it first, which erases its files); asking for no cap leaves the one it has. Named sandboxes only, off by defaultexamples/: seven small runnable scripts: quickstart, resuming and snapshots, limits, files and jobs, the egress allowlist,network="isolated"and the/workspacecap. CI runs every one of them against real gVisor, so they can't rot- Video: a one-minute walk through the two features, made from the real output of the examples on gVisor (attached:
whats-new-0.1.6.mp4) - The firewall rule for the cloud metadata endpoint in the README (
iptables -I DOCKER-USER -d 169.254.169.254 -j DROP) is now checked in CI against a fake metadata service on the runner (tests/test_gvisor_imds.py): a sandbox on"bridge"reads it, and stops reading it once the rule is in. That is a fake on the CI runner, not a real EC2 or Azure instance - CI: a new
gvisorjob runs every real-runsc test script and the examples on each push and pull request, on the runner's own docker, includingtest_mcp_stdio.py(agvisor-mcpdriven over stdio by the realmcpclient). Until now these were only run by hand - Tested on real gVisor (runsc 20261026.0, GitHub's Ubuntu 26.04 runner) with
tests/test_gvisor_isolated.pyandtests/test_gvisor_workspace.py, the cap on a loop-mounted xfs filesystem withpquota. Not tested:isolatedor the cap on a real cloud VM, either of them withgui=True, and the/etc/fstabline in the README's xfs setup
v0.1.5
- 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--internalnetwork whose only other member is a small allowlist proxy;HTTP_PROXY/HTTPS_PROXYpoint at it, sopip,apt,curland Python'surllibjust work, and code that ignores them has no route. A name only gets through if it resolves to public addresses, so it can't reach10.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 pruneandprune_egress()remove what expired sandboxes leave behind.agvisor-mcptakesAGVISOR_EGRESSfor the same thing - Background jobs:
sb.spawn(cmd, timeout=...)returns aJobat once, withpoll(),wait(),read(offset)andkill(). It outlives theexec()and your process, andJob(sb, job_id)picks it up again. A running job does not keep anidle_ttlsandbox alive.agvisor-mcp:start_job,job_outputandkill_job - Directories in and out:
sb.put_dir(local, remote)andsb.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'sdatafilter (nothing lands outside, no device files, no setuid bits), and links that point outside are left out and returned by name.agvisor putandagvisor getdo 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. Attimeoutthe code gets aTimeoutErrorand the session survives. A Python exception is a traceback instdout, not a return code. Needspython3in the image; the session goes with the container agvisor-mcp: newpython,read_file,list_filesandedit_file(path, old, new)tools.edit_filereplaces one exact piece of text that must appear once, so the agent doesn't resend a whole fileagvisor-mcp: setAGVISOR_PUT_DIR=HOST_DIR:/DESTand a directory of yours is copied into the sandbox when it is made. It is skipped when/DESTalready 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) withtests/test_gvisor_egress.py,test_gvisor_jobs.pyandtest_gvisor_mcp.py: egress, jobs, directories, theagvisor put/getcommands, and the MCP tools includingpython,edit_fileandAGVISOR_PUT_DIR. The MCP tools were called as functions, not through a real MCP client
v0.1.4
- Snapshots for named sandboxes:
sb.snapshot("clean")copies/workspaceinto a second volume in a throwaway gVisor container (no network), andsb.restore("clean")puts it back in a fresh container (processes are lost).list_snapshots()returns the tags,delete_snapshot(tag)frees one, anddelete()removes them all with the sandbox. Each snapshot costs as much host disk as/workspace, which still has no size cap - Files in and out:
sb.put(path, bytes)andsb.get(path, max_bytes=10 MB), throughexec()with base64 (needs GNU coreutils in the image).get()reads regular files only and refuses more thanmax_bytes, because what comes out of a sandbox is untrusted - New
agvisorcommand:agvisor ls,agvisor rm NAME... | --older-than SECONDS [--data]andagvisor exec NAME cmd..., with--hostand--owner.rmnever removes everything without a name or an age, so a retention job isagvisor rm --older-than 14400in cron;--dataalso erases the files and snapshots of named sandboxes agvisor-mcp: newwrite_file(path, content)tool, so the agent doesn't need a heredoc (it breaks on quoting and on very long content)agvisor-mcp: setAGVISOR_NAMEand the sandbox becomes a named one (/workspacekept in a volume, andreset()keeps it), and the agent also getssnapshot()andrestore()over a single checkpoint slot. Unset, nothing changes. That volume has no size cap and is shared by every server process using the same name- Behaviour change: headless sandboxes now start with
--entrypoint=. An image with anENTRYPOINTused to takesleep infinityas its arguments and exit at once; it works now, but the entrypoint's own setup script no longer runs. The README and skill no longer say "never set an ENTRYPOINT" - Tested on real gVisor over
ssh://(WSL2 Ubuntu 24.04, docker 29.1.3, runsc release-20261102.0): snapshot, restore, list and delete, the ENTRYPOINT fix (the test fails without it), and the MCP named-mode functions called directly.put()/get()were run against a real container on runc and on gVisor. Theagvisorcommand andwrite_filehave unit tests only, and the MCP tools were not run through a real MCP client this time
v0.1.3
- New
agvisor-mcp: an MCP server so Claude Code, VS Code and OpenCode can run code in an agvisor sandbox instead of on the host.pip install 'agvisor[mcp]', thenuvx --from 'agvisor[mcp]' agvisor-mcp(needsmcp>=2; the library itself still has no dependencies, and its API is unchanged) - Two tools,
run(command, timeout)andreset(). Image, network (off by default), CPU/memory and expiry come fromAGVISOR_*environment variables, so the agent can't choose them - One anonymous sandbox per server process: no
/workspacevolume and nothing shared between projects. It expires after 10 idle minutes or 1 hour; a sandbox killed for going over memory or pids is reported as "sandbox was reset", never silently re-run - README: new "Coding agents" section with setup for Claude Code, VS Code and OpenCode, and two links that were relative are now absolute (PyPI doesn't rewrite them)
- An agent skill is in the repo under
.claude/skills/agvisor/(not part of the package): when to sandbox, and the gotchas - Tested on real gVisor over
ssh://(WSL2 Ubuntu 24.04, docker 29.1.3, runsc release-20261102.0): library 9/9, MCP server 11/11, and OpenCode 2.0.27 with a real model. Claude Code was tried against a stand-in docker, VS Code not yet
v0.1.2
- list_sandboxes() handles now have .created (timezone-aware datetime) and .owner; list_sandboxes(owner=) filters
- create_sandbox(name=, owner=): the first owner claims a named sandbox's data volume; a different owner, or none, gets PermissionError. Opt-in, not authentication; a volume made without owner= can't be adopted later (see README, Security)
- list_sandboxes() output is parsed from tab-separated docker output, and named start() makes two more docker calls (volume create/inspect)
- README documents the agvisor-desktop npm package
v0.1.1
What's Changed
- Release 0.1.1: exec() raises SandboxGone; project URLs and typing metadata by @cr-sbarbouche in #3
Full Changelog: v0.1.0...v0.1.1