Use sandboxed file tools for safe agent read/write operations (no path traversal), with an explicit root directory you control.
This page covers:
File I/O should be explicit and sandboxed.
A filesystem tool without a sandbox is a security boundary violation. Predicate filesystem tools are restricted to a root directory you choose.
Filesystem tools operate under a configured base directory (sandbox root). Requests like:
../secrets.txt/etc/passwdshould be rejected or normalized to stay within the sandbox.
Recommended layout:
./.sentience/files/from predicate.tools import ToolRegistry, FileSandbox, ToolContext, register_filesystem_tools
registry = ToolRegistry()
sandbox = FileSandbox("./.sentience/files")
register_filesystem_tools(registry, sandbox)
ctx = ToolContext(runtime, files=sandbox)await registry.execute("write_file", {"path": "notes.txt", "content": "hello"}, ctx=ctx)
result = await registry.execute("read_file", {"path": "notes.txt"}, ctx=ctx)
print(result.content)