Skip to main content
This page will walk you through how to set up an Archil disk and build a real agent with the AI SDK in less than 5 minutes that uses real tools, like bash, against your data. With Archil, you only pay for the infrastructure that you use, which means that this entire tutorial should fit inside of our free plan. For this tutorial, let’s build an agent that writes a storybook for us, creates a nicely formatted PDF document of our book, and delivers an audit-log of every tool that it used to create the book — without the use of a separate sandbox.
This tutorial does not walk through mounting the Archil file system. If you already have a server you want to attach Archil to, see Mount on Linux (FUSE) (or macOS / in a container).
1

Create an API key

Sign in to the Archil console, create an API key from the API keys page, and export it alongside a key for your model provider:
Create your API key in the region closest to where your users are, for this tutorial, you need to use one of the Archil AWS regions where sandboxes are offered (aws-us-east-1, aws-us-west-2, or aws-eu-west-1); see Region availability.
2

Install dependencies

In your project directory, install the required dependencies for this tutorial:
3

Create your agent's workspace

Archil provides the file system workspace for agents to store files, manipulate context, and run complex commands — while providing concurrent access to that workspace from your web application for humans. Each Archil account supports an unlimited number of file systems so we recommend making one for each agent that you plan to run. Make one for our tutorial agent:
The result includes a token that you can use to mount the disk directly. You do not need it for this tutorial.
If you have an existing S3 or GCS bucket you’d like the agent to work against, you can specify it as a data source when creating your disk — see S3 Object Storage. When specifying a data source, your disk will mirror the contents of your bucket.
4

Build the agent

Let’s build our agent to now write us a short story. We use a ToolLoopAgent from the AI SDK to iteratively call tools until we accomplish our goal. We’ll go ahead and give the agent some instructions to use Archil and connect our disk as a set of tools in conditional mode.
That’s the whole integration. createDiskTools automatically gives the agent a set of tools to manipulate data on the disk without a separate sandbox which includes: read/write/delete files, run bash, glob, and grep.You can view your story in the Archil console, or by downloading the contents of the file:
5

Record an audit log

Next, let’s extend our agent to make it ready for production by building an audit log of each tool call that was made while it ran. We can easily build an append-only log on Archil by using the AppendObject function of our extended S3 API.We can use the onToolExecutionEnd lifecycle hook in the AI SDK to record each tool call as it happens.Replace the agent.generate line in your code with the following:
Now, you can view your audit log by reading the contents of the auditPath file.
Which will output the audit log entries to the console that look like this:
You now know the basics of how to build agents with Archil with persistent disks that can scale to any size, have multiple agents work in parallel, and provide strong-consistency for human clients who might interact using a web application via our S3-compatible API.

Next steps

AI SDK integration

Mount several disks as one workspace, and scope what the agent can reach.

Serverless execution

The runtime behind run_bash — fan out across containers, compose disks, no lifecycle to manage.

Multi-agent systems

Branch a disk per agent, run them in parallel, and keep the best result.

Persistent sandboxes

Keep a sandbox warm across tool calls when the agent needs a long-lived machine.

Mount to a Linux server

Use the same disk as a POSIX filesystem from your own machines.

Pricing

View Archil pricing and plan details.