tool interface. These tools give AI agents the ability to read, write, search, and modify files, as well as execute shell commands — all within a security sandbox.
Import
tools object is a convenience bundle containing all five tools keyed by name:
Sandboxing
All tools are sandboxed torootDir, which defaults to the workflow directory. Every file path provided to a tool is resolved relative to this root, and any attempt to escape it (including via symlinks) is rejected with an error.
The sandbox enforces:
- Path resolution. Relative paths are resolved against
rootDir. Absolute paths are validated to ensure they fall within the root. - Symlink traversal. Symlinks that resolve outside the sandbox root are rejected.
- Output size limits. All tool outputs are truncated to
maxOutputBytes(default: 200KB / 200,000 bytes). Files and command outputs exceeding this limit are either truncated or rejected. - Timeouts. Shell commands (
bash,grep) have a default timeout of 60 seconds. Processes that exceed the timeout are killed withSIGKILL. - Network blocking. The
bashtool blocks network-accessing executables by default. See the bash tool section for details.
Tool Call Logging
Every tool invocation is logged to the_smithers_tool_calls database table with the following fields:
| Field | Description |
|---|---|
runId | The current workflow run ID |
nodeId | The task node that invoked the tool |
iteration | The Ralph loop iteration |
attempt | The retry attempt number |
seq | Sequential tool call counter within the task |
toolName | Name of the tool (read, write, edit, grep, bash) |
inputJson | Serialized input arguments |
outputJson | Serialized output (truncated if over maxOutputBytes) |
startedAtMs | Timestamp when the tool call began |
finishedAtMs | Timestamp when the tool call completed |
status | "success" or "error" |
errorJson | Serialized error details (if status is "error") |
read
Read a file from the filesystem. Input schema:- The file is resolved against the sandbox root and validated against symlink escapes.
- If the file size exceeds
maxOutputBytes(default 200KB), the tool throws"File too large". - Output is truncated to
maxOutputBytesif needed.
write
Write content to a file, creating parent directories as needed. Input schema:"ok"
Behavior:
- Parent directories are created recursively if they do not exist.
- If the content byte size exceeds
maxOutputBytes(default 200KB), the tool throws"Content too large". - The content hash (SHA-256) and byte size are logged, but the full content is not stored in the tool call log to conserve space.
edit
Apply a unified diff patch to an existing file. Input schema:"ok"
Behavior:
- The file must already exist. The current contents are read, the patch is applied using the
difflibrary’sapplyPatchfunction, and the result is written back. - If the patch byte size exceeds
maxOutputBytes, the tool throws"Patch too large". - If the file size exceeds
maxOutputBytes, the tool throws"File too large". - If the patch cannot be applied (e.g., context lines do not match), the tool throws
"Failed to apply patch". - The patch hash (SHA-256) and byte size are logged.
grep
Search for a regex pattern in files usingripgrep (rg).
Input schema:
rg -n.
Behavior:
- The search path is resolved and sandboxed to
rootDir. - Uses
ripgrep(rg) under the hood with the-nflag for line numbers. - Output is truncated to
maxOutputBytes(default 200KB). - If the command times out (default 60s), the process is killed and an error is thrown.
- If
rgexits with code 2 (error), the stderr output is thrown as an error. - Exit code 1 (no matches) returns an empty string, not an error.
ripgrep must be installed and available in the system PATH.
Example output:
bash
Execute a shell command. Input schema:- The working directory defaults to
rootDirand is sandboxed. Ifopts.cwdis provided, it is resolved and validated against the sandbox. - Stdout and stderr are captured separately and combined in the output.
- Output is truncated to
maxOutputBytes(default 200KB). - Default timeout is 60 seconds. Processes exceeding the timeout are killed with
SIGKILLvia process group. - Non-zero exit codes throw an error with the exit code or signal name.
Network Blocking
By default, thebash tool blocks commands that access the network. This is controlled by the allowNetwork option in RunOptions, the CLI (--allow-network), or the server configuration.
When allowNetwork is false (the default), the following are blocked:
Blocked executables:
| Category | Commands |
|---|---|
| HTTP clients | curl, wget |
| Remote shells | ssh, scp, sftp, ftp, telnet |
| Network tools | nc / netcat, ping, traceroute, dig, nslookup, nmap, openssl |
| Package managers | npm, bun, pip, pip3, pnpm, yarn, apt, apt-get, brew, cargo, go, gem |
| Version control (remote ops) | git push, git pull, git fetch, git clone, git remote |
| Other | hg, svn, powershell, pwsh |
://, www., http://, https://, ws://, wss://, git@, or ssh:// is blocked.
IP detection: Arguments matching an IP address pattern (e.g., 192.168.1.1:8080) are blocked.
Proxy detection: Arguments containing --proxy, http_proxy, or https_proxy are blocked.
Local git commands (e.g., git status, git diff, git log) are allowed even when network access is disabled.
Example:
Using Tools with Agents
The standard pattern is to pass tools to an AI SDK agent, then assign that agent to a<Task>:
tools bundle:
Configuration
Tool behavior is configured throughRunOptions when calling runWorkflow or through the server/CLI:
| Option | Default | Description |
|---|---|---|
rootDir | Workflow directory | Sandbox root for all file operations |
allowNetwork | false | Allow network-accessing executables in bash |
maxOutputBytes | 200000 (200KB) | Maximum output size for all tools |
toolTimeoutMs | 60000 (60s) | Timeout for bash and grep commands |