Docs/SDK/Filesystem Tools

Filesystem Tools

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.

Table of Contents

  1. Sandbox model
  2. Register filesystem tools
  3. Examples

Sandbox model

Filesystem tools operate under a configured base directory (sandbox root). Requests like:

should be rejected or normalized to stay within the sandbox.

Recommended layout:


Register filesystem tools

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)

Examples

Write then read a file

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)