Read and write files during agent execution in the sandboxed environment
During execution, your agent runs inside an isolated sandbox with a dedicated filesystem. You can read and write files using Node.js fs module — no SDK wrapper needed.
Each agent execution gets its own temporary workspace. The only writable directory is /work — this is your working directory, HOME, and CWD. All other paths in the sandbox are read-only for security.Everything in /work is ephemeral — destroyed after execution ends. If you need to persist data, send it to an external API before the execution finishes.
import { writeFile, readFile } from 'fs/promises';import { httpGet } from '@runflow-ai/sdk/http';// Download a fileconst imageBuffer = await httpGet('https://example.com/image.png', { responseType: 'arraybuffer',});await writeFile('/work/image.png', Buffer.from(imageBuffer));// Process itconst data = await readFile('/work/image.png');// ... process the binary data
The sandbox is fully isolated — each execution runs in its own environment with strict constraints:
Constraint
Value
Writable directory
/work only
Everything else
Read-only (agent code, system binaries, libraries)
Process user
Unprivileged (no root access)
Cleanup
All files deleted after execution
Never store secrets in files. Use environment variables or the Credentials module instead. Files in /work are accessible to all code running in the same execution.
The /work directory has 0777 permissions — your agent code can create, read, and write files freely within it. Trying to write anywhere else will fail with a permission error.