Core Concepts
File System
Learn how to use /workspace, when to read files directly, when to use artifacts, and how checkpoints, documents, and recordings fit into file workflows.
The file system is the memory of a sandbox.
The most important path is:
/workspaceThat is where your workflow should usually place:
- downloaded inputs
- generated reports
- transformed documents
- intermediate files another step needs later
Why /workspace matters
If your workflow spans more than one step, /workspace is what ties those steps together.
For example:
- the agent can browse a site and save notes to
/workspace/research.md - a later step can convert that report to PDF
- your app can read the file or download it as an artifact
Read, write, and list files
Write:
await sandbox.fs.write("/workspace/report.txt", "hello");Read:
const content = await sandbox.fs.read("/workspace/report.txt");List:
const entries = await sandbox.fs.list("/workspace");When to read a file directly
Direct reads are best when:
- the file is small
- you want the contents immediately
- the file is mostly internal workflow output
When to use artifacts instead
Artifacts are for outputs you want to treat as durable deliverables.
Common examples:
- PDFs
- packaged workspace outputs
- checkpoint-related files
- browser recordings
Read artifact state:
const state = await sandbox.getArtifacts();Create a download URL:
const download = await sandbox.getArtifactDownloadUrl("artifact-key");
console.log(download.url);Checkpoints
A checkpoint is a saved restore point for the sandbox.
const checkpoint = await sandbox.checkpoint();
const checkpoints = await sandbox.listCheckpoints();
await sandbox.restoreCheckpoint(checkpoints[0].id);Use checkpoints when:
- a workflow is long
- you want a recovery point before a risky step
- a human will step in and you want an easy restore target
Document conversion
Document tools let the sandbox convert files as part of the workflow.
await sandbox.convertDocument("/workspace/report.html", {
format: "pdf",
});Recordings
When browser recording is enabled, the recording is saved as an artifact.
That is useful for:
- audit trails
- QA review
- support and debugging
Recommended output strategy
For most agent workflows:
- let the agent write working files into
/workspace - inspect the directory with
fs.list() - read small files directly with
fs.read() - convert or package final outputs
- use artifacts for durable downloads