Workspace Filesystem
Note: Workspace Filesystem is Experimental The Workspace API is experimental. Expect iteration and possible breaking changes as we refine the API.
Workspace filesystem provides a persistent (or in-memory) file layer for agents. Use it to store notes, datasets, and intermediate outputs.
Backend options
In-memory is the default. For disk persistence, use NodeFilesystemBackend:
import { Workspace, NodeFilesystemBackend } from "@voltagent/core";
const workspace = new Workspace({
filesystem: {
backend: new NodeFilesystemBackend({
rootDir: "./.workspace",
}),
},
});
All filesystem tool paths are workspace-relative and must start with /.
Filesystem tools
ls: list files in a directoryread_file: read a filewrite_file: write a fileedit_file: edit a filedelete_file: delete a filestat: get file or directory metadatamkdir: create a directoryrmdir: remove a directorylist_tree: list files and directories recursively with depth controllist_files: alias forlist_treeglob: list files matching a globgrep: search for a regex pattern
Behavior
write_filesupportsoverwriteandcreate_parent_dirsdelete_filesupportsrecursiveto delete directories
Read-only mode
Mark the filesystem as read-only to block writes and hide write tools from the toolkit:
const workspace = new Workspace({
filesystem: {
readOnly: true,
},
});
When read-only, workspace_index and workspace_index_content are also disabled.
Tool policies (filesystem)
Tool policies let you enable/disable tools, require approval, or enforce read-before-write:
const agent = new Agent({
name: "workspace-agent",
model,
workspace,
workspaceToolkits: {
filesystem: {
toolPolicies: {
defaults: { needsApproval: true },
tools: {
write_file: { enabled: false },
edit_file: { needsApproval: true },
delete_file: { requireReadBeforeWrite: true },
mkdir: { requireReadBeforeWrite: true },
},
},
},
},
});
requireReadBeforeWrite forces a read_file call before edits/deletes and prompts a re-read if the file changes.
Security notes
- Keep filesystem access within a workspace root.
- Avoid exposing absolute host paths.
- Prefer read-only mode for untrusted agents.
For broader recommendations, see Workspace Security.