- Running untrusted AI-generated code on a machine that is close to the context that the AI is attempting to work on, without risking that code breaking the origin server.
- Running map-reduce style jobs across large data sets for data analysis tasks such as full-text search or aggregation.
- Using your disk from a different region in order to avoid excessive network latency between your application code and the disk, and reduce the amount of data transferred out of Archil.
disk.exec() invocation at the default size counts as one serverless tool call, even when it runs several
commands. Execution is included in the per-call price. See Pricing & Billing.
Working directory and environment
Each command starts with the working directory set to where your Archil disk is mounted (/mnt/archil). The default runtime image includes most common Unix tools. To run in a different environment,
choose an image, or install additional tools by directing the binaries to your disk.
Choosing an image
By default, commands run in Archil’s exec image. To run a command in your own environment, passbaseImage
(base_image in Python) with any public Linux OCI image built for amd64, such as python:3.13. Docker Hub
shorthand works, as does a full reference such as ghcr.io/acme/agent-runtime:v2.
imageId (image_id in Python) instead. The exec runs
the image’s latest successful build. An image that has not finished its first build is rejected with 409
image_not_ready. baseImage and imageId are mutually exclusive.
/mnt/archil in every image.
Choosing a size
Each command runs in a microVM with 2 vCPU and 4096 MiB of memory by default. PassvcpuCount (1 to 32) and
memSizeMib (256 to 65,536) to size it for the work, such as a build or a data-processing step that needs more
memory. In Python, these are vcpu_count and mem_size_mib.
403
tool_call_size_limit_exceeded.
Restricting network access
By default, a command has unrestricted network egress. On the Developer, Team, and Enterprise plans, passnetwork
to apply the same egress rules as the sandbox firewall, such as denying everything but
a package registry:
network is rejected with 403 network_plan_required.
baseImage, imageId, vcpuCount, memSizeMib, and network work the same way on multi-disk commands
run with archil.exec.
Composing multiple disks into a single command
Often, users need to run commands on multiple disks at once. For example, if you’re building an AI agent which has access to a read-only customer-specific disk and a read-write session-specific disk, and you want your agent to use documents on both disks. To run a command against several disks, you instead pass a map of disks intoarchil.exec. Each
disk is automatically mounted to the /mnt/archil/<key> path inside the sandbox. For example, in the
code below, the data disk is mounted to /mnt/archil/data and the logs disk is mounted to /mnt/archil/logs.
Specifying disk options
You may want to run a command in which some disks have reduced permissions, so the code running cannot modify them. Serverless execution supports specifying whether or not a disk should be marked as read-only or whether it should be limited to a subdirectory of the disk. For example, in the code below, thelogs disk will be mounted to /mnt/archil/logs. That directory
will be read-only, and code in the sandbox cannot modify it. It will only display the contents of
the app/logs subdirectory of the disk.
conditionalto write without a checkout, so several clients can write to the disk at once. See Sharing disks.checkoutPaths(checkout_pathsin Python) to check out paths relative to the mount before the command starts, andqueueMs(queue_ms) to wait that many milliseconds for each checkout. Neither combines withreadOnly.
Streaming output and input
Withstream: true (stream=True in Python), exec returns once the command has started, with the same process
handle a sandbox process has. wait() returns its exit code and output,
as in the samples above, or iterate its output while it runs:
cwd, env, terminal, and timeoutSeconds
(timeout_seconds in Python). Send input with sendInput (send_input) and end it with closeStdin
(close_stdin). kill() and disconnect() both stop the command and its microVM. disk.exec mounts the disk at
/mnt/archil, and archil.exec mounts each disk at /mnt/archil/<key>. In TypeScript, streaming runs on Node.js
and Bun; elsewhere, leave out stream and exec returns once the command finishes.
Consistency with other clients
Serverless execution works like other Archil clients, with the same read-after-write consistency model. A file written to the disk by one command is immediately visible to the next command that reads it. By default, disks are mounted in shared mode, which means that you’ll need to take care to callarchil checkout before mutating files on the disk. For more details on how to
checkout or checkin files in shared mode, see Sharing disks.
Limits
- After 5 minutes, the call returns
504withExec timed outand the command is stopped. Writes the command flushed withfsyncbefore the timeout are durable; other writes are flushed on a best-effort basis as the command is stopped. For longer work, use a persistent sandbox, which has no per-command timeout. - A command longer than 100 KiB is rejected with
400. There is no separate stdin. To pass a larger input, write it to the disk first, for example withputObject, and have the command read the file. - Output past 4 MiB on a stream is dropped, and the stream ends with
[output truncated]. To keep larger output, write it to a file on the disk and read it with the getObject API. - When a command finishes, its writes to the mounted disk are committed before the response returns. If committing fails, the
command’s exit code is non-zero and stderr says
archil: command output may not have been durably committed. - Users can execute hundreds of commands in parallel, contact us to have your limits raised to thousands.
Latency
Each call starts a fresh microVM with your disks mounted. Every result reportstiming.queueMs, the time from the
request arriving to the command starting, which includes booting the microVM and mounting the disks. In our
measurement from a laptop to a disk in AWS us-west-2, a trivial command (true) returned in 82 ms at the median end
to end, including about 40 ms of internet round trip, with a median queueMs of 37 ms. The first call on a newly
created disk took longer, 331 ms at the median. See
How fast is a serverless tool call?
for the full results and a script to reproduce them.
These figures are for the default image and size, which start from a pool of ready microVMs. A command with a
different image or size boots its microVM on demand, so its queueMs is
higher.