Available Tools
The SDK includes four disk operation tools:write_file- Create or overwrite text filesread_file- Read file contents with optional line offset and limitreplace_string- Find and replace text in fileslist_artifacts- List files and directories in a path
Building an Agent with Filesystem
You can build an agentic loop where the LLM autonomously calls disk tools to complete file-related tasks. Here’s a complete example:The agent will automatically call the appropriate tools (
write_file, read_file, etc.) to complete your request, creating a fully autonomous file management system.How It Works
1
Initialize clients and create a disk
Set up both the Acontext client and your LLM client (OpenAI or Anthropic). Create a disk to store files.
2
Get tool schemas for your LLM
Convert the disk tools to the schema format your LLM provider expects.
3
Implement the agentic loop
Create a loop that sends messages to the LLM, executes tool calls, and feeds results back until the task is complete.Executing Tools After LLM Response:When the LLM responds with tool calls, iterate through each one and execute them using
DISK_TOOLS.execute_tool() (Python) or DISK_TOOLS.executeTool() (TypeScript):The loop continues until the LLM returns a message without tool calls, indicating the task is complete.
Tool Reference
write_file
Create or overwrite a text file on the disk. Parameters:filename(required) - Name of the file, e.g.,"report.md"content(required) - Text content to write to the filefile_path(optional) - Directory path, e.g.,"/notes/"(defaults to"/")
read_file
Read the contents of a text file from the disk. Parameters:filename(required) - Name of the file to readfile_path(optional) - Directory path where the file is located (defaults to"/")line_offset(optional) - Starting line number (defaults to0)line_limit(optional) - Maximum number of lines to return (defaults to100)
replace_string
Replace all occurrences of a string in a file. Parameters:filename(required) - Name of the file to modifyold_string(required) - String to be replacednew_string(required) - Replacement stringfile_path(optional) - Directory path where the file is located (defaults to"/")
list_artifacts
List all files and directories at a specified path. Parameters:file_path(required) - Directory path to list, e.g.,"/notes/"or"/"